/* SQUINT - cartoony pixel look.
   Rules of thumb used here: hard offset shadows (no blur), notched pixel borders,
   press feedback on :active, hover gated to real pointers, reduced motion respected. */

@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/pixelify-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Silkscreen"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/silkscreen-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #1B1A3A;
  --sky: #CFE3FF;
  --sky-2: #BCD6FF;
  --white: #FFFFFF;
  --coral: #FF6B5E;
  --violet: #8E73FF;
  --sun: #FFC83D;
  --mint: #34D399;
  --sea: #5BC0FF;
  --shade: rgba(27, 26, 58, 0.28);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  /* Reading text: Atkinson Hyperlegible (made for legibility).
     Pixel look only for short titles (Pixelify Sans) and the logo (Silkscreen).
     Never use a pixel font for numbers: Pixelify's 5 and 8 look like the letter S, and Silkscreen's 4 is a blob. */
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-title: "Pixelify Sans", ui-monospace, "Courier New", monospace;
  --font-logo: "Silkscreen", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--sky);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--sky);
  background-image:
    linear-gradient(var(--sky-2) 2px, transparent 2px),
    linear-gradient(90deg, var(--sky-2) 2px, transparent 2px);
  background-size: 24px 24px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, a, [role="button"] { touch-action: manipulation; }
button { font: inherit; color: inherit; }
button, .noselect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

h1, h2, h3, p { margin: 0; }
canvas.px, .px-img { image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.app:focus-visible { outline: none; }   /* the app container only takes focus so screen readers and keyboards start at the top of a new screen */

.app { max-width: 980px; margin: 0 auto; padding: 14px 16px 40px; }

/* ---------- pixel surfaces ---------- */
.pix {
  background: var(--white);
  margin: 4px;
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    0 12px 0 0 var(--shade);
}

.btn {
  --c: var(--white);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 8px 18px;
  margin: 4px;
  border: 0;
  background: var(--c);
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    0 8px 0 0 var(--shade);
  transition: transform 110ms var(--ease-out), box-shadow 110ms var(--ease-out), background-color 110ms var(--ease-out);
}
.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    0 4px 0 0 var(--shade);
}
.btn[disabled], .btn.is-off { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }
.btn-primary { --c: var(--sun); }
.btn-coral { --c: var(--coral); }
.btn-small { min-height: 40px; padding: 4px 12px; font-size: 16px; }
.btn-wide { width: calc(100% - 8px); }

@media (hover: hover) and (pointer: fine) {
  .btn:not([disabled]):hover { background: color-mix(in srgb, var(--c) 82%, white); }
}

/* ---------- header ---------- */
.hdr { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo canvas { width: 40px; height: 28px; }
.logo-word { font-family: var(--font-logo); font-weight: 700; font-size: 28px; letter-spacing: 2px; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: center; padding: 8px 0 22px; }
.hero-eye { width: min(260px, 70%); margin: 0 auto; }
.hero-eye canvas { width: 100%; height: auto; display: block; }
.hero-copy h1 { font-family: var(--font-title); font-size: clamp(30px, 6vw, 46px); line-height: 1.05; font-weight: 700; margin-bottom: 10px; text-wrap: balance; }
.hero-copy p { font-size: 19px; max-width: 34ch; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 14px; }
.chip { display: inline-block; margin: 4px; padding: 4px 12px; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); font-weight: 600; }
.chip b { font-variant-numeric: tabular-nums; }
@media (min-width: 720px) {
  .hero { grid-template-columns: 280px 1fr; gap: 36px; }
  .hero-eye { width: 100%; }
}

/* ---------- daily run ---------- */
.run { padding: 16px 18px 18px; margin: 4px 4px 28px; display: grid; gap: 12px; grid-template-columns: 1fr; align-items: center; background: var(--sun); }
.run h2 { font-family: var(--font-title); font-size: 26px; }
.run p { margin-top: 2px; }
.pips { display: flex; gap: 8px; margin-top: 8px; }
.pip { width: 22px; height: 22px; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.pip.on { background: var(--mint); }
.pip.now { background: var(--coral); }
.run-actions { display: flex; flex-wrap: wrap; align-items: center; }
@media (min-width: 720px) { .run { grid-template-columns: 1fr auto; } }

/* ---------- game cards ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 26px 24px; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }

.gcard { --c: var(--coral); display: flex; flex-direction: column; margin: 4px; padding: 0; overflow: visible; }
.gcard-top { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--c); }
.gcard-top canvas { width: 64px; height: 64px; flex: none; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.gcard-top h3 { font-family: var(--font-title); font-size: 24px; line-height: 1.05; }
.gcard-body { padding: 12px 16px 6px; }
.gcard-body p { min-height: 2.7em; }
.gcard-body .gcard-status { margin-top: 8px; min-height: 0; font-weight: 600; }
.gcard-status .ok { color: #0B7A55; }
.gcard-unl { margin-top: 6px; min-height: 36px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-weight: 600; }
.gcard-unl .ok { color: #0B7A55; }
.gcard-unl .btn { min-height: 36px; padding: 2px 12px; font-size: 15px; }
.gcard-actions { display: flex; flex-wrap: wrap; padding: 6px 12px 14px; }
.gcard-actions .btn { flex: 1 1 130px; }

/* ---------- game screen ---------- */
.gamebar { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px; }
.gtitle { font-family: var(--font-title); flex: 1; min-width: 0; font-size: 22px; font-weight: 700; line-height: 1.05; }
.gtitle small { display: block; font-family: var(--font-body); font-size: 15px; font-weight: 400; opacity: 0.9; }
.gameroot { padding: 0 4px; }
.gamebar, .gameroot { max-width: 820px; margin-left: auto; margin-right: auto; }

.q { font-size: clamp(22px, 4.6vw, 30px); font-weight: 700; line-height: 1.1; margin: 4px 0 12px; text-wrap: balance; }
.q.fixed { min-height: 2.2em; }
.hint { font-size: 17px; color: #2D2B55; margin-bottom: 10px; }
.hint.two { min-height: 3.1em; }   /* memory round: same height before, during and after the flash so the board never jumps */
.panel { padding: 14px 16px; margin: 4px 4px 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.right { margin-left: auto; }
.muted { opacity: 0.85; }
.gamebar .muted { font-weight: 700; opacity: 1; }
.big { font-size: 26px; font-weight: 700; }

/* rare map */
.map-wrap { margin: 8px 4px 14px; background: var(--sea); position: relative; line-height: 0; }
.map { width: 100%; aspect-ratio: 400 / 158; height: auto; display: block; touch-action: none; cursor: crosshair; }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.pickline { min-height: 1.5em; font-size: 20px; font-weight: 700; flex: 1 1 110px; padding: 0 6px; min-width: 0; overflow-wrap: anywhere; }

/* glimpse */
.scene-wrap { position: relative; margin: 8px 4px 14px; line-height: 0; background: var(--ink); }
.scene { width: 100%; height: auto; display: block; }
.scene-wrap, .timer { max-width: 680px; margin-left: auto; margin-right: auto; }   /* keep the scene on screen on a desktop */
.cover { font-family: var(--font-title); position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 700; line-height: 1; color: var(--ink); background-color: var(--sky); background-image: linear-gradient(45deg, var(--sky-2) 25%, transparent 25%, transparent 75%, var(--sky-2) 75%), linear-gradient(45deg, var(--sky-2) 25%, transparent 25%, transparent 75%, var(--sky-2) 75%); background-size: 32px 32px; background-position: 0 0, 16px 16px; }
.cover[hidden] { display: none; }
.timer { height: 14px; margin: 0 4px 12px; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); overflow: hidden; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--coral); transform-origin: left center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0 12px; }
.stepper output { min-width: 3ch; text-align: center; font-size: 44px; font-weight: 700; line-height: 1; }
.stepper .btn { width: 56px; min-height: 56px; font-size: 28px; padding: 0; }

/* shortcut */
.board { position: relative; aspect-ratio: 4 / 3; max-width: 620px; margin: 8px auto 14px; background: var(--white); touch-action: manipulation; background-image: radial-gradient(var(--sky-2) 2px, transparent 2px); background-size: 20px 20px; }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board svg line, .board svg polyline { shape-rendering: crispEdges; stroke-linecap: square; stroke-linejoin: miter; fill: none; }
.dot { position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; padding: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.dot::before { content: ""; width: 22px; height: 22px; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); transition: transform 110ms var(--ease-out), background-color 110ms var(--ease-out); }
.dot:active::before { transform: scale(0.88); }
.dot.on::before { background: var(--sun); }
.dot.last::before { background: var(--coral); }
.dot span { position: absolute; font-size: 15px; font-weight: 700; line-height: 1; pointer-events: none; }
.dot.off { cursor: default; }

/* fake flag */
.flag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; margin: 12px auto 14px; max-width: 620px; }
.flag-btn { padding: 0; border: 0; background: transparent; cursor: pointer; display: block; text-align: center; transition: transform 110ms var(--ease-out); }
.flag-btn:active { transform: scale(0.97); }
.flag-btn canvas { display: block; width: 100%; height: auto; background: var(--white); box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink), 0 10px 0 0 var(--shade); }
.flag-btn .fname { display: block; min-height: 1.4em; margin-top: 14px; font-size: 16px; font-weight: 600; }
.flag-btn.fake canvas { box-shadow: 0 -4px 0 0 var(--mint), 0 4px 0 0 var(--mint), -4px 0 0 0 var(--mint), 4px 0 0 0 var(--mint), 0 10px 0 0 var(--ink); }
.flag-btn.wrong canvas { box-shadow: 0 -4px 0 0 var(--coral), 0 4px 0 0 var(--coral), -4px 0 0 0 var(--coral), 4px 0 0 0 var(--coral), 0 10px 0 0 var(--ink); }
.flag-btn[disabled] { cursor: default; }
.flag-btn[disabled]:active { transform: none; }

/* ---------- results ---------- */
.result { padding: 22px 18px 20px; margin: 8px 4px 24px; text-align: center; }
.result h2 { font-size: 24px; margin-bottom: 4px; }
.bignum { font-size: clamp(72px, 22vw, 120px); font-weight: 700; line-height: 1; margin: 6px 0 2px; }
.bignum small { font-size: 0.3em; opacity: 0.7; margin-left: 6px; }
.squares { display: flex; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.sq { width: 30px; height: 30px; box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.sq.g { background: var(--mint); } .sq.y { background: var(--sun); } .sq.o { background: #FF9A3D; } .sq.x { background: #4A4870; }
.vs { margin-top: 14px; font-size: 20px; font-weight: 600; }
.note { margin-top: 6px; font-size: 15px; color: #3A3860; max-width: 44ch; margin-inline: auto; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.subscores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; margin: 18px 4px 4px; }
.subscore { padding: 8px 6px; background: var(--sky); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.subscore b { display: block; font-size: 28px; line-height: 1.1; }
/* profile */
.profile .pcard { display: block; width: min(340px, 100%); height: auto; margin: 10px auto 0; }
.profile .psec-title { font-family: var(--font-title); font-size: 24px; margin: 26px 4px 0; text-align: left; }
.profile .psec { margin: 22px 0 0; text-align: left; }
.profile .psec h3 { display: flex; align-items: center; gap: 10px; font-family: var(--font-title); font-size: 22px; margin: 0 4px 8px; }
.profile .psec h3 canvas { width: 32px; height: 32px; flex: none; }
.ptable { width: 100%; border-collapse: collapse; background: var(--white); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.ptable th, .ptable td { padding: 6px 12px; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.ptable th:first-child { text-align: left; font-weight: 600; }
.ptable thead th { font-family: var(--font-title); font-size: 15px; background: var(--sky); }
.ptable tbody tr + tr th, .ptable tbody tr + tr td { border-top: 2px solid var(--sky-2); }
.subscore small { display: block; font-size: 13px; color: #3A3860; }
/* head to head (a friend's result next to yours) */
.versus { margin: 18px 4px 4px; padding: 10px 10px 12px; background: var(--white); text-align: left; box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.versus h3 { font-size: 18px; text-align: center; margin-bottom: 6px; }
.vrow { display: grid; grid-template-columns: 1fr 64px 64px; gap: 6px; align-items: center; padding: 3px 2px; font-size: 16px; }
.vrow b { text-align: center; font-size: 18px; padding: 1px 0; }
.vrow b.win { background: var(--mint); }
.vhead b { font-size: 14px; }
.vtotal { margin-top: 6px; padding-top: 8px; border-top: 3px solid var(--ink); }
.vverdict { text-align: center; margin-top: 10px; font-size: 20px; font-weight: 600; }
.subscore span { font-size: 15px; }

.feedback { margin: 4px 4px 14px; padding: 12px 16px; }
.feedback .big { margin-bottom: 4px; }

footer.foot { margin-top: 36px; font-size: 15px; color: #2D2B55; text-align: center; }
footer.foot .ver { margin-top: 6px; font-size: 12px; opacity: .55; letter-spacing: .04em; }


/* ---------- hearts, hud, verdict, titles ---------- */
.hearts { display: flex; align-items: center; gap: 6px; }
.heart { width: 32px; height: 28px; }
.heart.lose { animation: heart-pop 420ms var(--ease-out); }
@keyframes heart-pop { 0% { transform: scale(1.6) rotate(-12deg); } 40% { transform: scale(0.8) rotate(8deg); } 100% { transform: none; } }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 8px; min-height: 36px; }
.hud-note { font-weight: 700; font-size: 16px; text-align: right; }
.hud-score { font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.hud-chip { padding: 2px 10px; background: var(--white); font-weight: 700; font-size: 18px; box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.hud-chip.hot { background: var(--sun); }
.hud-chip.pop { animation: chip-pop 380ms var(--ease-out); }
@keyframes chip-pop { 0% { transform: scale(1.5); } 100% { transform: none; } }

.verdict { display: flex; align-items: center; gap: 14px; }
.face { width: 56px; height: 32px; flex: none; }
.say { font-size: 18px; font-weight: 600; margin: 2px 0 4px; }
.result > .face { display: block; width: 84px; height: 48px; margin: 6px auto 0; }
.title { font-family: var(--font-title); font-size: 26px; line-height: 1.1; font-weight: 700; margin: 2px 0 6px; }

.burst { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; display: grid; place-items: center; }
.burst b { font-family: var(--font-body); font-weight: 700; font-size: clamp(44px, 15vw, 104px); line-height: 1; letter-spacing: 1px; color: var(--sun); text-shadow: 5px 5px 0 var(--ink), -4px -4px 0 var(--ink), 4px -4px 0 var(--ink), -4px 4px 0 var(--ink), 0 6px 0 var(--ink), 0 -5px 0 var(--ink); transform: translate(var(--bx, 0px), var(--by, 0px)) rotate(-9deg); animation: burst-pop 1.5s var(--ease-out) both; }
@keyframes burst-pop {   /* tilted at about 9 degrees; --bx and --by move it next to the title card */
  0% { transform: translate(var(--bx, 0px), var(--by, 0px)) scale(0.3) rotate(-26deg); opacity: 0; }
  16% { transform: translate(var(--bx, 0px), var(--by, 0px)) scale(1.18) rotate(-6deg); opacity: 1; }
  28% { transform: translate(var(--bx, 0px), var(--by, 0px)) scale(1) rotate(-9deg); }
  78% { opacity: 1; }
  100% { transform: translate(var(--bx, 0px), var(--by, 0px)) scale(1.06) rotate(-9deg); opacity: 0; }
}
.burst i { position: absolute; top: -24px; left: var(--x); width: var(--s); height: var(--s); background: var(--c); box-shadow: 0 0 0 2px var(--ink); animation: confetti var(--d) cubic-bezier(.2, .6, .4, 1) forwards; }
@keyframes confetti { to { transform: translate(var(--dx), 110vh) rotate(260deg); } }

/* glimpse: tap the change */
.scene-wrap.tappable { cursor: crosshair; touch-action: manipulation; }
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; box-sizing: border-box; border: 3px solid var(--mint); }
.mark.x { border-color: var(--coral); border-width: 0; }
.mark.x::before, .mark.x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 150%; height: 4px; min-width: 22px; background: var(--coral); box-shadow: 0 0 0 2px var(--ink); transform: translate(-50%, -50%) rotate(45deg); }
.mark.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.hotspot { position: absolute; padding: 0; border: 0; background: transparent; pointer-events: none; }
.hotspot:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

/* shortcut: memory round */
.dot.hid::before { opacity: 0; }
.board.recall { cursor: crosshair; }
.board.recall .dot.hid { pointer-events: none; }
.board .cover { z-index: 3; }
.dot.hit::before { background: var(--mint); }
.dot.miss::before { background: var(--coral); }

/* ---------- results: the eye, rolling number, rarity title card, collection ---------- */
.result > .result-eye { display: block; width: min(240px, 66%); height: auto; margin: 2px auto 0; }
.result-eye.pop { animation: eye-pop 460ms var(--ease-out); }
@keyframes eye-pop { 0% { transform: scale(1); } 35% { transform: scale(1.14); } 100% { transform: scale(1); } }
.bignum .num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.result.shake { animation: shake 400ms steps(2, end); }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-7px, 3px); } 40% { transform: translate(6px, -4px); } 60% { transform: translate(-5px, -2px); } 80% { transform: translate(4px, 3px); } }

.tear { position: fixed; z-index: 55; pointer-events: none; transform-origin: 50% 0; animation: tear-fall 2.1s linear forwards; }
@keyframes tear-fall {
  0% { transform: translateY(0) scale(0.3); animation-timing-function: ease-out; }
  16% { transform: translateY(0) scale(1); animation-timing-function: cubic-bezier(0.5, 0, 1, 0.6); }   /* it hangs a moment, then falls faster and faster */
  100% { transform: translateY(var(--fall)) scale(1); }
}

/* rarity: 0 Common, 1 Uncommon, 2 Rare, 3 Epic, 4 Legendary */
.r0 { --rc: #D5D9EC; --halo: transparent; }
.r1 { --rc: var(--mint); --halo: transparent; }
.r2 { --rc: var(--sea); --halo: transparent; }
.r3 { --rc: var(--violet); --halo: rgba(142, 115, 255, 0.5); }
.r4 { --rc: var(--sun); --halo: rgba(255, 200, 61, 0.65); }
.tcard, .ttile, .newtitle { --edge: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
.tcard { position: relative; display: inline-grid; justify-items: center; gap: 2px; margin: 8px 0 10px; padding: 8px 22px 10px; background: var(--rc); box-shadow: var(--edge), 0 0 0 7px var(--halo); }
.tcard .tname { font-family: var(--font-title); font-size: 28px; line-height: 1.1; font-weight: 700; }
.tcard .trar { font-size: 15px; font-weight: 700; }
.tcard.pre { visibility: hidden; }
.tcard.stamp { animation: stamp 520ms var(--ease-out) both; }
.tcard.r3.stamp, .tcard.r4.stamp { animation: stamp 520ms var(--ease-out) both, halo 1.2s steps(2, end) 520ms infinite; }
.tcard.r3.live, .tcard.r4.live { animation: halo 1.2s steps(2, end) infinite; }
@keyframes stamp { 0% { transform: scale(2.4) rotate(-8deg); opacity: 0; } 55% { transform: scale(0.92) rotate(1deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes halo { 0% { box-shadow: var(--edge), 0 0 0 5px var(--halo); } 50% { box-shadow: var(--edge), 0 0 0 11px var(--halo); } 100% { box-shadow: var(--edge), 0 0 0 5px var(--halo); } }
.tcard.r4::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.75) 50%, transparent 58%); background-size: 260% 100%; background-position: 160% 0; animation: shine 2.4s steps(14, end) 800ms infinite; }
@keyframes shine { to { background-position: -60% 0; } }

.newtitle { display: block; margin: 0 auto 10px; padding: 4px 14px; border: 0; font: inherit; font-weight: 600; color: var(--ink); background: var(--coral); box-shadow: var(--edge); cursor: pointer; }
.newtitle.pre { visibility: hidden; }
.newtitle.in { animation: chip-pop 420ms var(--ease-out); }
.chip-btn { border: 0; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.chip-btn:active { transform: translateY(2px); }

.titles .tsec { margin: 22px 0 0; text-align: left; }
.titles .tsec h3 { font-family: var(--font-title); font-size: 22px; margin: 0 4px 8px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 0 4px; }
.ttile { padding: 8px 10px 9px; text-align: center; background: var(--rc); box-shadow: var(--edge); }
.ttile b { display: block; font-family: var(--font-title); font-size: 19px; line-height: 1.15; }
.ttile span { display: block; font-size: 14px; font-weight: 700; }
.ttile .tsub { font-weight: 500; color: #2D2B55; }
.ttile.locked { background: repeating-linear-gradient(45deg, #E6EBF8 0 8px, #D8DFF2 8px 16px); box-shadow: var(--edge), inset 0 7px 0 0 var(--rc); padding-top: 14px; color: #3A3860; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); background: var(--ink); color: var(--white); padding: 10px 18px; font-weight: 600; opacity: 0; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); z-index: 50; pointer-events: none; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn, .flag-btn, .dot::before, .toast { transition-property: opacity, background-color; }
  .btn:active, .flag-btn:active { transform: none; }
  .toast { transform: translate(-50%, 0); }
  .tcard, .tcard::after, .result-eye, .result.shake, .newtitle, .tear { animation: none !important; }
}
