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

:root {
  --bg: #111009;
  --bg2: #181610;
  --surface: #1C1A13;
  --surface2: #242218;
  --border: #2E2B1E;
  --accent: #FF5500;
  --accent-hover: #FF6B1A;
  --accent-glow: rgba(255, 85, 0, 0.2);
  --accent-light: rgba(255, 85, 0, 0.1);
  --success: #3CBF82;
  --success-light: rgba(60, 191, 130, 0.1);
  --success-border: rgba(60, 191, 130, 0.25);
  --gold: #E8A020;
  --gold-light: rgba(232, 160, 32, 0.1);
  --gold-border: rgba(232, 160, 32, 0.25);
  --text: #EAE7DF;
  --text-dim: #B8B4AA;
  --muted: #625F54;
  --shadow: 0 2px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.7);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Outfit', sans-serif;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Subtle grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.022;
  mix-blend-mode: overlay;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 22px 40px;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.header-left { display: flex; flex-direction: column; gap: 2px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.logo {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1.2;
}

.logo span {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(255, 85, 0, 0.45);
}

.tagline {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.streak {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
  display: none;
}

.streak.active {
  display: block;
  color: var(--accent);
  border-color: rgba(255, 85, 0, 0.3);
  background: var(--accent-light);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  max-width: 400px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  font-size: 16px; color: var(--muted);
  cursor: pointer; padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 22px;
  color: var(--text);
}

.how-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 26px;
}

.how-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.step-num {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent-glow);
}

.step-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  padding-top: 3px;
}

/* ── SCREENS ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── PROGRESS PILLS ── */
.progress-pills {
  display: flex;
  gap: 7px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: all 0.2s;
}

.pill.done {
  background: var(--success-light);
  border-color: var(--success-border);
  color: var(--success);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.pill-word {
  font-style: italic;
  opacity: 0.9;
  font-size: 12px;
}

/* ── PROMPT CARD ── */
.prompt-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 26px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  min-height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.prompt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, #FF8040 100%);
  box-shadow: 0 0 14px var(--accent-glow);
}

.prompt-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(255, 85, 0, 0.055) 0%, transparent 55%);
  pointer-events: none;
}

.prompt-number {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.prompt-text {
  font-size: clamp(20px, 4.8vw, 27px);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

/* ── INPUT ── */
.input-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 13px;
}

#word-input {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  padding: 13px 17px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-transform: lowercase;
  font-family: var(--font);
}

#word-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 18px var(--accent-glow);
}

#word-input.error {
  border-color: #FF3B30;
  animation: shake 0.3s;
}

#word-input::placeholder { color: var(--muted); font-weight: 400; font-size: 16px; }

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

#submit-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  padding: 13px 22px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-width: 96px;
  font-family: var(--font);
  letter-spacing: 0.5px;
  box-shadow: 0 0 18px var(--accent-glow);
}

#submit-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 28px rgba(255, 85, 0, 0.38);
  transform: translateY(-1px);
}
#submit-btn:active { transform: scale(0.97) translateY(0); }
#submit-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; transform: none; }

.submit-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.meta-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  box-shadow: 0 0 6px rgba(60, 191, 130, 0.5);
}

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.meta-sep { color: var(--border); }

/* ── WAITING SCREEN ── */
.waiting-header {
  text-align: center;
  padding: 32px 0 24px;
}

.waiting-icon {
  width: 54px; height: 54px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 22px rgba(60, 191, 130, 0.35);
}

.waiting-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.waiting-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.countdown-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.countdown-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.countdown-timer {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px var(--accent-glow);
}

.waiting-summary {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 22px;
}

.waiting-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.waiting-row-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  width: 16px;
  flex-shrink: 0;
}

.waiting-row-prompt {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  line-height: 1.3;
}

.waiting-row-word {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
}

.waiting-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.total-players {
  font-size: 12px;
  color: var(--muted);
}

.total-players span {
  font-weight: 700;
  color: var(--text-dim);
}

/* ── REVEAL SCREEN ── */
.reveal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.reveal-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.reveal-score strong { color: var(--accent); font-weight: 800; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  border: 1.5px solid var(--success-border);
  border-radius: 10px;
  padding: 2px 7px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 4px;
}

.live-badge::before {
  content: '';
  width: 5px; height: 5px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
  box-shadow: 0 0 4px rgba(60, 191, 130, 0.6);
}

.share-btn-small {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid rgba(255, 85, 0, 0.35);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 15px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.share-btn-small:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ── REVEAL TABS ── */
.reveal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.reveal-tabs::-webkit-scrollbar { display: none; }

.reveal-tab {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  min-width: 58px;
  justify-content: center;
  font-family: var(--font);
}

.tab-emoji { font-size: 14px; line-height: 1; }
.tab-num { font-size: 13px; font-weight: 700; }

.reveal-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.reveal-tab.hit { border-color: var(--success-border); color: var(--success); }
.reveal-tab.hit.active { background: var(--success); border-color: var(--success); color: #fff; box-shadow: 0 0 12px rgba(60, 191, 130, 0.3); }
.reveal-tab.top-hit { border-color: var(--gold-border); color: var(--gold); }
.reveal-tab.top-hit.active { background: var(--gold); border-color: var(--gold); color: #111; box-shadow: 0 0 12px rgba(232, 160, 32, 0.3); }

.reveal-panel { display: none; }
.reveal-panel.active { display: block; animation: fadeUp 0.2s ease; }

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

.reveal-prompt-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.reveal-prompt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border);
}

.reveal-prompt-card.hit::before { background: var(--success); }
.reveal-prompt-card.top-hit::before { background: var(--gold); }

/* ── BOARD ── */
.board {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.board-row.visible { opacity: 1; transform: translateY(0); }

.rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.rank.top { color: var(--gold); }

.bar-container {
  flex: 1;
  background: var(--surface2);
  border-radius: 8px;
  height: 42px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  background: var(--surface2);
  width: 0%;
  transition: width 0.55s cubic-bezier(0.25, 1, 0.5, 1);
}

.bar-fill.is-yours { background: rgba(255, 85, 0, 0.2); }
.bar-fill.is-top { background: rgba(232, 160, 32, 0.18); }

.bar-label {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
  z-index: 1;
}

.bar-badge {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  pointer-events: none;
  letter-spacing: 0.3px;
}

.bar-badge.you { background: var(--accent); color: #fff; }
.bar-badge.top { background: var(--gold); color: #111; }

.bar-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* ── YOUR RESULT ── */
.your-result {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 17px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

.your-result.hit {
  background: var(--success-light);
  border-color: var(--success-border);
  color: var(--text-dim);
}

.your-result.top-hit {
  background: var(--gold-light);
  border-color: var(--gold-border);
  color: var(--text-dim);
}

.your-result strong { color: var(--accent); }
.your-result.hit strong { color: var(--success); }
.your-result.top-hit strong { color: var(--gold); }

/* ── BUTTONS ── */
.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  padding: 15px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  letter-spacing: 0.3px;
  box-shadow: 0 0 18px var(--accent-glow);
}

.primary-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 30px rgba(255, 85, 0, 0.38);
  transform: translateY(-1px);
}
.primary-btn:active { transform: scale(0.98) translateY(0); }

.secondary-btn {
  width: 100%;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: var(--font);
}

.secondary-btn:hover { border-color: var(--text); color: var(--text); }

/* ── HISTORY ── */
.history-section {
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.history-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.history-day-date {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-day-date::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.history-rows { display: flex; flex-direction: column; }

.history-row {
  display: flex;
  flex-direction: column;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.history-row:last-child { border-bottom: none; }

.history-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.history-prompt-text {
  font-size: 13px;
  color: var(--text-dim);
  flex: 1;
  line-height: 1.4;
  font-weight: 500;
}

.history-top-word {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.expand-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.expand-btn:hover { border-color: var(--accent); color: var(--accent); }

.history-word-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-word-list[hidden] { display: none; }

.hist-word-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.hist-rank {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.hist-word {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  width: 90px;
  flex-shrink: 0;
}

.hist-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.hist-bar {
  height: 100%;
  background: var(--border);
  border-radius: 3px;
  display: block;
}

.hist-word-row:first-child .hist-word { color: var(--accent); }
.hist-word-row:first-child .hist-bar { background: rgba(255, 85, 0, 0.5); }

.hist-count {
  font-size: 11px;
  color: var(--muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 500;
}

/* ── FOOTER ── */
.site-footer {
  margin-top: 48px;
  padding: 22px 0 0;
  border-top: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex-wrap: wrap;
}

.footer-logo {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dim);
}

.footer-logo span { color: var(--accent); }

.footer-sep { color: var(--border); }

.footer-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── HINT ── */
.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 400px) {
  .prompt-text { font-size: 19px; }
  #word-input { font-size: 18px; }
  .prompt-card { padding: 22px 18px 20px; }
}
