/* ============ smush — minimal-modern, violet accent ============ */
:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --border: #2a2a2e;
  --border-soft: #232327;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #7c5cff;        /* electric violet */
  --accent-soft: #9a80ff;
  --accent-ink: #ffffff;
  --correct: #22c55e;
  --present: #7c5cff;
  --absent: #36363b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-lg: 18px;
  --tile-size: 48px;
  --tile-gap: 6px;
  --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(124, 92, 255, 0.35); }

/* ============ 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; overflow-y: auto; }
.start-inner { max-width: 460px; width: 100%; text-align: center; }

.logo { display: inline-flex; align-items: baseline; margin-bottom: 16px; }
.logo h1 {
  font-size: clamp(2.8rem, 11vw, 4.2rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.example {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 11px 20px;
  margin-bottom: 30px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.example-blend { color: var(--accent-soft); }
.example-eq, .example-plus { color: var(--faint); font-weight: 600; }
.example-word { color: var(--text); }

.diff-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.diff-chip {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.diff-chip:hover { color: var(--text); border-color: var(--accent); }
.diff-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.diff-chip.active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.start-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }

.start-footer { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.install-dismiss {
  padding-left: 0;
  padding-right: 0;
  width: 40px;
  min-width: 40px;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}
.app-version-line { text-align: center; margin-top: 16px; }
.app-version {
  color: var(--faint, #8a8a8a);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

/* ============ 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: updateToastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes updateToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%); }
}
.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; }

/* ============ Buttons ============ */
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: 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; }
.ghost-btn.block { width: 100%; border-radius: var(--radius); }

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  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.1); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.primary-btn svg { width: 18px; height: 18px; }

.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-soft); }
.hint-btn .hint-cost { font-size: 0.82rem; font-weight: 800; }
.hint-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.hint-btn:disabled:hover { color: var(--accent-soft); border-color: var(--border-soft); }

/* ============ HUD ============ */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  gap: 10px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.hud-title { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.hud-label { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.02em; }
.hud-sub { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }

/* ============ Prompt ============ */
.prompt {
  text-align: center;
  padding: 6px 16px 2px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.prompt-blend {
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-soft);
  line-height: 1.05;
}
.prompt-meta { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 8px; }
.prompt-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.prompt-cat {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.28);
  padding: 3px 10px;
  border-radius: 999px;
}
.prompt-diff {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.prompt-diff.diff-easy { color: var(--correct); background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.3); }
.prompt-diff.diff-medium { color: var(--accent-soft); background: rgba(124, 92, 255, 0.12); border-color: rgba(124, 92, 255, 0.3); }
.prompt-diff.diff-hard { color: #fca5a5; background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.32); }
.prompt-clue { color: var(--muted); font-size: 0.96rem; max-width: 34ch; line-height: 1.4; }

/* ============ Board ============ */
.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}
#board { display: flex; flex-direction: column; gap: 7px; }
.board-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.word-group { display: flex; gap: var(--tile-gap); }
.row-plus { color: var(--faint); font-weight: 800; font-size: calc(var(--tile-size) * 0.4); }

.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: 9px;
  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.active-slot { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2); }
.tile.hinted { border-color: var(--accent); color: var(--accent-soft); 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(n+2) { animation-delay: 0.05s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-13px); }
}

/* ============ Toast ============ */
#toast {
  position: fixed;
  left: 50%;
  top: 14%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.9rem;
  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;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 15px;
  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.5rem; font-weight: 800; letter-spacing: -0.03em; }
.overlay-card h3 { font-size: 0.95rem; font-weight: 700; }

.result-icon {
  width: 58px;
  height: 58px;
  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: 30px; height: 30px; }

.result-word { color: var(--muted); font-size: 0.96rem; }

.result-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-wrap: wrap;
}
.result-answer .ans-word { color: var(--text); }
.result-answer .ans-plus { color: var(--accent-soft); }

.result-grid {
  font-family: inherit;
  font-size: 1.35rem;
  line-height: 1.32;
  letter-spacing: 2px;
  margin: 0;
  white-space: pre;
}
.result-streak { font-size: 0.92rem; color: var(--muted); }
.result-streak strong { color: var(--accent-soft); }
.result-btns { display: flex; flex-direction: column; gap: 10px; }
.result-next { font-size: 0.82rem; color: var(--faint); }

/* ============ How to play ============ */
.how-list { list-style: none; display: flex; flex-direction: column; gap: 14px; color: var(--muted); font-size: 0.94rem; line-height: 1.45; }
.how-list strong { color: var(--text); font-weight: 600; }
.how-demo { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }
.demo-plus { color: var(--faint); font-weight: 800; margin: 0 3px; }
.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); }

/* ============ Stats ============ */
.final-stats { display: flex; gap: 6px; justify-content: center; }
.final-stats > div { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.final-stats span { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.final-stats label { font-size: 0.62rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.dist-title { color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; }
.dist-row .dist-n { width: 12px; color: var(--faint); font-weight: 700; }
.dist-row .dist-bar {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 5px;
  padding: 2px 8px;
  font-weight: 700;
  text-align: right;
  min-width: 26px;
  transition: width 0.4s ease;
}
.dist-row .dist-bar.empty { background: var(--surface-2); color: var(--faint); }
.dist-row .dist-bar.current { background: var(--correct); color: #04210f; }

/* ============ Creator form ============ */
.create-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.field input {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.2s ease;
}
.field input:focus { border-color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 560px) {
  .hud-label { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
