:root {
  --ink: #142B26;
  --surface: #1D3F37;
  --surface-2: #234A40;
  --paper: #F3EEE2;
  --paper-dim: #B9C7BE;
  --ember: #E4703A;
  --ember-dim: #7A3A22;
  --gold: #D9A94E;
  --rosewood: #B85C4E;
  --sage: #8FA89A;

  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --font-ui: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  flex-shrink: 0;
}

.brand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--paper);
  opacity: 0.9;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.stat-pill.streak { color: var(--gold); }
.stat-pill .flame { font-size: 14px; }

.offline-badge {
  font-size: 11px;
  color: var(--sage);
  border: 1px solid var(--sage);
  border-radius: 999px;
  padding: 2px 8px;
  opacity: 0.75;
  display: none;
}
.offline-badge.show { display: inline-block; }

/* ---------- Necklace (signature element) ---------- */
.necklace-wrap {
  flex-shrink: 0;
  padding: 6px 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.necklace-wrap::-webkit-scrollbar { display: none; }

.necklace {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  min-width: min-content;
  position: relative;
}

.bead {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--paper-dim);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
  animation: beadIn 0.35s ease-out;
}

.bead::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 50%;
  width: 14px;
  height: 1px;
  background: var(--sage);
  opacity: 0.4;
}

.bead:last-child::after { display: none; }

@keyframes beadIn {
  from { opacity: 0; transform: translateY(6px) scale(0.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Main stage ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  text-align: center;
  gap: 6px;
}

.next-letter-hint {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.current-word {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(38px, 12vw, 64px);
  line-height: 1.05;
  color: var(--paper);
  transition: color 0.25s ease, transform 0.25s ease;
  min-height: 1.2em;
  word-break: break-word;
}

.current-word.valid-flash { color: var(--ember); animation: pop 0.3s ease; }
.current-word.invalid-flash { color: var(--rosewood); animation: shake 0.35s ease; }

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

.feedback-line {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--sage);
  min-height: 1.4em;
}

.timer-ring {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--gold);
  min-height: 1.2em;
}

.definition-box {
  font-size: 13px;
  color: var(--paper-dim);
  max-width: 320px;
  min-height: 1.2em;
}

/* ---------- Input area ---------- */
.input-area {
  flex-shrink: 0;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}

.word-input {
  flex: 1;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--paper);
  outline: none;
}
.word-input:focus { border-color: var(--ember); }
.word-input::placeholder { color: var(--paper-dim); }

.submit-btn {
  background: var(--ember);
  color: var(--ink);
  border: none;
  border-radius: 14px;
  padding: 0 22px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.submit-btn:active { transform: scale(0.95); }
.submit-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Start / mode select screen ---------- */
.start-screen, .end-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px 24px;
  text-align: center;
}

.wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 42px;
  color: var(--paper);
}
.tagline {
  color: var(--sage);
  font-size: 14px;
  max-width: 280px;
  margin-top: -14px;
}

.mode-row {
  display: flex;
  gap: 12px;
}

.mode-btn {
  background: var(--surface);
  color: var(--paper);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 14px 20px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.mode-btn.selected { border-color: var(--ember); color: var(--ember); }

.play-btn {
  background: var(--ember);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 16px 42px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-ui);
}
.play-btn:active { transform: scale(0.96); }

.stats-row {
  display: flex;
  gap: 24px;
  font-family: var(--font-mono);
  color: var(--sage);
  font-size: 13px;
}
.stats-row b { color: var(--gold); font-size: 16px; display: block; }

.end-score {
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--gold);
}
.end-label { color: var(--sage); font-size: 14px; }

.share-card-img {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.4);
  border: 1px solid var(--surface-2);
}

.share-btn {
  background: var(--surface-2);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
}

.mode-btn.small {
  padding: 8px 16px;
  font-size: 13px;
}

.turn-indicator {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 1.2em;
}
.turn-indicator.thinking { color: var(--sage); }

.hint-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px 10px;
}
.lives-display {
  font-size: 15px;
  letter-spacing: 2px;
}
.hint-btn {
  background: none;
  border: 1px solid var(--sage);
  border-radius: 999px;
  color: var(--sage);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-ui);
  padding: 6px 14px;
}
.hint-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pause-btn {
  background: var(--surface);
  border: none;
  color: var(--paper);
  font-size: 15px;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 43, 38, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
}
.overlay-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 28px;
  color: var(--paper);
  text-align: center;
}

.friend-names-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.friend-name-input {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--paper);
  width: 120px;
  text-align: center;
  outline: none;
}
.friend-name-input:focus { border-color: var(--ember); }
.friend-name-input::placeholder { color: var(--paper-dim); }
.vs-text {
  color: var(--sage);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
}

.setup-label {
  color: var(--sage);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.back-link {
  background: none;
  border: none;
  color: var(--sage);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-ui);
  padding: 6px;
}

.manual-share-box {
  position: fixed;
  bottom: 90px;
  left: 18px;
  right: 18px;
  background: var(--surface);
  color: var(--paper);
  border: 2px solid var(--ember);
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  resize: none;
  height: 100px;
  z-index: 60;
}

.scoring-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.scoring-list li {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--paper);
}
.scoring-list b {
  color: var(--gold);
  font-family: var(--font-mono);
  margin-right: 6px;
}
.scoring-tip {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--sage);
  max-width: 260px;
  text-align: center;
}

.hidden { display: none !important; }
