/* ============ wordl.buzz — minimal-modern, amber accent ============ */
:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --border: #2a2a2e;
  --border-soft: #232327;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #f5b301;       /* honey / buzz gold */
  --accent-soft: #fbbf24;
  --accent-ink: #1a1500;
  --correct: #22c55e;
  --present: #f5b301;
  --absent: #36363b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-lg: 18px;
  --tile-size: clamp(46px, 11vw, 60px);
  --maxw: 720px;
}

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

/* The `hidden` attribute must always win, even over display rules like
 * `.ghost-btn { display: inline-flex }` (same specificity would otherwise let
 * the class override it, keeping "hidden" elements like the install button visible). */
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  letter-spacing: -0.011em;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Glow removed: subtle radial gradients band visibly on the near-black
 * background (8-bit color stepping shows as a faint horizontal line). */
#bg-glow { display: none; }

::selection { background: rgba(245, 179, 1, 0.3); }

/* ============ Screens ============ */
.screen { position: fixed; inset: 0; display: none; z-index: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ============ Start screen ============ */
#screen-start { align-items: center; justify-content: center; padding: 28px 24px; }
.start-inner { max-width: var(--maxw); width: 100%; text-align: center; }

.logo { display: inline-flex; align-items: baseline; margin-bottom: 18px; }
.logo h1 {
  font-size: clamp(2.6rem, 9vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.logo h1 em { font-style: normal; color: var(--accent); }

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 400;
  max-width: 30ch;
  margin: 0 auto 44px;
  line-height: 1.5;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.mode-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px 16px 22px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.mode-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-3px);
}
.mode-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.mode-card.featured { border-color: var(--border); }

.mode-badge {
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
}
.mode-len {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}
.mode-card:hover .mode-len { color: var(--accent); }
.mode-name { font-size: 1.05rem; font-weight: 600; }
.mode-desc { font-size: 0.8rem; color: var(--faint); font-weight: 400; }

.start-footer { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ Buttons ============ */
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); background: var(--surface); }
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost-btn svg { width: 17px; height: 17px; }

.primary-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 14px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.1s ease;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 20px; height: 20px; }

.hint-btn { width: auto; padding: 0 14px; color: var(--accent); }
.hint-btn .hint-cost { font-size: 0.8rem; font-weight: 800; }
.hint-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.hint-btn:disabled:hover { color: var(--accent); border-color: var(--border-soft); }

/* ============ HUD ============ */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  gap: 10px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.hud-stats {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 8px;
}
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 0 6px; }
.hud-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.hud-value { font-size: 1.1rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
.hud-value.hearts { display: flex; gap: 3px; align-items: center; }
.hearts svg { width: 15px; height: 15px; }
.heart-full { color: var(--danger); fill: var(--danger); }
.heart-empty { color: var(--absent); fill: none; }

@keyframes scorePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); color: var(--accent); }
  100% { transform: scale(1); }
}
.hud-value.pop { animation: scorePop 0.5s ease; }

/* ============ Board ============ */
.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}
#board { display: grid; gap: 8px; }
.board-row { display: grid; grid-auto-flow: column; gap: 8px; }

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: grid;
  place-items: center;
  font-size: calc(var(--tile-size) * 0.44);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  border-radius: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.3s ease, color 0.3s ease;
}
.tile.filled { border-color: var(--accent); transform: scale(1.03); }
.tile.hinted { border-color: var(--accent); color: var(--accent); border-style: dashed; }

.tile.reveal { animation: flipIn 0.5s ease both; }
@keyframes flipIn {
  0% { transform: rotateX(0); }
  45% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #04210f;
}
.tile.present {
  background: var(--present);
  border-color: var(--present);
  color: var(--accent-ink);
}
.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: var(--muted);
}

.board-row.shake { animation: shake 0.45s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.board-row.win .tile { animation: bounce 0.55s ease both; }
.board-row.win .tile:nth-child(2) { animation-delay: 0.06s; }
.board-row.win .tile:nth-child(3) { animation-delay: 0.12s; }
.board-row.win .tile:nth-child(4) { animation-delay: 0.18s; }
.board-row.win .tile:nth-child(5) { animation-delay: 0.24s; }
.board-row.win .tile:nth-child(6) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-14px); }
}

/* ============ Toast ============ */
#toast {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  padding: 11px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Keyboard ============ */
.kb-wrap { padding: 8px 6px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#keyboard {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.kb-row { display: flex; gap: 6px; justify-content: center; }

.key {
  flex: 1;
  max-width: 46px;
  height: 54px;
  border: none;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
  display: grid;
  place-items: center;
}
.key:hover { background: var(--border); }
.key:active { transform: translateY(1px); }
.key.wide { max-width: 72px; flex: 1.6; font-size: 0.7rem; letter-spacing: 0.04em; }
.key svg { width: 22px; height: 22px; }

.key.correct { background: var(--correct); color: #04210f; }
.key.present { background: var(--present); color: var(--accent-ink); }
.key.absent { background: #1a1a1d; color: var(--faint); }

/* ============ Overlays ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 7, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: cardIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.overlay-card.wide { max-width: 460px; text-align: left; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.overlay-card h2 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.03em; }

.result-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.14);
  color: var(--correct);
}
.result-icon.fail { background: rgba(239, 68, 68, 0.14); color: var(--danger); }
.result-icon svg { width: 32px; height: 32px; }

.result-word { color: var(--muted); font-size: 0.98rem; }
.result-word strong { color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }

.result-points {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  min-height: 1.4em;
}

.final-stats { display: flex; gap: 10px; }
.final-stats div {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.final-stats span { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; }
.final-stats label { font-size: 0.64rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }

.how-list { list-style: none; display: flex; flex-direction: column; gap: 15px; color: var(--muted); font-size: 0.94rem; line-height: 1.45; }
.how-list strong { color: var(--text); font-weight: 600; }
.how-tiles { display: flex; gap: 5px; margin-bottom: 7px; }
.demo-tile {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  font-weight: 700;
  color: var(--text);
}
.demo-tile.correct { background: var(--correct); border-color: var(--correct); color: #04210f; }
.demo-tile.present { background: var(--present); border-color: var(--present); color: var(--accent-ink); }

/* ============ Continue run / round options ============ */
.continue-wrap { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; }
.continue-wrap[hidden] { display: none; }
.continue-or {
  font-size: 0.8rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  text-align: center;
  margin: 4px 0;
}

.hud-left { display: flex; gap: 8px; }

.options-menu { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.options-menu .primary-btn,
.options-menu .ghost-btn { width: 100%; justify-content: center; }
.options-menu .ghost-btn { margin-top: 10px; }
.option-note { font-size: 0.78rem; color: var(--faint); margin: 2px 2px 6px; }

.install-steps {
  text-align: left;
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}
.install-steps strong { color: var(--text); font-weight: 600; }

.ghost-btn.danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }
.ghost-btn.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* ============ Cookie consent banner ============ */
.consent-banner {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  width: min(640px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  animation: consentIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes consentIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%); }
}
.consent-banner[hidden] { display: none; }
.consent-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
}
.consent-text {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}
.consent-text a { color: var(--accent); text-decoration: none; font-weight: 600; }
.consent-text a:hover { text-decoration: underline; }
.consent-actions { display: flex; gap: 10px; flex-shrink: 0; }
.consent-actions .ghost-btn { padding: 10px 16px; }
.primary-btn.consent-accept { display: inline-block; width: auto; padding: 10px 22px; }

/* ============ Legal pages (privacy) ============ */
.legal-line { margin-top: 26px; }
.legal-line a {
  color: var(--faint);
  font-size: 0.78rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.legal-line a:hover { color: var(--muted); text-decoration: underline; }
.app-version {
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  margin-left: 8px;
}

/* ============ Update / refresh toast ============ */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(420px, calc(100vw - 28px));
  padding: 14px 14px 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  color: var(--text);
  animation: consentIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.update-toast span {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}
.update-toast button {
  flex-shrink: 0;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: 11px;
  cursor: pointer;
}
.update-toast button:disabled { opacity: 0.6; cursor: default; }

#btn-install-dismiss { margin-top: 10px; width: 100%; justify-content: center; font-size: 0.85rem; }

.legal-page {
  position: static;
  min-height: 100%;
  overflow-y: auto;
  display: block;
  user-select: text;
  -webkit-user-select: text;
}
.legal-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px max(40px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}
.legal-wrap h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; }
.legal-wrap h2 { font-size: 1.15rem; font-weight: 700; margin-top: 30px; letter-spacing: -0.02em; }
.legal-wrap p, .legal-wrap li { color: var(--muted); font-size: 0.96rem; line-height: 1.6; }
.legal-wrap p { margin-top: 12px; }
.legal-wrap ul { margin: 12px 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.legal-wrap a { color: var(--accent); text-decoration: none; }
.legal-wrap a:hover { text-decoration: underline; }
.legal-wrap strong { color: var(--text); font-weight: 600; }
.legal-updated { color: var(--faint); font-size: 0.82rem; margin-top: 8px; }
.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}
.legal-back:hover { color: var(--text); }
.legal-back svg { width: 17px; height: 17px; }

/* ============ Responsive ============ */
@media (max-width: 560px) {
  .consent-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .consent-actions { justify-content: flex-end; }
  .mode-cards { grid-template-columns: 1fr; gap: 11px; }
  .mode-card { flex-direction: row; justify-content: flex-start; padding: 16px 20px; gap: 16px; }
  .mode-len { font-size: 1.9rem; min-width: 38px; }
  .mode-card .mode-desc { margin-left: auto; text-align: right; }
  .mode-badge { left: auto; right: 16px; transform: none; }
  .hud-item { min-width: 52px; }
  :root { --tile-size: clamp(40px, 12.5vw, 56px); }
}

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