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

:root {
  --bg:        #f9f9f7;
  --surface:   #ffffff;
  --surface2:  #f2f1ee;
  --border:    rgba(0,0,0,0.1);
  --border2:   rgba(0,0,0,0.18);
  --text:      #1a1a18;
  --text2:     #6b6b68;
  --text3:     #9a9a96;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --green:   #1D9E75;
  --teal:    #5DCAA5;
  --amber:   #EF9F27;
  --salmon:  #F09595;
  --red:     #E24B4A;
  --purple:  #7F77DD;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #141413;
    --surface: #1e1e1c;
    --surface2:#2a2a28;
    --border:  rgba(255,255,255,0.09);
    --border2: rgba(255,255,255,0.16);
    --text:    #f0efe9;
    --text2:   #9a9a96;
    --text3:   #6b6b68;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ── Loading ── */
#loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-inner { text-align: center; width: 300px; }
.logo { font-size: 26px; font-weight: 600; margin-bottom: 2rem; color: var(--text); }
.loading-bar-wrap { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin-bottom: 1rem; }
.loading-bar { height: 100%; background: var(--purple); border-radius: 2px; width: 0%; transition: width 0.4s; }
.loading-msg { font-size: 13px; color: var(--text2); }

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.title { font-size: 16px; font-weight: 600; }
.subtitle { font-size: 13px; color: var(--text2); }
.scores { display: flex; gap: 10px; }
.sc { background: var(--surface2); border-radius: var(--radius-sm); padding: 6px 14px; text-align: center; min-width: 56px; }
.sc-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.sc-val { font-size: 18px; font-weight: 600; }

/* ── Progress ── */
.progress-bar { display: flex; gap: 3px; padding: 0 1.5rem; margin: 0.75rem 0; }
.pip { flex: 1; height: 4px; border-radius: 2px; background: var(--surface2); }
.pip.current { background: var(--purple); }
.pip.done-ok  { background: var(--green); }
.pip.done-miss{ background: var(--red); }

/* ── Debug banner ── */
.debug-banner {
  margin: 0 1.5rem 0.75rem;
  padding: 8px 12px;
  background: #fff8e6;
  border: 0.5px solid #f5c842;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: #7a5c00;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  .debug-banner { background: #2a2200; border-color: #7a5c00; color: #f5c842; }
}
.debug-tag {
  font-size: 10px;
  font-weight: 700;
  background: #f5c842;
  color: #3a2d00;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  margin-top: 1px;
}

/* ── Main layout ── */
main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 700px) {
  main { grid-template-columns: 1fr; }
}

/* ── Image panel ── */
.image-panel {}
#game-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: var(--surface2);
  display: block;
  margin-bottom: 0.75rem;
}
.hint-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 11px;
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  color: var(--text2);
}

/* ── Guess panel ── */
.guess-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.section-label { font-size: 11px; color: var(--text3); }

/* ── Prompt word area ── */
.prompt-area {
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  line-height: 2.4;
  min-height: 80px;
  font-size: 15px;
  word-break: break-word;
}
.w {
  display: inline-block;
  position: relative;
  cursor: default;
  border-radius: 4px;
  margin: 1px 2px;
  vertical-align: middle;
}
.w .tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--text);
  z-index: 10;
  pointer-events: none;
}
.w:hover .tip { display: block; }
.skel {
  display: inline-block;
  border-radius: 3px;
  height: 1.1em;
  vertical-align: middle;
}

/* ── Attempt dots ── */
.attempt-row { display: flex; gap: 8px; align-items: center; }
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface2);
  border: 0.5px solid var(--border2);
  transition: background 0.3s;
}
.dot.good { background: var(--green); border-color: var(--green); }
.dot.ok   { background: var(--amber); border-color: var(--amber); }
.dot.miss { background: var(--red);   border-color: var(--red); }

/* ── History ── */
.history { display: flex; flex-direction: column; gap: 0; }
.hist-row {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 0.5px solid var(--border);
}
.hist-row:last-child { border-bottom: none; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }

/* ── Similarity bar ── */
.bar-wrap { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.bar { height: 100%; border-radius: 3px; transition: width 0.5s, background 0.5s; width: 0%; }

/* ── Input area ── */
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input-row input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(127,119,221,0.15); }
.input-row input:disabled { opacity: 0.5; }
button {
  padding: 8px 18px;
  font-size: 14px;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
button:hover { background: var(--surface2); }
button:disabled { opacity: 0.4; cursor: default; }
.char-counter { font-size: 11px; color: var(--text3); text-align: right; margin-top: 3px; }
.char-counter.warn  { color: var(--amber); }
.char-counter.error { color: var(--red); }

/* ── Reveal row ── */
.reveal-row { text-align: center; padding-top: 0.25rem; }
.btn-ghost {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--text3);
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-ghost:hover { color: var(--text2); background: none; }

/* ── Round result ── */
.round-result { text-align: center; padding: 0.5rem 0; }
.result-pts { font-size: 38px; font-weight: 700; }
.result-label { font-size: 13px; color: var(--text2); margin: 4px 0 1rem; }

/* ── End screen ── */
#end-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.end-inner { text-align: center; }
.end-title { font-size: 16px; color: var(--text2); margin-bottom: 0.5rem; }
.end-score { font-size: 64px; font-weight: 700; margin-bottom: 0.25rem; }
.end-sub { font-size: 14px; color: var(--text2); margin-bottom: 1.5rem; }
