/* ===== Brain Arena — 공통 스타일 (모바일 우선) ===== */
:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --primary: #5b6cff;
  --primary-dark: #3f4fd6;
  --accent: #ff7a59;
  --text: #1f2333;
  --muted: #6b7280;
  --line: #e7e9f2;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(30, 40, 90, 0.08);
  --shadow-sm: 0 2px 8px rgba(30, 40, 90, 0.06);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", Pretendard, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary-dark); text-decoration: none; }

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== 헤더 ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}
.brand .logo {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-size: 16px;
}
.nav-back {
  font-size: 14px; color: var(--muted); font-weight: 600;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; gap: 2px; background: #eef0f6; border-radius: 999px; padding: 3px; }
.lang-opt {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 800; line-height: 1; color: var(--muted);
  padding: 6px 9px; border-radius: 999px; transition: color .15s, background .15s;
}
.lang-opt:hover { color: var(--text); }
.lang-opt.on { color: var(--primary-dark); background: #fff; box-shadow: var(--shadow-sm); }

/* ===== 메인 ===== */
main { flex: 1; padding: 20px 0 40px; }

.page-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ===== 게임 카드 그리드 (랜딩) ===== */
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 420px) { .game-grid { grid-template-columns: 1fr; } }

.game-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.game-card:active { transform: scale(.98); }
.game-card.playable:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.game-card .emoji { font-size: 34px; }
.game-card h3 { font-size: 16px; font-weight: 700; }
.game-card p { font-size: 13px; color: var(--muted); }
.game-card .tag {
  align-self: flex-start; margin-top: 6px;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: #eef0ff; color: var(--primary-dark);
}
.game-card.soon { opacity: .6; }
.game-card.soon .tag { background: #f1f2f6; color: var(--muted); }
.game-card .best {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 700; color: var(--accent);
}

/* ===== 버튼 ===== */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 15px;
  padding: 13px 20px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff;
  transition: background .15s ease, transform .1s ease;
  width: 100%;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { background: #c7cbe0; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--primary-dark); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: #f0f1f8; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #ef643f; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }

/* ===== 게임 공통 무대 ===== */
.stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 16px;
  margin-bottom: 20px;
}
.hidden { display: none !important; }

.hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.hud .pill {
  background: #eef0ff; color: var(--primary-dark);
  font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px;
}
.hud .pill strong { font-size: 15px; }

/* ===== SEO 설명 영역 ===== */
.game-desc {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow-sm);
}
.game-desc h2 { font-size: 18px; margin: 18px 0 8px; }
.game-desc h2:first-child { margin-top: 0; }
.game-desc p { font-size: 14px; color: #3a4053; margin-bottom: 10px; }
.game-desc ul { margin: 0 0 12px 18px; font-size: 14px; color: #3a4053; }
.game-desc li { margin-bottom: 4px; }

/* ===== 광고 슬롯 (승인 후 실제 코드 삽입) ===== */
.ad-slot {
  margin: 20px 0; min-height: 90px;
  display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: #c2c6d6; font-size: 12px; background: #fafbff;
}

/* ===== 푸터 ===== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0; margin-top: auto;
  font-size: 13px; color: var(--muted); background: var(--card);
}
.site-footer .container { display: flex; flex-direction: column; gap: 8px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ===== 토스트/결과 ===== */
.result-score { text-align: center; padding: 10px 0 6px; }
.result-score .num { font-size: 48px; font-weight: 800; color: var(--primary); line-height: 1; }
.result-score .label { color: var(--muted); font-size: 14px; margin-top: 4px; }
.result-msg { text-align: center; font-weight: 700; margin: 8px 0 4px; }

/* ===== 리더보드 ===== */
.lb { margin-top: 20px; text-align: left; border-top: 1px solid var(--line); padding-top: 16px; }
.lb-title { font-size: 15px; font-weight: 800; text-align: center; margin-bottom: 12px; }
.lb-submit { display: flex; gap: 8px; margin-bottom: 6px; }
.lb-nick {
  flex: 0 0 120px; padding: 11px 12px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); font-size: 15px; font-family: inherit; color: var(--text);
}
.lb-nick:focus { outline: none; border-color: var(--primary); }
.lb-btn {
  flex: 1; border: none; background: var(--primary); color: #fff; font-weight: 700;
  border-radius: var(--radius-sm); font-family: inherit; font-size: 15px; cursor: pointer;
}
.lb-btn:active { transform: scale(.98); }
.lb-btn:disabled { background: #9aa2c8; cursor: default; }
.lb-msg { font-size: 13px; color: var(--accent); font-weight: 700; min-height: 18px; text-align: center; }
.lb-top { margin-top: 8px; max-height: 340px; overflow-y: auto; }
.lb-loading, .lb-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 16px 0; line-height: 1.7; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.lb-table td:first-child { width: 46px; color: var(--muted); font-weight: 800; text-align: center; }
.lb-table td:last-child { text-align: right; font-weight: 800; color: var(--primary-dark); width: 66px; }
.lb-table tr.me td { background: #eef0ff; }
.lb-table tr.me td:nth-child(2)::after { content: " ★"; color: var(--primary); font-size: 11px; font-weight: 700; }
.lb-table tbody tr:nth-child(1) td:first-child { color: #f59e0b; }
.lb-table tbody tr:nth-child(2) td:first-child { color: #9ca3af; }
.lb-table tbody tr:nth-child(3) td:first-child { color: #d97706; }
