/* Crowns: one royal look everywhere, matching the key art.
   Navy velvet stage, polished gold, glossy enamel gem tiles. */
:root {
  color-scheme: dark;
  --bg: #13111d;
  --ink: #f6efe0;
  --ink-soft: #d3cbe2;
  --gold: #e8b23a;
  --gold-hi: #fbe39a;
  --gold-lo: #a06a14;
  --gold-grad: linear-gradient(180deg, #fbe39a 0%, #eebf4c 38%, #d39a26 70%, #b07a1a 100%);
  --metal: linear-gradient(145deg, #fbe39a 0%, #e1a93a 22%, #a8721a 48%, #f2cf6c 70%, #b98322 100%);
  --panel: linear-gradient(180deg, rgba(43, 38, 66, .92), rgba(26, 23, 41, .94));
  --panel-solid: #221e33;
  --rim: rgba(238, 191, 76, .45);
  --rim-soft: rgba(238, 191, 76, .2);
  --bad: #ff6b5e;
  --good: #7ad39a;
  --r0: #ef6f5a; --r1: #f5c445; --r2: #6fbf5e; --r3: #4fa9e0; --r4: #9b74e0;
  --r5: #f07fb5; --r6: #3fbfae; --r7: #f59a52; --r8: #6f86e8; --r9: #b9cc4a;
  --cell-x: rgba(20, 16, 34, .62);
  --display: Fraunces, Georgia, serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  font: 16px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(12, 10, 20, .62) 0%, rgba(12, 10, 20, .5) 30%, rgba(12, 10, 20, .45) 60%, rgba(12, 10, 20, .7) 100%),
    url(/bg-velvet.jpg);
  background-size: auto, cover;
  background-repeat: no-repeat;
  background-position: top center;
  background-attachment: fixed;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
svg { width: 22px; height: 22px; flex: none; }
a { color: inherit; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px 24px; min-height: 100%; display: flex; flex-direction: column; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-crown { width: 38px; height: 38px; margin-top: -6px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .5)); }
.wordmark {
  font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -.02em;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45));
}
.help-pill {
  display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px 0 7px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--rim); color: var(--gold-hi); font-weight: 700; font-size: 13px;
}
.help-pill svg { width: 18px; height: 18px; color: var(--gold); }
.help-pill:hover { border-color: var(--gold); }
.top-right { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--gold); }
.icon-btn:hover { background: rgba(238, 191, 76, .12); color: var(--gold-hi); }
.streak-chip {
  display: flex; align-items: center; gap: 3px; height: 32px; padding: 0 11px 0 7px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--rim); font-weight: 800; font-size: 14px; color: var(--gold-hi);
}
.streak-chip img { width: 20px; height: 20px; }
.streak-chip.cold img { filter: grayscale(1) opacity(.55); }

/* ---------- tabs ---------- */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; border-radius: 16px; margin: 6px 0 16px;
  background: rgba(10, 8, 18, .45); border: 1px solid var(--rim-soft);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
}
.tab { display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--ink); }
.tab svg { width: 17px; height: 17px; }
.tab.active {
  background: var(--gold-grad); color: #2a1d06;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -2px 0 rgba(120, 70, 10, .4), 0 2px 6px rgba(0, 0, 0, .4);
}

/* ---------- puzzle head ---------- */
.puzzle-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 8px; }
.puzzle-title { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.1; color: var(--ink); text-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.puzzle-sub { color: var(--ink-soft); font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.puzzle-sub select { padding: 4px 8px; font-size: 13px; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; color: var(--gold-hi);
  background: var(--panel); border: 1px solid var(--rim); border-radius: 12px; padding: 4px 12px;
}
.coach {
  min-height: 44px; font-size: 15px; line-height: 1.4; color: var(--ink); margin-bottom: 12px; padding: 11px 14px;
  background: rgba(14, 12, 24, .82); border: 1px solid var(--rim-soft); border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35); transition: border-color .2s;
}
.coach.warn { color: #ffd4cf; border-color: rgba(255, 107, 94, .7); font-weight: 600; background: rgba(60, 14, 18, .85); }
.coach strong, .coach b { color: var(--gold-hi); }
.coach.guide { border: 1.5px solid var(--gold); font-size: 16px; padding: 12px 16px 14px; box-shadow: 0 0 0 4px rgba(238, 191, 76, .12), 0 8px 20px rgba(0, 0, 0, .45); animation: guidein .35s ease; }
.coach.guide p { margin: 4px 0 0; }
.guide-top { display: flex; justify-content: space-between; align-items: center; }
.guide-step { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.guide-skip { font-size: 13px; font-weight: 700; color: var(--ink-soft); padding: 4px 8px; border-radius: 8px; }
.guide-skip:hover { color: var(--ink); background: rgba(255, 255, 255, .08); }
@keyframes guidein { from { transform: translateY(-6px); opacity: .3; } }

/* Tutorial focus */
body.tutorial .timer { visibility: hidden; }
body.tutorial .tabs, body.tutorial .tools, body.tutorial .legend { display: none; }
.cell.target { z-index: 3; }
.cell.target .tile {
  filter: brightness(1.15);
  box-shadow: 0 0 0 3px #fff3c4, 0 0 18px 6px rgba(255, 214, 110, .85), inset 0 2px 1px rgba(255, 255, 255, .6);
  animation: breathe 1.3s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.06); } }
.cell.target::before, .cell.target::after {
  content: ""; position: absolute; inset: -2px; border-radius: 22%; pointer-events: none;
  border: 3px solid #fff3c4; box-shadow: 0 0 14px 4px rgba(255, 214, 110, .9), inset 0 0 10px rgba(255, 230, 160, .7);
  animation: ring 1.3s ease-out infinite;
}
.cell.target::after { animation-delay: .65s; }
@keyframes ring { 0% { transform: scale(.85); opacity: 1; } 100% { transform: scale(1.45); opacity: 0; } }
.cell.nope .tile { animation: nope .35s ease; }
@keyframes nope { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.cell.xin .mx { animation: pop .25s cubic-bezier(.3, 1.6, .5, 1); }

/* ---------- board: gold setting with enamel gem tiles ---------- */
.board-wrap { position: relative; }
.board {
  --n: 8;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
  padding: 9px;
  border-radius: 20px;
  background: var(--metal);
  touch-action: none;
  user-select: none;
  box-shadow:
    0 22px 40px rgba(0, 0, 0, .55),
    0 0 70px rgba(240, 180, 70, .16),
    0 0 0 1px rgba(90, 55, 8, .8),
    inset 0 2px 1px rgba(255, 245, 200, .8),
    inset 0 -3px 2px rgba(90, 55, 8, .6);
  position: relative;
}
/* the inner bed the tiles sit in: darker gold so grooves read as wire */
.board::before {
  content: ""; position: absolute; inset: 7px; border-radius: 14px; pointer-events: none;
  background: linear-gradient(160deg, #e3ae45, #b8832a 50%, #d9a440);
  box-shadow: inset 0 2px 4px rgba(70, 40, 5, .6);
}
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; z-index: 1; }
.tile {
  position: absolute;
  top: var(--it, 1.5px); right: var(--ir, 1.5px); bottom: var(--ib, 1.5px); left: var(--il, 1.5px);
  border-radius: 18%;
  background:
    radial-gradient(ellipse 80% 55% at 35% 18%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--rc) 78%, white) 0%, var(--rc) 42%, color-mix(in srgb, var(--rc) 74%, black) 100%);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, .6),
    inset 0 -3px 3px rgba(0, 0, 0, .28),
    inset 0 0 0 1px rgba(0, 0, 0, .08),
    0 1.5px 2px rgba(60, 35, 5, .55);
  transition: filter .15s;
}
.cell:hover .tile { filter: brightness(1.06); }
.glyph { position: relative; z-index: 1; width: 100%; height: 100%; display: grid; place-items: center; pointer-events: none; }
.cell .tile { transition: transform .12s ease, filter .15s; }
.cell.press .tile { transform: scale(.92); filter: brightness(.95); }
/* Tiles cascade in when a board appears */
.board.enter .tile { animation: tilein .45s cubic-bezier(.2, 1.3, .4, 1) both; animation-delay: calc(var(--d, 0) * 28ms); }
@keyframes tilein { from { transform: scale(.3) translateY(-6px); opacity: 0; } }
/* A shine sweeps across the board on a solve */
.board::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 248, 220, .55) 48%, rgba(255, 255, 255, .0) 60%);
  background-size: 250% 100%; background-position: 150% 0; opacity: 0;
}
.board.won::after { animation: sweep 1.3s ease .15s; }
@keyframes sweep { 0% { opacity: 1; background-position: 150% 0; } 100% { opacity: 1; background-position: -60% 0; } }
.cell svg { width: 58%; height: auto; aspect-ratio: 1; pointer-events: none; }
.cell img.mc { width: 84%; height: auto; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(40, 20, 0, .5)); }
.cell .mx { width: 34%; color: var(--cell-x); }
.cell .mc { animation: pop .25s cubic-bezier(.3, 1.6, .5, 1); }
.cell.bad .tile { filter: saturate(.7) brightness(.9); }
.cell.bad .tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(45deg, rgba(220, 40, 40, .45) 0 5px, transparent 5px 10px);
  box-shadow: inset 0 0 0 2px rgba(255, 90, 80, .9);
}
.cell.bad .mc { filter: drop-shadow(0 0 5px rgba(255, 70, 60, 1)) saturate(.6); }
.cell.hint .tile { animation: hintpulse 1s ease-in-out 3; }
.board.won .cell .mc { animation: crownwave .6s ease both; animation-delay: calc(var(--d) * 45ms); }
.board.won { animation: boardglow 1.6s ease; }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }
@keyframes hintpulse { 50% { filter: brightness(1.4); box-shadow: inset 0 0 0 3px #fff6cf, 0 0 14px rgba(255, 220, 120, .9); } }
@keyframes crownwave { 40% { transform: translateY(-18%) scale(1.25); } }
@keyframes boardglow { 30% { box-shadow: 0 22px 40px rgba(0, 0, 0, .55), 0 0 40px rgba(255, 200, 90, .7), inset 0 2px 1px rgba(255, 245, 200, .8); } }

/* ---------- tool buttons ---------- */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.tool {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 48px; border-radius: 15px;
  background: var(--panel); border: 1px solid var(--rim); color: var(--ink); font-weight: 700; font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 4px 10px rgba(0, 0, 0, .35);
}
.tool:hover { border-color: var(--gold); }
.tool:active { transform: scale(.97); }
.tool svg { width: 19px; height: 19px; color: var(--gold); }
.tool .count {
  font-size: 11px; font-weight: 800; color: #2a1d06; background: var(--gold-grad); border-radius: 99px; padding: 1px 7px; margin-left: 2px;
}
.rules-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.rules-strip span {
  text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ink); padding: 8px 4px; border-radius: 11px;
  background: rgba(14, 12, 24, .78); border: 1px solid var(--rim-soft);
}
.rules-strip b { color: var(--gold-hi); font-weight: 800; }
.legend { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 10px 0 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 10px; }
.rules-grid div { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(10, 8, 18, .5); border: 1px solid var(--rim-soft); font-size: 14px; line-height: 1.3; }
.rules-grid b { font-family: var(--display); font-size: 30px; line-height: 1; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rules-grid em { font-style: normal; font-weight: 800; color: var(--gold-hi); }
svg.inline { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------- archive ---------- */
.archive-head h2 { font-family: var(--display); margin: 6px 0 2px; color: var(--ink); }
.archive-head p { color: var(--ink-soft); margin: 0 0 14px; font-size: 14px; }
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.day {
  background: var(--panel); border: 1px solid var(--rim-soft); border-radius: 14px; padding: 10px; text-align: left;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .3); min-height: 80px; display: flex; flex-direction: column; justify-content: space-between;
}
.day:hover { border-color: var(--rim); }
.day b { font-family: var(--display); font-size: 19px; color: var(--ink); }
.day small { color: var(--ink-soft); font-size: 12px; }
.day .st { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.day .st svg { width: 14px; height: 14px; }
.day.done { border-color: var(--rim); }
.day.done .st { color: var(--gold-hi); }
.day.locked { opacity: .65; }

.foot { margin-top: auto; padding-top: 28px; display: flex; gap: 8px; justify-content: center; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.foot a { text-decoration: none; }
.foot a:hover { text-decoration: underline; color: var(--gold-hi); }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(6, 5, 12, .62); backdrop-filter: blur(3px); z-index: 20; animation: fade .2s; }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(560px, 100%); max-height: 92vh; overflow-y: auto; overflow-x: hidden;
  background:
    radial-gradient(ellipse 80% 30% at 50% 0%, rgba(240, 180, 70, .16), transparent 70%),
    linear-gradient(180deg, #2a2540, #1b1829);
  border: 1px solid var(--rim); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 26px 22px max(24px, env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 230, 160, .25);
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
@media (min-width: 640px) { .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 24px; border-bottom: 1px solid var(--rim); animation: fade .2s; } }
.sheet-close { position: absolute; right: 10px; top: 10px; }
.sheet h2 { font-family: var(--display); font-size: 30px; margin: 0 0 4px; letter-spacing: -.01em; color: var(--ink); }
.sheet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin: 22px 0 8px; }
.sheet p { margin: 6px 0; }
.muted { color: var(--ink-soft); }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 54px; border-radius: 16px;
  font-weight: 800; font-size: 16px; margin-top: 10px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--rim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 4px 10px rgba(0, 0, 0, .35);
}
.btn svg { width: 20px; height: 20px; color: var(--gold); }
.btn.gold {
  background: var(--gold-grad); color: #2a1d06; border: 1px solid #8a5a10; text-shadow: 0 1px 0 rgba(255, 240, 200, .6);
  box-shadow: inset 0 2px 0 rgba(255, 250, 220, .75), inset 0 -3px 0 rgba(120, 70, 10, .45), 0 6px 16px rgba(200, 140, 30, .35);
}
.btn.gold svg { color: #2a1d06; }
.btn.ghost { background: var(--panel); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .7; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- stats and win ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 12px 0; }
.stat-row b { display: block; font-size: 28px; font-family: var(--display); line-height: 1.1; color: var(--ink); }
.stat-row span { font-size: 12px; color: var(--ink-soft); }
.win-time {
  font-family: var(--display); font-size: 58px; font-weight: 800; line-height: 1; margin: 8px 0 2px; font-variant-numeric: tabular-nums;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5));
}
.pct { display: inline-block; background: rgba(122, 211, 154, .14); border: 1px solid rgba(122, 211, 154, .4); color: var(--good); font-weight: 700; border-radius: 99px; padding: 4px 12px; font-size: 14px; margin-top: 8px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--gold-hi); }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 70px 1fr 28px; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.bar i { display: block; height: 18px; border-radius: 6px; background: var(--gold-grad); min-width: 4px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
.week { display: flex; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.week span {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: rgba(10, 8, 18, .45); border: 1px solid var(--rim-soft); color: var(--ink-soft);
}
.week span.on { background: var(--gold-grad); color: #2a1d06; border-color: #8a5a10; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6); }
.week span.frozen { background: linear-gradient(180deg, #bfe3ff, #6fb3d6); color: #10202e; border-color: #4f8fb3; }
.week span svg { width: 16px; height: 16px; }

/* ---------- Club ---------- */
.club {
  border-radius: 20px; padding: 18px; margin-top: 18px;
  background: radial-gradient(ellipse at 20% 0%, rgba(240, 180, 70, .22), transparent 60%), linear-gradient(160deg, #332b4f, #1f1b30);
  border: 1px solid var(--rim);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, .25), 0 8px 20px rgba(0, 0, 0, .4);
}
.club h4 { margin: 0 0 4px; font-family: var(--display); font-size: 21px; display: flex; gap: 8px; align-items: center; color: var(--gold-hi); }
.club ul { margin: 8px 0 4px; padding-left: 18px; }
.club li { margin: 4px 0; font-size: 14px; }
.club li::marker { color: var(--gold); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.plan {
  border: 1.5px solid var(--rim-soft); border-radius: 14px; padding: 12px 6px 10px; text-align: center; position: relative;
  background: rgba(10, 8, 18, .4);
}
.plan.sel { border-color: var(--gold); background: rgba(238, 191, 76, .14); box-shadow: 0 0 0 1px var(--gold), 0 0 16px rgba(238, 191, 76, .25); }
.plan b { display: block; font-size: 19px; color: var(--ink); }
.plan small { font-size: 11px; color: var(--ink-soft); }
.plan em { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--gold-grad); color: #2a1d06; font-style: normal; font-size: 10px; font-weight: 800; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.club a { color: var(--gold-hi); }

/* ---------- settings and inputs ---------- */
.setting { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--rim-soft); gap: 12px; }
.setting small { display: block; color: var(--ink-soft); font-size: 12px; }
.switch { width: 48px; height: 28px; border-radius: 99px; background: rgba(10, 8, 18, .6); border: 1px solid var(--rim-soft); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, #fff, #ddd5c4); top: 2px; left: 2px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.switch[aria-checked="true"] { background: var(--gold-grad); border-color: #8a5a10; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
select, input[type=text], input[type=email] {
  font: inherit; padding: 9px 11px; border-radius: 11px; border: 1px solid var(--rim); background: rgba(10, 8, 18, .55); color: var(--ink);
}
input[type=text], input[type=email] { width: 100%; }
select option { background: var(--panel-solid); color: var(--ink); }

/* ---------- how to play minis ---------- */
.rule { display: flex; gap: 14px; align-items: flex-start; margin: 14px 0; }
.rule .mini {
  flex: none; width: 78px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 4px;
  border-radius: 10px; background: var(--metal); box-shadow: 0 4px 8px rgba(0, 0, 0, .4);
}
.rule .mini i {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 22%;
  background-image: radial-gradient(ellipse 80% 55% at 35% 18%, rgba(255, 255, 255, .5), transparent 60%), linear-gradient(180deg, rgba(255, 255, 255, .25), rgba(0, 0, 0, .18));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 1px 1px rgba(60, 35, 5, .5);
}
.rule .mini svg { width: 70%; height: 70%; }
.rule .mini img { width: 86%; }
.rule b { color: var(--gold-hi); }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -90px); background: var(--gold-grad); color: #2a1d06;
  padding: 10px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; z-index: 40; transition: transform .25s; pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.toast.show { transform: translate(-50%, 0); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- badges ---------- */
.badge { display: inline-block; object-fit: contain; vertical-align: middle; }
.win-mark { display: block; margin: -6px auto 2px; filter: drop-shadow(0 10px 22px rgba(240, 180, 70, .45)); animation: crownin .7s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes crownin { from { transform: translateY(-30px) scale(.6) rotate(-8deg); opacity: 0; } }
.awards { display: flex; justify-content: center; gap: 20px; margin: 16px 0 4px; flex-wrap: wrap; }
.award { display: grid; justify-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--gold-hi); animation: awardin .5s cubic-bezier(.2, 1.5, .4, 1) both; animation-delay: calc(.35s + var(--i) * .12s); }
.award .badge { filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }
@keyframes awardin { from { transform: scale(.3); opacity: 0; } }
.badges-row > div { display: grid; justify-items: center; gap: 2px; }
.badges-row .badge { margin-bottom: 4px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45)); }
.club h4 .badge { width: 40px; height: 40px; margin: -6px 0 -6px -4px; }
.sheet-hero { display: grid; place-items: center; margin-top: -4px; }
.sheet-hero .badge { filter: drop-shadow(0 10px 20px rgba(240, 180, 70, .4)); animation: crownin .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.day .st .badge { width: 18px; height: 18px; }

@media (max-width: 420px) {
  .help-pill span { display: none; }
  .help-pill { padding: 0 7px; }
  .wordmark { font-size: 23px; }
  .brand-crown { width: 30px; height: 30px; }
  .brand { gap: 6px; }
  .icon-btn { width: 34px; height: 36px; }
  .top-right { gap: 2px; }
  .streak-chip { height: 30px; padding: 0 9px 0 6px; font-size: 13px; }
  .tab { font-size: 13px; gap: 5px; }
}

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

/* ---------- loading scene (studio-mark.md section 2) ---------- */
.pp-loading {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: #13111d url(/bg-velvet.jpg) center / cover no-repeat; transition: opacity .35s ease;
}
.pp-loading.gone { opacity: 0; pointer-events: none; }
.load-logo { display: grid; justify-items: center; gap: 6px; margin-bottom: 14vh; animation: loadin .6s cubic-bezier(.2, 1.3, .4, 1) both; }
.load-logo img { width: min(46vw, 200px); height: auto; filter: drop-shadow(0 12px 26px rgba(240, 180, 70, .45)); }
.load-logo span { font-family: var(--display); font-weight: 800; font-size: clamp(44px, 13vw, 72px); background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .6)); }
@keyframes loadin { from { transform: scale(.85); opacity: 0; } }
.pp-fade { position: absolute; inset: auto 0 0 0; height: 30%; background: linear-gradient(to bottom, transparent, rgba(19, 17, 29, .69)); }
.pp-studio { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(3.5vh + env(safe-area-inset-bottom, 0px)); width: clamp(140px, 34vmin, 280px); height: auto; opacity: .92; animation: pp-in .25s ease-out both; }
@keyframes pp-in { from { opacity: 0; } }

/* Keep the Powell Play button's corner clear */
#app { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

/* ---------- settings ---------- */
.mini-btn { width: auto; height: 36px; padding: 0 14px; margin: 0; font-size: 14px; flex: none; }
.row-btns { display: flex; gap: 8px; }
.link-row { text-decoration: none; color: var(--ink); }
.link-row span { color: var(--gold); font-size: 22px; }
.danger-row { color: var(--bad); }
.about { text-align: center; margin-top: 26px; display: grid; justify-items: center; gap: 4px; }
.about-mark img { width: 120px; height: auto; opacity: .7; transition: opacity .15s; display: block; }
.about-mark:hover img, .about-mark:focus-visible img { opacity: 1; }
.about p { margin: 2px 0; font-size: 12.5px; color: var(--ink-soft); }
.about a { color: var(--ink-soft); }
.about .ver { font-variant-numeric: tabular-nums; }
.sheet input[type=text] { margin: 8px 0 4px; font-size: 16px; letter-spacing: .02em; }

/* ---------- Powell Play (powellplay-ui.md: tokens Coal, Card, Line, Bone, Dim, Lime, Danger) ---------- */
.pp-section {
  margin: 22px 0 6px; padding: 16px; border-radius: 20px; background: #151515; border: 1px solid rgba(246, 243, 235, .09);
  font-family: 'Space Grotesk', Inter, system-ui, sans-serif; color: #F6F3EB;
}
.pp-section h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .2em; color: #A9A59C; text-transform: uppercase; }
.pp-dim { color: #A9A59C; font-size: 13px; display: block; }
.pp-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pp-row b { font-size: 15px; font-weight: 700; display: block; }
.pp-item { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 0; border-top: 1px solid rgba(246, 243, 235, .09); color: #F6F3EB; text-decoration: none; text-align: left; font-size: 15px; }
.pp-item small { display: block; color: #A9A59C; font-size: 13px; }
.pp-danger { color: #FF6B7A; }
.pp-link { color: #F6F3EB; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; padding: 8px 0; display: block; text-align: left; }
.pp-signin { display: block; margin: 12px 0 4px; width: 100%; max-width: 320px; border-radius: 14px; transition: transform .1s, filter .1s; }
.pp-signin img { display: block; width: 100%; height: auto; min-height: 44px; }
.pp-signin:active { transform: scale(.97); filter: brightness(1.08); }
.pp-avatar { width: 44px; height: 44px; border-radius: 22%; object-fit: cover; display: grid; place-items: center; flex: none; }
.pp-mono { background: #151515; border: 1px solid rgba(246, 243, 235, .09); color: #A9A59C; font-weight: 700; }
.pp-av-wrap { position: relative; display: inline-block; flex: none; }
.pp-av-wrap .pp-avatar { width: 100%; height: 100%; }
.pp-frame { position: absolute; left: 50%; top: 50%; width: 114%; height: 114%; transform: translate(-50%, -50%); pointer-events: none; }
.pp-sheet h2 { font-size: 22px; }
.pp-option { display: grid; gap: 2px; width: 100%; text-align: left; padding: 14px; margin: 8px 0; border-radius: 16px; border: 1px solid rgba(246, 243, 235, .09); background: #151515; color: #F6F3EB; }
.pp-option b { font-size: 17px; }
.pp-option span { color: #A9A59C; font-size: 13px; }
.pp-option.sel { border: 2px solid #C7F000; box-shadow: 0 0 18px rgba(199, 240, 0, .25); }
.pp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
@media (max-width: 360px) { .pp-cards { grid-template-columns: 1fr; } }
.pp-card { display: grid; gap: 4px; justify-items: start; padding: 14px; border-radius: 16px; background: #151515; border: 1px solid rgba(246, 243, 235, .09); font-size: 13px; color: #A9A59C; }
.pp-card small { text-transform: uppercase; letter-spacing: .12em; font-size: 10px; color: var(--gold); }
.pp-card b { color: #F6F3EB; font-size: 16px; }
.pp-note { font-size: 13px; color: var(--ink-soft); text-align: center; }
.pp-lines { padding-left: 18px; display: grid; gap: 10px; margin: 12px 0; }
.pp-code { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; padding: 10px 12px; border-radius: 12px; background: #0b0b0b; border: 1px solid var(--rim); }
.pp-code code { font: 700 15px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; color: var(--gold-hi); flex: 1; word-break: break-all; }
.pp-code .pp-link { padding: 0; }
.pp-prompt { display: grid; gap: 4px; margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: #151515; border: 1px solid rgba(246, 243, 235, .09); color: #F6F3EB; text-align: left; }
.pp-prompt span { color: #A9A59C; font-size: 13px; }
.btn.danger { background: #FF6B7A; color: #0b0b0b; border-color: #c94455; }
html.pp-off .pp-section, html.pp-off .pp-prompt { display: none; }
html.pp-host .club, html.pp-host #s-join, html.pp-host #s-restore { display: none !important; }

/* ---------- badges in stats ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.badge-cell { display: grid; justify-items: center; text-align: center; gap: 3px; padding: 10px 6px; border-radius: 14px; background: rgba(10, 8, 18, .45); border: 1px solid var(--rim-soft); }
.badge-cell img { filter: grayscale(1) brightness(.6); opacity: .55; }
.badge-cell b { font-size: 12px; line-height: 1.2; color: var(--ink-soft); }
.badge-cell span { font-size: 10.5px; line-height: 1.25; color: var(--ink-soft); opacity: .8; }
.badge-cell.got { border-color: var(--rim); background: rgba(238, 191, 76, .08); }
.badge-cell.got img { filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45)); opacity: 1; }
.badge-cell.got b { color: var(--gold-hi); }

.award em { font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #2a1d06; background: var(--gold-grad); border-radius: 99px; padding: 1px 7px; margin-top: 2px; }
.award.new .badge { filter: drop-shadow(0 0 10px rgba(255, 214, 110, .7)) drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }

/* Portal builds (embedded in another site): portal hides the studio lockup, Support links and Powell Play (studio-mark.md section 7) */
html.portal .about-mark, html.portal .about a, html.portal .link-row[href="/support"], html.portal .pp-studio, html.portal .pp-section, html.portal .pp-prompt { display: none !important; }
