/* Crowns — a gilded tray on a night-blue table: enamel-coloured regions with
   bold seams (so colour is never the only cue), gold crowns that land with a
   clink, and a royal finish. Scoped under .cr. */
.cr {
  --night: #12163a; --night-2: #1c2150; --ink: #1b1f3d; --cream: #fff8ea;
  --gold: #ffc84a; --gold-d: #c98a00; --bad: #ff4d6d; --muted: #a9b0d6;
  --r0: #ff9b85; --r1: #ffd166; --r2: #8fe3b0; --r3: #8ecbff; --r4: #c3a6ff;
  --r5: #ffb3d1; --r6: #6fd6cf; --r7: #d4ed7a; --r8: #e8c9a0;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Nunito', system-ui, sans-serif;

  max-width: 520px; margin: 0 auto; padding: 16px 16px 28px;
  display: flex; flex-direction: column; gap: 14px;
  color: var(--cream); font-family: var(--body); text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.cr-page {
  background:
    radial-gradient(70% 30% at 50% 0%, rgba(255,200,74,.14), transparent 70%),
    radial-gradient(50% 30% at 100% 60%, rgba(142,203,255,.06), transparent 70%),
    #12163a;
  padding-bottom: 24px;
}
.cr *, .cr *::before, .cr *::after { box-sizing: border-box; }
.cr [hidden] { display: none !important; }
.cr button { margin: 0; }

.cr-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cr-brand { display: flex; align-items: center; gap: 10px; }
.cr-brand svg { width: 44px; height: 38px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.cr-brand h1 { font: 900 38px/1 var(--display); margin: 0; letter-spacing: -.01em; color: var(--cream); }
.cr-meta { text-align: right; font-weight: 800; color: var(--muted); font-size: 13px; line-height: 1.35; }
.cr-meta b { color: var(--cream); }

.cr-rules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cr-rule { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 7px 4px 8px; text-align: center; font-size: 11.5px; font-weight: 800; color: var(--muted); line-height: 1.2; }
.cr-rule svg { display: block; margin: 0 auto 4px; width: 30px; height: 30px; }

.cr-banner { background: linear-gradient(90deg, rgba(255,200,74,.18), rgba(255,200,74,.06)); border: 1px solid rgba(255,200,74,.35); border-radius: 14px; padding: 10px 14px; font-weight: 800; font-size: 15px; }
.cr-banner b { color: var(--gold); }
.cr-banner button { font: 900 14px var(--body); color: var(--gold); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }

.cr-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cr-timer { font: 900 26px var(--body); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; color: var(--cream); }
.cr-timer .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.cr-timer.paused .dot { background: var(--muted); box-shadow: none; }
.cr-tools { display: flex; gap: 6px; }
.cr-tool { font: 800 14px var(--body); color: var(--cream); background: var(--night-2); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 9px 12px; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.cr-tool:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.cr-tool:disabled { opacity: .4; cursor: default; }
.cr button:focus-visible, .cr input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* the board */
.cr-tray {
  position: relative; padding: 10px; border-radius: 18px;
  background: linear-gradient(145deg, #ffe27a, #d79b0f 45%, #ffd65a 70%, #b97f00);
  box-shadow: 0 2px 0 rgba(255,255,255,.4) inset, 0 -3px 0 rgba(0,0,0,.25) inset, 0 18px 40px rgba(0,0,0,.45);
}
.cr-board {
  --n: 8; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  aspect-ratio: 1; width: 100%; background: var(--ink); border: 3px solid var(--ink); border-radius: 8px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.cr-board.loading { display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.cr-cell {
  position: relative; border: 0; padding: 0; cursor: pointer; background: var(--c);
  min-width: 0; min-height: 0; overflow: hidden; transition: filter .15s;
  box-shadow: inset 0 0 0 .5px rgba(27,31,61,.35);
}
.cr-cell.t { border-top: 3px solid var(--ink); } .cr-cell.b { border-bottom: 3px solid var(--ink); }
.cr-cell.l { border-left: 3px solid var(--ink); } .cr-cell.r { border-right: 3px solid var(--ink); }
.cr-cell::before { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255,255,255,.28), transparent 45%, rgba(0,0,0,.06)); pointer-events: none; }
@media (hover: hover) { .cr-cell:hover { filter: brightness(1.06); } }
.cr-cell svg { position: absolute; inset: 0; margin: auto; }
.cr-cell .x { width: 34%; height: 34%; color: rgba(27,31,61,.55); }
.cr-cell .x.auto { color: rgba(27,31,61,.2); }
.cr-cell .crown { width: 72%; height: 72%; filter: drop-shadow(0 2px 0 rgba(0,0,0,.25)); animation: cr-land .32s cubic-bezier(.3,1.7,.5,1); }
.cr-cell.bad { background-image: repeating-linear-gradient(135deg, rgba(255,77,109,.42) 0 6px, transparent 6px 12px); }
.cr-cell.bad .crown { animation: cr-bad .4s ease; }
.cr-cell.hint { animation: cr-hint 1.2s ease 2; }
@keyframes cr-land { 0% { transform: scale(.3) translateY(-40%); } 100% { transform: scale(1); } }
@keyframes cr-bad { 25%, 75% { transform: translateX(-12%); } 50% { transform: translateX(12%); } }
@keyframes cr-hint { 50% { box-shadow: inset 0 0 0 4px #fff, 0 0 18px #fff; } }
.cr-board.won .crown { animation: cr-wave .6s cubic-bezier(.3,1.7,.5,1) both; animation-delay: var(--d); }
@keyframes cr-wave { 40% { transform: scale(1.35) rotate(-8deg); } }
.cr-board.won .cr-cell::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,241,184,.85) 50%, transparent 70%); background-size: 300% 100%; animation: cr-shine 1.1s ease both; animation-delay: calc(var(--d) * .6); pointer-events: none; }
@keyframes cr-shine { from { background-position: 120% 0; } to { background-position: -40% 0; } }

.cr-status { min-height: 1.4em; text-align: center; font-weight: 800; color: var(--muted); margin: 0; }
.cr-status.warn { color: #ffb3c0; }

/* the finish */
.cr-win { background: var(--cream); color: var(--ink); border-radius: 22px; padding: 20px 18px 18px; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 18px 40px rgba(0,0,0,.4); animation: cr-rise .5s cubic-bezier(.2,1.3,.4,1); }
@keyframes cr-rise { from { transform: translateY(30px); opacity: 0; } }
.cr-win h2 { font: 900 40px/1 var(--display); margin: 0; color: var(--ink); }
.cr-win .time { font: 900 54px/1 var(--body); font-variant-numeric: tabular-nums; color: var(--gold-d); }
.cr-win p { margin: 0; }
.cr-vs { font-weight: 900; font-size: 18px; }
.cr-proof { font-weight: 900; color: #7a5200; }
.cr-chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.cr-chip { background: #f1e6cf; border-radius: 999px; padding: 6px 12px; font-weight: 900; font-size: 14px; }
.cr-name { display: flex; flex-direction: column; gap: 6px; text-align: left; font-weight: 800; font-size: 14px; color: #4b5280; }
.cr-name input { font: 800 17px var(--body); padding: 11px 12px; border-radius: 12px; border: 2px solid #e2d6bb; background: #fff; color: var(--ink); width: 100%; }
.cr-big { font: 900 19px var(--body); border: 0; border-radius: 16px; padding: 15px 18px; cursor: pointer; color: var(--ink); background: var(--gold); box-shadow: 0 5px 0 var(--gold-d); }
.cr-big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-d); }
.cr-big.alt { background: var(--ink); color: var(--cream); box-shadow: 0 5px 0 #000; }
.cr-next { font-weight: 800; color: #6b7199; font-size: 14px; }
.cr-practice { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; align-items: center; }
.cr-practice span { font-weight: 900; color: #4b5280; font-size: 14px; }
.cr-practice button { font: 900 15px var(--body); border-radius: 12px; padding: 9px 12px; border: 2px solid #e2d6bb; background: #fff; color: var(--ink); cursor: pointer; }
.cr-mode { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; color: var(--muted); }
.cr-mode button { font: 800 14px var(--body); color: var(--gold); background: none; border: 0; cursor: pointer; text-decoration: underline; padding: 4px; }

.cr-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--cream); color: var(--ink); font: 900 15px var(--body); padding: 10px 16px; border-radius: 999px; transition: .25s; pointer-events: none; z-index: 1001; }
.cr-toast.show { opacity: 1; transform: translateX(-50%); }
canvas.cr-fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }

/* how-to and FAQ cards below the game */
.cr-content { max-width: 760px; margin: 8px auto 0; padding: 0 16px; display: grid; gap: 16px; color: #dfe8f5; font-family: system-ui, sans-serif; }
.cr-card { background: #10151f; border: 1px solid #212a3d; border-radius: 12px; padding: 16px 18px; }
.cr-card h2 { margin: 0 0 8px; font-size: 1.3rem; color: #fff; }
.cr-card h3 { margin: 14px 0 6px; font-size: 1.05rem; color: #fff; }
.cr-card p, .cr-card li { color: #b9c2d3; line-height: 1.6; }
.cr-card ol, .cr-card ul { margin: 6px 0 0 20px; padding: 0; }
.cr-card details { background: #0f1421; border: 1px solid #212a3d; border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.cr-card summary { cursor: pointer; font-weight: 700; color: #fff; }

@media (max-width: 380px) { .cr-brand h1 { font-size: 32px; } .cr-rule { font-size: 10.5px; } .cr-tool { padding: 9px 10px; } }
@media (prefers-reduced-motion: reduce) { .cr *, .cr *::before, .cr *::after { animation: none !important; transition: none !important; } }
