/* ── Reset & variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0a1a;
  --nav-bg:    #110d22;
  --surface:   #15102b;
  --surface2:  #1a1435;
  --border:    #2d1f5e;
  --border-lt: #1c1440;
  --purple:    #5b21b6;
  --purple-lt: #7c3aed;
  --accent:    #a78bfa;
  --text:      #f0ebff;
  --muted:     #9d8ec4;
  --dim:       #6d5d8f;
  --dimmer:    #4c3d6e;
  --green:     #34d399;
  --red:       #f87171;
  --yellow:    #fbbf24;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ── Nav ── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px;
  flex-shrink: 0;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: 2px;
  color: var(--text);
  text-decoration: none;
}

.nav-logo {
  width: 26px; height: 26px;
  background: var(--purple);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.nav-score-bar {
  display: flex; align-items: center; gap: 1.5rem;
  font-size: 13px;
}

.score-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

.score-pill .label { color: var(--dim); font-size: 11px; letter-spacing: 1px; }
.score-pill .value { color: var(--accent); font-weight: 600; font-size: 15px; }

.round-indicator {
  color: var(--dim); font-size: 12px; letter-spacing: 1px;
}

/* ── Screens ── */
main { flex: 1; display: flex; flex-direction: column; }

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.screen.active { display: flex; }

/* ── Setup screen ── */
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
}

.game-title {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text);
  margin-bottom: 4px;
}

.game-subtitle-jp {
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.game-tagline {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2rem;
  font-style: italic;
}

.difficulty-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.diff-btn {
  padding: 10px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-btn:hover { border-color: var(--purple-lt); color: var(--text); }
.diff-btn.selected {
  border-color: var(--purple-lt);
  background: #1e1245;
  color: var(--accent);
}

.diff-btn .diff-jp { display: block; font-size: 17px; margin-bottom: 2px; }
.diff-btn .diff-en { display: block; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }

.how-to {
  background: var(--surface2);
  border: 1px solid var(--border-lt);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.75rem;
  text-align: left;
}
.how-to p { font-size: 12px; color: var(--muted); line-height: 1.7; }
.how-to strong { color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  border: none;
  font-family: inherit;
}
.btn:hover:not(:disabled) { opacity: 0.85; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary   { background: var(--purple); color: var(--text); width: 100%; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost     { background: transparent; color: var(--dim); font-size: 12px; }
.btn-correct   { background: #064e3b; border: 1px solid var(--green); color: var(--green); }
.btn-next      { background: var(--purple); color: var(--text); }

/* ── Game screen ── */
#screen-game {
  padding: 1.5rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  justify-content: flex-start;
  gap: 1rem;
}

.role-banner {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}

.role-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent);
  background: #1e1245;
  border: 1px solid #4c1d95;
  border-radius: 20px;
  padding: 3px 10px;
}

.role-desc { font-size: 13px; color: var(--muted); }

/* Target word display (when human describes) */
.target-word-box {
  width: 100%;
  background: #1e1245;
  border: 1px solid var(--purple-lt);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.target-word-label {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 6px;
}

.target-word {
  font-size: clamp(28px, 5vw, 42px);
  color: var(--text);
  letter-spacing: 4px;
  font-weight: 500;
}

/* Panels */
.game-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

@media (max-width: 580px) {
  .game-panels { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-lt);
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--dim);
  display: flex; align-items: center; justify-content: space-between;
}

.panel-count {
  background: var(--surface2);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--dimmer);
}

.panel-list {
  flex: 1;
  min-height: 140px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-list::-webkit-scrollbar { width: 4px; }
.panel-list::-webkit-scrollbar-track { background: transparent; }
.panel-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.clue-item, .guess-item {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clue-item {
  background: var(--surface2);
  color: var(--text);
}

.clue-num {
  font-size: 10px; color: var(--dim);
  min-width: 16px; text-align: right;
}

.guess-item { background: var(--surface2); color: var(--muted); }
.guess-item.correct { background: #064e3b; color: var(--green); }
.guess-item.wrong   { background: #1f1215; color: var(--red); text-decoration: line-through; }

.empty-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--dimmer); min-height: 140px;
}

/* Input area */
.input-area {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-label {
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--dim);
}

.input-row {
  display: flex; gap: 0.5rem;
}

.kana-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.kana-input:focus { border-color: var(--purple-lt); }
.kana-input::placeholder { color: var(--dimmer); font-size: 13px; }
.kana-input.error { border-color: var(--red); animation: shake 0.3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.input-hint {
  font-size: 11px;
  color: var(--dim);
}

.input-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
}

/* AI thinking indicator */
.ai-thinking {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 13px; color: var(--muted);
}

.dots {
  display: flex; gap: 3px;
}
.dots span {
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Round end screen ── */
.round-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.result-icon { font-size: 40px; margin-bottom: 0.75rem; }

.result-word {
  font-size: 28px; letter-spacing: 3px;
  color: var(--text); margin-bottom: 0.25rem;
}

.result-label {
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 1.5rem;
}

.result-points {
  font-size: 48px; font-weight: 600;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.result-points-label {
  font-size: 12px; color: var(--dim); letter-spacing: 1px;
  margin-bottom: 1.5rem;
}

.result-breakdown {
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}

.score-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.sc-side { text-align: center; }
.sc-name { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.sc-val  { font-size: 22px; font-weight: 600; }
.sc-you  { color: var(--accent); }
.sc-ai   { color: var(--muted); }
.sc-vs   { font-size: 12px; color: var(--dimmer); }

/* ── Session end screen ── */
.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.session-title {
  font-size: 13px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 1rem;
}

.session-verdict {
  font-size: clamp(22px, 4vw, 32px); font-weight: 500;
  color: var(--text); margin-bottom: 0.5rem;
}

.session-sub { font-size: 13px; color: var(--muted); margin-bottom: 1.75rem; }

.final-scores {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.75rem;
}

.fs-side { text-align: center; }
.fs-name { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.fs-score { font-size: 40px; font-weight: 600; }
.fs-you { color: var(--accent); }
.fs-ai  { color: var(--muted); }
.fs-vs  { font-size: 14px; color: var(--dimmer); }

.round-log {
  background: var(--surface2);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1.75rem;
  text-align: left;
}

.round-log-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 0.5rem;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-lt);
  align-items: center;
}
.round-log-row:last-child { border-bottom: none; }
.round-log-row .rr-num  { color: var(--dim); }
.round-log-row .rr-word { color: var(--text); }
.round-log-row .rr-who  { color: var(--dim); font-size: 10px; letter-spacing: 1px; }
.round-log-row .rr-pts  { font-weight: 600; text-align: right; min-width: 28px; }
.rr-pts.you { color: var(--accent); }
.rr-pts.ai  { color: var(--muted); }

/* ── Utilities ── */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

/* ── Correct flash overlay ── */
.correct-flash {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(52, 211, 153, 0.08);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.correct-flash.show { opacity: 1; }
