:root {
  --bg: #0c0c0c;
  --fg: #f2f2f2;
  --muted: #9a9a9a;
  --accent: #f2f2f2;
  --border: #1a1a1a;
  --pill: #151515;
  --danger: #ff6060;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

.app-header, .app-footer {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}
.app-footer { border-top: 1px solid var(--border); border-bottom: none; justify-content: center; }
.brand { font-weight: 600; letter-spacing: 4px; }
.brand.small { letter-spacing: 3px; font-size: 14px; }
.meta { display: flex; gap: 12px; align-items: center; font-size: 12px; }
#resetCountdown { display: inline-block; width: 60px; text-align: left; }
.muted { color: var(--muted); }
.bull { color: var(--border); }

/* Streak indicator with public PNG flame backdrop */
.streak-indicator {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-image: url('/streakflame.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
}
.streak-number {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 10px;
  color: #0c0c0c;
  position: relative;
  z-index: 1;
  top: 4px;
  text-shadow: 0 0 1px rgba(255,255,255,0.3);
}

/* Streak tooltip */
.streak-indicator::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  right: 0;
  transform: translateX(0);
  background: #1a1a1a;
  color: var(--fg);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
  border: 1px solid var(--border);
  margin-top: 4px;
}

.streak-indicator:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Help button */
.help-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 8px;
}
.help-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
  background: rgba(255,255,255,0.05);
}
.help-btn.past-guesses {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  padding: 0;
  margin-right: 0;
  transition: all 0.2s ease;
}
.help-btn.past-guesses:hover {
  color: var(--fg);
  border-color: var(--fg);
  background: rgba(255,255,255,0.05);
}

.container { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }
.game-panel { display: flex; flex-direction: column; gap: 16px; }

.status-row { display: flex; gap: 8px; }
.status-pill { background: var(--pill); padding: 6px 10px; border-radius: 999px; color: var(--muted); font-size: 12px; }

.quote-board { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; position: relative; }
.quote-reveal { font-size: 20px; font-weight: 600; margin: 20px 0; text-align: center; line-height: 1.4; }
.speaker-reveal { font-size: 16px; color: var(--muted); text-align: center; margin-bottom: 24px; }
.word { display: inline-flex; gap: 6px; align-items: center; }
.letters { display: inline-flex; gap: 4px; }
.blank, .filled, .correct, .wrong { width: 24px; height: 32px; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; }
.blank { background: #1a1a1a; color: var(--muted); cursor: text; border-color: #333; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.blank:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: #222; }
.filled { background: #121212; color: var(--fg); }
.correct { background: #2d5a2d; color: var(--fg); }
.wrong { background: #3a2d2d; color: #999; }
.punct { padding: 0 2px; color: var(--muted); }


.input-panel { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.instructions { margin-bottom: 8px; }
.instructions p { margin: 0; font-size: 12px; }
.speaker-input-section { margin-top: 16px; }
.input-label { font-size: 12px; color: var(--muted); }
.text-input {
  width: 100%;
  background: #0f0f0f;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.text-input::placeholder { color: #6b6b6b; }

.actions { display: flex; gap: 12px; align-items: center; justify-content: center; }
.tries-text { color: var(--muted); font-size: 14px; }
.btn {
  background: #121212;
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

/* Hide guess button initially until game is ready */
#guessBtn {
  opacity: 0;
  transition: opacity 0.3s ease;
}

#guessBtn.ready {
  opacity: 1;
}
.btn.primary { background: var(--fg); color: #000; border-color: var(--fg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Subtle share button on final quote screen */
.btn.subtle-share {
  background: var(--bg);
  color: #cfcfcf;
  border: 1px solid #2a2a2a; /* thin outline */
  opacity: 0.85; /* subtle */
}
.btn.subtle-share:hover {
  opacity: 1;
  border-color: #3a3a3a;
}

.hint-group { position: relative; }
.hint-menu {
  position: absolute; top: 110%; left: 0; background: #0f0f0f; border: 1px solid var(--border);
  border-radius: 8px; display: none; flex-direction: column; min-width: 180px; z-index: 10;
}
.hint-menu.open { display: flex; }
.hint-item { padding: 8px 10px; background: transparent; color: var(--fg); border: none; text-align: left; cursor: pointer; }
.hint-item:hover { background: #151515; }

.hint-reveals { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-pill { background: #101010; border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font-size: 12px; color: var(--muted); }

.message { min-height: 20px; color: var(--muted); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { width: min(480px, calc(100% - 32px)); background: #0f0f0f; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 24px; text-align: center; }
.modal-title { margin: 0 0 16px 0; font-size: 20px; font-weight: 600; border: none; }
.icon-btn { background: transparent; color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px; }

.distribution { display: flex; flex-direction: column; gap: 12px; margin: 24px 0; }
.dist-row { display: grid; grid-template-columns: 60px 1fr 50px; gap: 12px; align-items: center; font-size: 14px; color: var(--muted); }
.bar { background: #121212; border: 1px solid var(--border); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--fg); width: 0%; }
.bar-fill.highlight { background: #2d5a2d; }
.pct { text-align: right; font-weight: 600; }

.modal-actions { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 24px; }

.script-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease-out;
  z-index: 10;
}

.script-overlay.visible {
  opacity: 1;
  transform: translateY(0);
}

.script-quote {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--fg);
  text-align: center;
  line-height: 1.4;
  margin-bottom: 16px;
  font-style: italic;
}

.script-speaker {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: var(--muted);
  text-align: center;
  font-weight: 400;
}

.result-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.92), rgba(0,0,0,0.96));
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  padding-top: 80px; /* Make room for header */
  z-index: 10;
}
.result-screen.show { display: flex; }

/* Hints section */
.hints-section {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 30px;
  padding: 8px 0;
  align-items: center;
}
.hint-pill {
  background: #0f0f0f;
  border: 1px solid #242424;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  color: #c8c8c8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hint-pill strong {
  color: #eaeaea;
}

/* Past guesses section */
.past-guesses-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.past-guesses-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.past-guesses-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toggle-past-guesses {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.toggle-past-guesses:hover {
  color: var(--fg);
}
.toggle-past-guesses #toggleIcon {
  font-size: 10px;
  transition: transform 0.25s ease;
  opacity: 0.6;
}
.toggle-past-guesses.open #toggleIcon {
  transform: rotate(-180deg);
}
.how-to-play-section {
  display: flex;
  align-items: center;
  gap: 6px;
}
.how-to-play-text {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}
.how-to-play-text:hover {
  color: var(--fg);
}
.past-guesses-list {
  display: none;
  margin-top: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}
.past-guesses-list.open {
  display: block;
}

/* Quote reference display - match main board exactly */
.quote-reference {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  font-size: 20px;
  line-height: 1.2;
}
.reference-word {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.reference-letter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.reference-letter {
  width: 24px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.2s ease;
  /* Match main board exactly */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
.reference-letter.correct {
  background: #2d5a2d;
  color: var(--fg);
  border-color: #4a9a4a;
}
.reference-letter.empty {
  background: #1a1a1a;
  color: #ff6b6b;
  border-color: #333;
  position: relative;
}
.wrong-letter-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  background: transparent;
  color: #ff6b6b;
  border: none;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10;
  box-shadow: none;
}
.reference-punctuation {
  color: var(--muted);
  font-size: 20px;
  padding: 0 2px;
  height: 32px;
  display: inline-flex;
  align-items: center;
}

/* Help modal styles */
.help-content {
  text-align: left;
}
.help-content p {
  margin: 8px 0;
  line-height: 1.4;
  font-size: 14px;
}
.help-content p:first-child {
  margin-top: 0;
}
.help-content p:last-child {
  margin-bottom: 0;
}

.result-quote-top {
  max-width: 720px;
  width: 100%;
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--fg);
  opacity: 0.9;
  margin-bottom: 16px;
  font-style: italic;
  line-height: 1.4;
}

@media (max-width: 560px) {
  .quote-board { gap: 6px 8px; }
  .blank, .filled { width: 22px; height: 30px; }
  .modal-title { font-size: 18px; white-space: nowrap; }
  .meta { justify-content: center; }
}


