@font-face {
  font-family: 'DungGeunMo';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/DungGeunMo.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf7f0;
  --bg-dot: #e6dfd1;
  --surface: #ffffff;
  --surface-soft: #f4efe4;
  --ink: #23212d;
  --ink-muted: #68637a;
  --border: #23212d;
  --shadow: #dfd7c7;
  --coral: #ff5a5f;
  --yellow: #ffb800;
  --mint: #2ec4b6;
  --green: #38b000;
  --blue: #3b82f6;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.25px, transparent 1.25px);
  background-size: 18px 18px;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

/* 언어별 전용 폰트 세팅 */
body.lang-en {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
body.lang-ja {
  font-family: 'DotGothic16', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
}
body.lang-ko {
  font-family: 'DungGeunMo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

/* 헤더 */
.portal-header {
  background: var(--surface);
  border-bottom: 3px solid var(--border);
  box-shadow: 0 4px 0 rgba(35, 33, 45, 0.08);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.portal-header-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}

.brand-logo-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--yellow);
  border: 2.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 0 var(--border);
}

.brand-title {
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.brand-badge {
  background: var(--coral);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 4px 7px;
  border-radius: 6px;
  border: 2px solid var(--border);
}

/* 언어 스위처 */
.lang-switcher {
  display: inline-flex;
  background: var(--surface-soft);
  border: 2.5px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  color: var(--ink-muted);
  border: none;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn.active {
  background: var(--ink);
  color: #ffffff;
}

/* 게임 탭 */
.game-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.game-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--ink-muted);
  border: 2.5px solid var(--border);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--border);
  transition: transform 0.08s ease, background 0.12s ease;
}

.tab-btn:hover {
  background: #ebe4d5;
  color: var(--ink);
}

.tab-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--border);
}

.tab-btn.active {
  background: var(--yellow);
  color: var(--ink);
}

.tab-btn small {
  font-size: 10px;
  font-weight: 800;
  background: #ffffff;
  color: var(--ink-muted);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* 3단 반응형 레이아웃 */
.portal-layout {
  max-width: 1320px;
  width: 100%;
  margin: 20px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) 268px;
  gap: 20px;
  align-items: start;
  flex: 1;
}

.clean-card {
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--shadow);
  padding: 16px;
}

.card-label {
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--ink-muted);
  margin-bottom: 10px;
  letter-spacing: 0.4px;
}

/* 좌측 애드센스 영역 */
.ad-placeholder {
  background: var(--surface-soft);
  border: 2px dashed #c8bfb0;
  border-radius: 10px;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 12px;
  gap: 8px;
}

.ad-icon { font-size: 26px; }
.ad-title { font-size: 14px; font-weight: 800; color: var(--ink); }
.ad-desc { font-size: 12px; color: var(--ink-muted); }
.ad-size {
  font-size: 11px;
  font-weight: 700;
  background: #ffffff;
  border: 1.5px solid #d7cfc0;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--ink-muted);
}

/* 중앙 게임 스테이지 */
.center-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.hud-bar {
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--shadow);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
}

.hud-label {
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--ink-muted);
}

.hud-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 15px;
  color: var(--ink);
}

.hud-value.accent { color: var(--coral); }
.hud-value.bone { color: #d97706; }

.hud-actions {
  display: flex;
  gap: 6px;
}

.ui-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--ink);
  border: 2.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--border);
  padding: 6px 12px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.1s ease;
}

.ui-btn:hover { filter: brightness(0.97); }
.ui-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border);
}

.ui-btn.primary {
  background: var(--green);
  color: #ffffff;
}
.ui-btn.accent {
  background: var(--coral);
  color: #ffffff;
}
.ui-btn.large { padding: 11px 22px; font-size: 15px; }
.ui-btn.full-width { width: 100%; padding: 10px 12px; font-size: 14px; }

/* 캔버스 래퍼 (Poki 스타일 깔끔한 게임 프레임) */
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #87ceeb;
  border: 4px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 0 var(--shadow);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(35, 33, 45, 0.58);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.canvas-overlay.hidden { display: none; }

.overlay-box {
  background: var(--surface);
  border: 3.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  padding: 22px 24px;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.overlay-box h2 {
  font-family: 'Silkscreen', 'Press Start 2P', monospace;
  font-size: 22px;
  color: var(--coral);
  margin-bottom: 6px;
}

.overlay-box p {
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.overlay-scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface-soft);
  border: 2.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  margin-bottom: 16px;
}

.overlay-scores span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
}

.overlay-scores strong {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: var(--ink);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
}

.theme-badge {
  color: var(--ink);
  font-weight: 800;
}

.control-tip {
  color: var(--ink-muted);
  font-weight: 600;
}

/* 하단 안내 카드 */
.guide-card h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
}

.guide-card p {
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guide-item {
  background: var(--surface-soft);
  border: 2px solid #dfd7c7;
  border-radius: 12px;
  padding: 12px 14px;
}

.guide-item h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
}

.guide-item ul {
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink-muted);
}

.guide-item li { margin-bottom: 5px; }
.guide-item code {
  background: #ffffff;
  border: 1.5px solid #d5ccb9;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--ink);
}

/* 우측 $WEBSITE 스폰서 위젯 */
.sponsor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: inline-block;
}

.sponsor-quote-box {
  background: #fff9e6;
  border: 2.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.quote-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.quote-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
  word-break: keep-all;
}

.quote-owner {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
}

.quote-owner strong { color: var(--ink); }

.sponsor-price-box {
  background: var(--surface-soft);
  border: 2px solid #dfd7c7;
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 12px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.price-row.sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-muted);
}

.sponsor-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.45;
}

/* 모달 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 33, 45, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.hidden { display: none; }

.modal-box {
  width: 100%;
  max-width: 400px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.modal-close {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.modal-desc {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--ink);
}

input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface-soft);
  color: var(--ink);
  border: 2.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 12px;
}

input[type="text"]:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--blue);
}

.filter-warning {
  background: #fff0f0;
  border: 2px solid var(--coral);
  border-radius: 10px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.filter-warning.hidden { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 푸터 */
.portal-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  border-top: 2.5px solid #e5ded0;
  background: var(--surface);
  margin-top: 24px;
}

/* 모바일/태블릿 반응형 */
@media (max-width: 1040px) {
  .portal-layout {
    grid-template-columns: 1fr;
    max-width: 720px;
    gap: 14px;
  }

  .center-stage { order: 1; }
  .right-panel { order: 2; }
  .left-panel { order: 3; }

  .ad-placeholder {
    min-height: 110px;
  }
}

@media (max-width: 600px) {
  .portal-header { padding: 10px 12px; }
  .brand-title { font-size: 16px; }
  .brand-logo-dot { width: 28px; height: 28px; font-size: 15px; }
  .brand-badge { display: none; }
  .lang-btn { font-size: 11px; padding: 4px 8px; }
  .tab-btn { font-size: 12px; padding: 6px 10px; }
  .hud-bar { padding: 8px 10px; }
  .hud-group { gap: 8px; }
  .hud-stat { padding: 4px 8px; }
  .hud-value { font-size: 13px; }
  .hud-label { font-size: 10px; }
  .ui-btn { font-size: 12px; padding: 5px 9px; }
  .guide-grid { grid-template-columns: 1fr; }
}
