/* ==========================================================================
   Unguessable - stylesheet
   Dark-first design; light theme via html[data-theme="light"].
   Colorblind tile palette via html[data-cb="1"].
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg0: #0b0e1a;
  --bg1: #131731;
  --bg2: #1b2040;
  --bg3: #232a52;
  --line: #2b3258;
  --line2: #3a4272;
  --ink: #edeffd;
  --ink2: #a9b0d6;
  --ink3: #7e86b3;

  --brand: #8b7cff;
  --brand-strong: #6e5bff;
  --on-brand: #ffffff;

  --tile-g: #2ba36c;
  --tile-y: #d59f2b;
  --tile-x: #3d4468;
  --tile-empty-border: #39406b;
  --tile-live: #4a538c;
  --on-tile: #ffffff;

  --ok: #34c98e;
  --warn: #ffb02e;
  --danger: #ff5470;
  --danger-strong: #e93a58;

  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-sm: 9px;

  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --z-rail: 10;
  --z-header: 100;
  --z-toast: 900;
  --z-modal: 1000;

  --glow-a: radial-gradient(1100px 500px at 85% -10%, rgba(139, 124, 255, 0.14), transparent 60%);
  --glow-b: radial-gradient(900px 420px at -10% 0%, rgba(255, 84, 112, 0.08), transparent 55%);

  color-scheme: dark;
}

/* Light theme - the classic warm-paper look (site default). */
html[data-theme="light"] {
  --bg0: #f7f5f0;
  --bg1: #ffffff;
  --bg2: #f1efe8;
  --bg3: #e8e5db;
  --line: #d8dbe2;
  --line2: #c3c8d6;
  --ink: #1f2937;
  --ink2: #4f5b6b;
  --ink3: #6b7280;

  --brand: #365d9d;
  --brand-strong: #2c4d85;

  --tile-g: #3b7f4a;
  --tile-y: #c99620;
  --tile-x: #737b86;
  --tile-empty-border: #d9dde4;
  --tile-live: #8793a4;

  --ok: #3b7f4a;
  --warn: #b3820f;
  --danger: #bb3e45;
  --danger-strong: #a33540;

  --shadow-1: 0 2px 8px rgba(31, 41, 55, 0.07);
  --shadow-2: 0 12px 35px rgba(31, 41, 55, 0.14);

  --glow-a: radial-gradient(circle at 10% 10%, rgba(54, 93, 157, 0.10), transparent 34%);
  --glow-b: radial-gradient(circle at 90% 12%, rgba(59, 127, 74, 0.10), transparent 30%);

  color-scheme: light;
}

/* Colorblind-friendly tile palette (orange = locked-in, blue = present). */
html[data-cb="1"] {
  --tile-g: #f5793a;
  --tile-y: #85c0f9;
}
html[data-cb="1"] .key.state-y,
html[data-cb="1"] .tile.y {
  color: #10243e;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}
/* The hidden attribute must always win, even over component classes that set
   their own display (.trap-banner, .btn, .ad-box, modals …). Without this the
   grid/flex display on those classes overrides the browser default and they
   show when they should be hidden. */
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--glow-a), var(--glow-b), var(--bg0);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  touch-action: manipulation;
}
a {
  color: var(--brand);
}
a:hover {
  color: var(--brand-strong);
}
button {
  font-family: inherit;
  cursor: pointer;
}
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: calc(var(--z-header) + 1);
  background: var(--brand);
  color: var(--on-brand);
  padding: 10px 14px;
  border-radius: 10px;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg0) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b7cff, #5a47e6);
  color: #fff;
  font-weight: 800;
  font-size: 1.18rem;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(90, 71, 230, 0.4);
  transform: rotate(-5deg);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.logo:hover .logo-mark {
  transform: rotate(4deg) scale(1.09);
}
.logo-word {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
  font-size: 1.34rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.logo-dont {
  color: var(--ink);
}
.logo-strike {
  position: relative;
  color: var(--danger);
}
.logo-strike::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -3px;
  top: 54%;
  height: 3px;
  border-radius: 2px;
  background: var(--danger);
  transform: rotate(-4deg);
  transform-origin: left center;
}
.logo:hover .logo-strike::after {
  animation: logo-strike 0.4s ease;
}
@keyframes logo-strike {
  from { transform: rotate(-4deg) scaleX(0); }
  to { transform: rotate(-4deg) scaleX(1); }
}
.logo-tag {
  display: none;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
@media (min-width: 760px) {
  .logo-tag {
    display: inline-flex;
  }
}
@media (max-width: 420px) {
  .logo {
    gap: 7px;
  }
  .logo-word {
    font-size: 1.14rem;
  }
  .logo-mark {
    width: 28px;
    height: 28px;
    font-size: 1.02rem;
  }
  .header-actions {
    gap: 3px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg1);
  color: var(--ink2);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover {
  background: var(--bg2);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.95);
}
.icon-btn svg {
  width: 21px;
  height: 21px;
}

/* ---------- Layout ---------- */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 16px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
}
@media (min-width: 1200px) {
  .page {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
}
.rail {
  display: none;
}
@media (min-width: 1200px) {
  .rail {
    display: block;
    position: sticky;
    top: 78px;
    z-index: var(--z-rail);
  }
}
.rail-card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.rail-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.rail-card p,
.rail-card li {
  color: var(--ink2);
  font-size: 0.9rem;
  margin: 0;
}
.rail-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.rail-card li + li {
  margin-top: 6px;
}

/* ---------- Game column ---------- */
.game-col {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}
.mode-switch button {
  border: 0;
  border-radius: 999px;
  padding: 10px 12px;
  min-height: 44px;
  background: transparent;
  color: var(--ink2);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.18s ease, color 0.18s ease;
}
.mode-switch button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hud-left {
  min-width: 0;
}
#modeInfo {
  font-weight: 800;
  font-size: 1.02rem;
}
#modeSub {
  color: var(--ink3);
  font-size: 0.82rem;
}
.hud-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.94rem;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.btn:hover {
  background: var(--bg2);
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn.primary {
  background: var(--brand);
  border-color: transparent;
  color: var(--on-brand);
}
.btn.primary:hover {
  background: var(--brand-strong);
}
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}
.btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, var(--bg1));
}
.btn svg {
  width: 17px;
  height: 17px;
}
.btn .count {
  background: color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 999px;
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  font-size: 0.78rem;
  padding: 0 6px;
}

/* Status line: guesses + safe-words danger meter */
.statusline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.guess-steps {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.guess-steps .step {
  width: 22px;
  height: 8px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--line);
}
.guess-steps .step.done {
  background: var(--brand);
  border-color: transparent;
}
.guess-label {
  color: var(--ink2);
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 8px;
}

.danger-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg1);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink2);
}
.danger-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.danger-pill b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.danger-pill[data-tier="caution"] .dot {
  background: var(--warn);
}
.danger-pill[data-tier="danger"] .dot {
  background: #ff7a45;
}
.danger-pill[data-tier="critical"] .dot {
  background: var(--danger);
}
.danger-pill[data-tier="critical"] {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}
.danger-pill[data-tier="critical"] b {
  color: var(--danger);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 84, 112, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(255, 84, 112, 0); }
}

/* ---------- Board ---------- */
.board-wrap {
  position: relative;
  margin: 0 auto 16px;
  width: min(100%, 350px);
}
.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
}
.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.row.shake {
  animation: shake 0.5s ease;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
  50% { transform: translateX(-3px); }
}
.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--tile-empty-border);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(1.35rem, 6vw, 1.9rem);
  font-weight: 800;
  text-transform: uppercase;
  user-select: none;
  transition: border-color 0.12s ease, background 0.15s ease;
}
.tile.filled {
  border-color: var(--tile-live);
  animation: pop 0.1s ease;
}
@keyframes pop {
  50% { transform: scale(1.08); }
}
.tile.g, .tile.y, .tile.x, .tile.fatal {
  border-color: transparent;
  color: var(--on-tile);
}
.tile.g { background: var(--tile-g); }
.tile.y { background: var(--tile-y); }
.tile.x { background: var(--tile-x); }
.tile.fatal {
  background: var(--danger-strong);
}
.tile.flip {
  animation: flip 0.5s ease both;
}
@keyframes flip {
  0% { transform: rotateX(0); }
  49% { transform: rotateX(90deg); }
  51% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
.tile.bounce {
  animation: bounce 0.6s ease;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-14px); }
  65% { transform: translateY(3px); }
}

/* ---------- Toast & trap banner ---------- */
.toast-region {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  background: var(--ink);
  color: var(--bg0);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 11px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  text-align: center;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
}
.trap-banner {
  border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, var(--bg1));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 14px;
  display: grid;
  gap: 10px;
}
.trap-banner h2 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 8px;
}
.trap-banner h2 svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.trap-banner p {
  margin: 0;
  color: var(--ink2);
  font-size: 0.92rem;
}
.trap-banner .trap-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Keyboard ---------- */
.keyboard {
  user-select: none;
  display: grid;
  gap: 7px;
  margin-bottom: 8px;
}
.key-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.key {
  flex: 1;
  max-width: 44px;
  height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--bg3);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  position: relative;
  transition: filter 0.12s ease, transform 0.06s ease;
}
.key:hover {
  filter: brightness(1.12);
}
.key:active {
  transform: scale(0.93);
}
.key.wide {
  max-width: 70px;
  flex: 1.6;
  font-size: 0.72rem;
}
.key svg {
  width: 22px;
  height: 22px;
}
.key.state-g { background: var(--tile-g); color: var(--on-tile); }
.key.state-y { background: var(--tile-y); color: var(--on-tile); }
.key.state-x {
  background: color-mix(in srgb, var(--bg3) 55%, var(--bg0));
  color: var(--ink3);
}
.key.state-x::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 50%;
  height: 2px;
  background: currentColor;
  opacity: 0.55;
  transform: rotate(-18deg);
  border-radius: 1px;
}

/* ---------- Ads ---------- */
.ad-box {
  margin: 22px auto;
  text-align: center;
}
.ad-box[hidden] {
  display: none;
}
.ad-label {
  display: block;
  color: var(--ink3);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ad-slot {
  display: block;
  min-height: 100px;
  border-radius: 10px;
  overflow: hidden;
}
.rail .ad-slot {
  min-height: 600px;
}

/* ---------- Content sections ---------- */
.content-section {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 26px;
}
.content-section h2 {
  margin: 0 0 12px;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
}
.content-section h3 {
  margin: 20px 0 8px;
  font-size: 1.02rem;
}
.content-section p,
.content-section li {
  color: var(--ink2);
  font-size: 0.95rem;
  line-height: 1.65;
}
.content-section p {
  margin: 0 0 12px;
}
.content-section ul,
.content-section ol {
  margin: 0 0 12px;
  padding-left: 22px;
}
.mini-legend {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.mini-legend .item {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink2);
  font-size: 0.92rem;
}
.mini-legend .swatch {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--on-tile);
  font-weight: 800;
  font-size: 0.85rem;
  flex: none;
}
.swatch.g { background: var(--tile-g); }
.swatch.y { background: var(--tile-y); }
.swatch.x { background: var(--tile-x); }

.faq-list {
  display: grid;
  gap: 4px;
}
.faq-list details {
  border-top: 1px solid var(--line);
  padding: 12px 4px;
}
.faq-list details:first-child {
  border-top: 0;
}
.faq-list summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  font-size: 0.97rem;
  list-style-position: outside;
}
.faq-list p {
  margin: 10px 0 0;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 26px 16px 40px;
  color: var(--ink3);
  font-size: 0.85rem;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.footer-links a,
.footer-links button {
  color: var(--ink2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  background: none;
  border: 0;
  padding: 0;
}
.footer-links a:hover,
.footer-links button:hover {
  color: var(--brand);
  text-decoration: underline;
}
.disclaimer {
  max-width: 860px;
  line-height: 1.55;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(5, 7, 16, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
}
.modal-overlay[hidden] {
  display: none;
}
.modal {
  width: min(100%, 520px);
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  background: var(--bg1);
  border: 1px solid var(--line2);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  padding: 22px;
  animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.22rem;
  letter-spacing: -0.01em;
}
.modal p {
  color: var(--ink2);
  font-size: 0.94rem;
}
.modal .lead {
  margin-top: 0;
}

/* Help modal example rows */
.example-row {
  display: flex;
  gap: 5px;
  margin: 10px 0 6px;
}
.example-row .tile {
  width: 44px;
  height: 44px;
  aspect-ratio: auto;
  font-size: 1.1rem;
  border-radius: 8px;
}
.example-caption {
  color: var(--ink2);
  font-size: 0.88rem;
  margin: 0 0 14px;
}
.rule-cards {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.rule-cards .rule {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.rule .rule-num {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
}
.rule p {
  margin: 2px 0 0;
  font-size: 0.9rem;
}
.rule b {
  color: var(--ink);
}

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
}
.setting-row:first-of-type {
  border-top: 0;
}
.setting-row .setting-label {
  min-width: 0;
}
.setting-row .setting-label b {
  display: block;
  font-size: 0.96rem;
}
.setting-row .setting-label span {
  color: var(--ink3);
  font-size: 0.82rem;
}
.seg {
  display: inline-flex;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink2);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: 8px;
}
.seg button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
}
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--bg3);
  transition: background 0.18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink2);
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch[aria-checked="true"] {
  background: var(--brand);
  border-color: transparent;
}
.switch[aria-checked="true"]::after {
  transform: translateX(22px);
  background: #fff;
}

/* Stats: KPI tiles + outcome distribution bars */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 6px 0 18px;
}
.kpi {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}
.kpi b {
  display: block;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.kpi span {
  color: var(--ink3);
  font-size: 0.72rem;
  font-weight: 600;
}
.dist {
  display: grid;
  gap: 7px;
  margin-bottom: 6px;
}
.dist-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}
.dist-row .dist-label {
  color: var(--ink2);
  font-weight: 600;
  text-align: right;
}
.dist-row .dist-track {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dist-row .dist-bar {
  height: 14px;
  border-radius: 4px;
  background: var(--brand);
  min-width: 2px;
  flex: none;
  transition: width 0.4s ease;
}
.dist-row.survived .dist-bar {
  background: var(--ok);
}
.dist-row .dist-count {
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.ach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.ach {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 10px 12px;
}
.ach .ach-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
}
.ach .ach-icon svg {
  width: 18px;
  height: 18px;
}
.ach b {
  display: block;
  font-size: 0.84rem;
}
.ach span {
  color: var(--ink3);
  font-size: 0.74rem;
  line-height: 1.35;
  display: block;
}
.ach.locked {
  opacity: 0.45;
}
.ach.locked .ach-icon {
  background: var(--bg3);
  color: var(--ink3);
}

/* Result modal */
.result-outcome {
  text-align: center;
  margin: 4px 0 14px;
}
.result-outcome .headline {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.result-outcome .headline.win {
  color: var(--ok);
}
.result-outcome .headline.lose {
  color: var(--danger);
}
.result-outcome p {
  margin: 0;
}
.secret-reveal {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 14px 0 6px;
}
.secret-reveal .tile {
  width: 46px;
  height: 46px;
  aspect-ratio: auto;
  font-size: 1.2rem;
}
.secret-link {
  text-align: center;
  font-size: 0.85rem;
  margin: 0 0 14px;
}
.result-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.result-facts .kpi b {
  font-size: 1.2rem;
}
.safe-list {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.safe-list p {
  margin: 0 0 8px;
  font-size: 0.86rem;
}
.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.word-chip {
  background: var(--bg3);
  border: 1px solid var(--line2);
  color: var(--ink);
  border-radius: 7px;
  padding: 4px 9px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.share-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 6px;
}
.countdown {
  text-align: center;
  color: var(--ink2);
  font-size: 0.88rem;
  margin: 10px 0 0;
}
.countdown b {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------- Article pages (privacy, terms, about, how-to-play) ---------- */
.article {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 18px 70px;
}
.article h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
  letter-spacing: -0.02em;
  margin: 10px 0 6px;
}
.article .updated {
  color: var(--ink3);
  font-size: 0.85rem;
  margin: 0 0 26px;
}
.article h2 {
  font-size: 1.25rem;
  margin: 30px 0 10px;
  letter-spacing: -0.01em;
}
.article h3 {
  font-size: 1.02rem;
  margin: 22px 0 8px;
}
.article p,
.article li {
  color: var(--ink2);
  line-height: 1.7;
  font-size: 0.98rem;
}
.article ul,
.article ol {
  padding-left: 24px;
}
.article .callout {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0;
}
.article .callout p {
  margin: 0;
}
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 14px 0;
}
.article th,
.article td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink2);
  vertical-align: top;
}
.article th {
  color: var(--ink);
}
.breadcrumb {
  font-size: 0.88rem;
  color: var(--ink3);
}
.breadcrumb a {
  text-decoration: none;
}

/* ---------- Motion & small screens ---------- */
@media (max-width: 380px) {
  .key {
    height: 50px;
  }
  .hud-actions .btn {
    padding-inline: 12px;
    font-size: 0.86rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
html[data-motion="reduce"] *,
html[data-motion="reduce"] *::before,
html[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ---------- Undo history ---------- */
.undo-history {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 4px 0 10px;
}
.undo-history summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink2);
}
.undo-history summary:hover {
  color: var(--ink);
}
.undo-list {
  display: grid;
  gap: 8px;
  padding: 12px 0 4px;
}
.undone-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mini-tiles {
  position: relative;
  display: inline-flex;
  gap: 3px;
  opacity: 0.75;
}
.mini-tiles::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 50%;
  height: 2px;
  background: var(--danger);
  border-radius: 1px;
  opacity: 0.8;
}
.mini-tile {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--on-tile);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}
.mini-tile.g { background: var(--tile-g); }
.mini-tile.y { background: var(--tile-y); }
.mini-tile.x { background: var(--tile-x); }
html[data-cb="1"] .mini-tile.y { color: #10243e; }
.undone-note {
  color: var(--ink3);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---------- Word Journal ---------- */
.lookup-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.lookup-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
  padding: 8px 12px;
  text-transform: lowercase;
}
.lookup-row input:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}
.journal-list {
  display: grid;
  gap: 10px;
}
.journal-entry {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.journal-entry .j-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.journal-entry .j-word {
  font-weight: 800;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.journal-entry .j-pos {
  color: var(--ink3);
  font-size: 0.78rem;
  font-style: italic;
}
.journal-entry .j-tag {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-radius: 999px;
  padding: 3px 9px;
}
.journal-entry .j-def {
  margin: 6px 0 0;
  color: var(--ink2);
  font-size: 0.9rem;
  line-height: 1.55;
}
.journal-entry .j-def a {
  font-size: 0.84rem;
}
.journal-empty {
  color: var(--ink3);
  font-size: 0.92rem;
  text-align: center;
  padding: 18px 0;
}

/* Alphabetical "All words" view */
.az-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  position: sticky;
  top: 0;
  background: var(--bg1);
  padding: 4px 0 8px;
  margin-bottom: 6px;
  z-index: 1;
}
.az-key {
  min-width: 26px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg2);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0 4px;
}
.az-key:hover {
  background: var(--brand);
  color: var(--on-brand);
  border-color: transparent;
}
.az-key.off {
  color: var(--ink3);
  opacity: 0.4;
  cursor: default;
}
.alpha-group {
  scroll-margin-top: 44px;
  margin-bottom: 4px;
}
.alpha-letter {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--brand);
  border-bottom: 1px solid var(--line);
  padding: 8px 0 4px;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}
.alpha-item {
  border-bottom: 1px solid var(--line);
}
.alpha-word {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 4px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.alpha-word::after {
  content: "+";
  color: var(--ink3);
  font-weight: 700;
}
.alpha-word[aria-expanded="true"]::after {
  content: "-";
}
.alpha-word:hover {
  color: var(--brand);
}
.alpha-def {
  color: var(--ink2);
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0 4px 12px;
}
.alpha-def a {
  font-size: 0.82rem;
}
.secret-def {
  text-align: center;
  color: var(--ink2);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0 0 14px;
  min-height: 1.2em;
}
.secret-def .j-pos {
  color: var(--ink3);
  font-style: italic;
}

/* Confetti canvas */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--z-modal) + 1);
}
