/* Ryftkeep — Valyd design language: deep violet night, glass panels, mono system labels. */
:root {
  --bg: #0a0715;
  --bg-glow: #170f2e;
  --panel: #1e12388c;
  --panel-solid: #160e2b;
  --panel-border: #a855f740;
  --line: #2c2347;
  --line-soft: #241a3f;
  --accent: #a855f7;
  --accent-bright: #d9b8ff;
  --accent-dim: #5b3a8f;
  --text: #ece6f7;
  --muted: #8779a8;
  --faint: #453a68;
  --good: #3fbf7f;
  --bad: #ef4b5c;
  --warn: #f2c94c;
  --sans: "Manrope", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
  --r: 16px;
  --r-sm: 10px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0a0715; } }
:root[data-theme="dark"] { --bg: #0a0715; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -200px, var(--bg-glow), transparent 70%),
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
  background-attachment: fixed;
  color: var(--text);
  font: 500 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body::before { /* fade the grid out toward the bottom like valyd.ca */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(transparent 0, var(--bg) 70%);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.ic { width: 22px; height: 22px; flex: none; }
.sr { position: absolute; left: -9999px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono, .label { font-family: var(--mono); }
.label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.accent { color: var(--accent-bright); }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent-bright)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- shell ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.sys { margin-left: auto; font: 500 10px var(--mono); letter-spacing: .18em; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sys::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.iconbtn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--muted); border: 1px solid transparent; background: none; cursor: pointer; }
.iconbtn:hover, .iconbtn:focus-visible { color: var(--text); border-color: var(--panel-border); }
#view { flex: 1; padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 980px; width: 100%; margin: 0 auto; outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; color: var(--muted); font: 500 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.tabbar a.on { color: var(--accent-bright); }
.tabbar a.on .ic { filter: drop-shadow(0 0 8px var(--accent)); }
.scan-orb { display: grid; place-items: center; width: 54px; height: 54px; margin-top: -26px; border-radius: 18px; color: #fff;
  background: linear-gradient(145deg, var(--accent), #6d28d9); box-shadow: 0 8px 28px -6px var(--accent), inset 0 1px 0 #ffffff40; }
.scan-orb .ic { width: 26px; height: 26px; }
body.immersive .tabbar, body.immersive .topbar { display: none; }
body.immersive #view { padding: 0; max-width: none; }

/* ---------- primitives ---------- */
.panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--r); padding: 16px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.panel.flat { background: var(--panel-solid); }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 22px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; } .row.gap-s { gap: 6px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 26px 0 10px; }
.section-h a { font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-bright); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform .1s, border-color .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(145deg, var(--accent), #7c3aed); border-color: transparent; color: #fff; box-shadow: 0 6px 22px -8px var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: #ef4b5c22; border-color: #ef4b5c66; color: #ffb3bc; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.tiny { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d0920; color: var(--text); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #a855f726; }
textarea.input { font: 13px/1.6 var(--mono); resize: vertical; min-height: 180px; }
.search { position: relative; }
.search .ic { position: absolute; left: 13px; top: 50%; translate: 0 -50%; color: var(--muted); width: 18px; height: 18px; }
.search .input { padding-left: 40px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 4px; margin: 0 -16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #0d0920; color: var(--muted); font: 500 12px var(--mono); letter-spacing: .04em; cursor: pointer; white-space: nowrap; }
.chip.on { color: var(--text); border-color: var(--accent); background: #a855f71f; }
.chip select { field-sizing: content; max-width: 46vw; text-overflow: ellipsis; background: transparent; border: 0; color: inherit; font: inherit; outline: none; appearance: none; -webkit-appearance: none; padding-right: 2px; }
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 14px; background: #0d0920; border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--panel-border); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #0a071599, 0 0 8px color-mix(in srgb, var(--c) 60%, transparent); }
.dot + .dot { margin-left: -3px; }
.pip { display: inline-block; width: 8px; height: 8px; transform: rotate(45deg); background: var(--c); border-radius: 1px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font: 600 11px var(--mono); background: #a855f726; color: var(--accent-bright); }
.badge.good { background: #3fbf7f22; color: #8fe6b8; }
.badge.bad { background: #ef4b5c22; color: #ffb3bc; }
.badge.warn { background: #f2c94c22; color: #f7dd8a; }

.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--accent-dim), var(--accent), var(--accent-bright)); box-shadow: 0 0 12px var(--accent); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 18px 0 6px; }
.hero h1 { font-size: clamp(30px, 8vw, 44px); }
.hero p { margin-top: 8px; font: 13px/1.6 var(--mono); color: var(--muted); }
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border); }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat .label { font-size: 10px; letter-spacing: .14em; }
.scan-cta { position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 20px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #c084fc 0%, #7c3aed 45%, #2e1065 100%); box-shadow: 0 18px 40px -18px var(--accent); }
.scan-cta::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, #ffffff30 45%, transparent 60%); transform: translateX(-100%); animation: sheen 3.6s infinite; }
@keyframes sheen { 60%, 100% { transform: translateX(100%); } }
.scan-cta .orb { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: #ffffff24; border: 1px solid #ffffff40; }
.scan-cta .orb .ic { width: 28px; height: 28px; }
.scan-cta h2 { font-size: 19px; }
.scan-cta p { font: 12px var(--mono); opacity: .85; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--panel-border); min-height: 92px; }
.tile .ic { color: var(--accent-bright); }
.tile b { font-size: 14px; }
.tile small { font: 10px var(--mono); color: var(--muted); letter-spacing: .06em; }
.setrow { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.setrow:last-child { border-bottom: 0; }
.setrow .bar { grid-column: 1 / -1; }
.strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.strip::-webkit-scrollbar { display: none; }
.strip .art { width: 74px; flex: none; }

/* ---------- cards ---------- */
.art { width: 100%; aspect-ratio: 744 / 1039; object-fit: cover; border-radius: 4.5% / 3.2%; background: linear-gradient(160deg, #1f1538, #120b24); box-shadow: 0 6px 16px -8px #000; }
.art.land { aspect-ratio: 744 / 1039; object-fit: contain; }
.art.missing { display: grid; place-items: center; color: var(--faint); font: 800 28px var(--sans); border: 1px dashed var(--line); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cell { position: relative; }
.cell button.open { all: unset; display: block; width: 100%; cursor: pointer; border-radius: 6px; }
.cell button.open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell.unowned .art { filter: saturate(.25) brightness(.55); }
.cell .own { position: absolute; top: 6px; right: 6px; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 8px; background: #0a0715d9; border: 1px solid var(--accent); color: var(--accent-bright); font: 700 11px/20px var(--mono); text-align: center; }
.cell .foil-tag { position: absolute; top: 6px; left: 6px; font: 700 9px/18px var(--mono); padding: 0 5px; border-radius: 6px; color: #0a0715; background: linear-gradient(90deg, #f0abfc, #93c5fd, #fde68a); }
.cell .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; min-height: 18px; }
.cell .meta .nm { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; border-radius: 10px; border: 1px solid var(--line); background: #0d0920; }
.stepper button { width: 34px; height: 30px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; }
.stepper button:active { color: var(--accent-bright); }
.stepper .ic { width: 16px; height: 16px; }
.stepper b { font: 700 13px var(--mono); }
.stepper.big button { width: 48px; height: 44px; }
.stepper.big b { font-size: 18px; }
.more { display: grid; place-items: center; padding: 24px; color: var(--muted); font: 12px var(--mono); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; }
.scrim { position: absolute; inset: 0; background: #05030ccc; opacity: 0; transition: opacity .25s; backdrop-filter: blur(3px); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; overscroll-behavior: contain;
  background: linear-gradient(#1a1031, #0f0a1f); border: 1px solid var(--panel-border); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 6px 18px calc(22px + var(--safe-b)); transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .9, .3, 1); max-width: 640px; margin: 0 auto; }
.sheet.tall { height: 92vh; max-height: none; }
.sheet-wrap.open .scrim { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.grab { width: 100%; height: 22px; display: grid; place-items: center; cursor: grab; position: sticky; top: -6px; z-index: 2; }
.grab::before { content: ""; width: 42px; height: 5px; border-radius: 99px; background: var(--faint); }
.sheet-body > * + * { margin-top: 14px; }
.detail-art { width: min(78%, 340px); margin: 0 auto; }
.detail-art .art { box-shadow: 0 24px 60px -20px var(--accent); }
.detail-art.land { width: 100%; }
.detail-art.land .art { aspect-ratio: 1039 / 744; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv div { padding: 10px; border-radius: 12px; background: #0d0920; border: 1px solid var(--line); text-align: center; }
.kv b { display: block; font-size: 18px; font-weight: 800; }
.rules { font-size: 14px; line-height: 1.55; padding: 12px 14px; border-radius: 12px; background: #0d0920; border: 1px solid var(--line); }
.sym { display: inline-grid; place-items: center; vertical-align: -3px; width: 18px; height: 18px; margin: 0 1px; border-radius: 50%; font: 800 11px var(--sans); }
.sym.en { background: #ece6f7; color: #0a0715; }
.sym.rune { width: 14px; height: 14px; transform: rotate(45deg); border-radius: 3px; background: var(--c); vertical-align: -2px; }
.sym.rune.rainbow { background: conic-gradient(#ef4b5c, #f2c94c, #3fbf7f, #3b9cff, #b066ff, #ef4b5c); }
.sym.might, .sym.ex { background: #ffffff1a; color: var(--accent-bright); }
.kw { font: 700 11px var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 5px; background: #a855f733; color: var(--accent-bright); }
.prints { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.prints button { all: unset; cursor: pointer; width: 64px; flex: none; text-align: center; font: 9px var(--mono); color: var(--muted); }
.prints button.on .art { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- decks ---------- */
.deck-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--panel-border); }
.deck-card .art { width: 56px; flex: none; }
.deck-card h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-sec { margin-top: 18px; }
.dl-sec > .row { margin-bottom: 6px; }
.dl-line { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line-soft); }
.dl-line .art { width: 34px; flex: none; border-radius: 3px; }
.dl-line .q { font: 700 13px var(--mono); color: var(--accent-bright); min-width: 22px; }
.dl-line .nm { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-line .cost { font: 600 11px var(--mono); color: var(--muted); }
.dl-line .ctl { display: flex; gap: 2px; }
.dl-line .ctl button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #0d0920; color: var(--muted); cursor: pointer; }
.dl-line .ctl .ic { width: 14px; height: 14px; }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); align-items: end; gap: 6px; height: 130px; padding-top: 18px; }
.curve div { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.curve i { display: block; height: var(--h); min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(var(--accent-bright), var(--accent-dim)); }
.curve span { position: absolute; top: 0; left: 0; right: 0; text-align: center; font: 600 11px var(--mono); color: var(--accent-bright); transform: translateY(calc(var(--top) * -1)); }
.curve-x { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 6px; text-align: center; font: 11px var(--mono); color: var(--muted); }
.split { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; }
.split i { background: var(--c); flex: var(--f); }
.legend-list { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 12px var(--mono); color: var(--muted); margin-top: 8px; }
.err { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: #ef4b5c14; border: 1px solid #ef4b5c44; color: #ffc2c9; }
.ok { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: #3fbf7f14; border: 1px solid #3fbf7f44; color: #a7efc8; }
.warnbox { padding: 10px 12px; border-radius: 12px; font-size: 13px; background: #f2c94c12; border: 1px solid #f2c94c40; color: #f7dd8a; }
.err ul, .warnbox ul { margin: 6px 0 0; padding-left: 18px; }
.hand { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.result-row .art { width: 44px; flex: none; }
.result-row button.add { margin-left: auto; }

/* ---------- scanner ---------- */
.scanner { position: fixed; inset: 0; background: #000; z-index: 50; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .shade { position: absolute; inset: 0; pointer-events: none; }
.guide { position: absolute; left: 50%; top: 43%; translate: -50% -50%; width: min(70vw, calc(56vh * 63 / 88)); aspect-ratio: 63 / 88; border-radius: 4.5% / 3.2%;
  box-shadow: 0 0 0 200vmax #05030c99; transition: box-shadow .2s; }
.guide::before, .guide::after { content: ""; position: absolute; inset: -3px; border-radius: inherit; pointer-events: none; }
.guide::before { border: 2px solid #ffffff30; }
.guide::after { border: 3px solid var(--accent); clip-path: polygon(0 0, 22% 0, 22% 3px, 3px 3px, 3px 16%, 0 16%, 0 84%, 3px 84%, 3px calc(100% - 3px), 22% calc(100% - 3px), 22% 100%, 78% 100%, 78% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 84%, 100% 84%, 100% 16%, calc(100% - 3px) 16%, calc(100% - 3px) 3px, 78% 3px, 78% 0, 100% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 0 8px var(--accent)); }
.guide .laser { position: absolute; left: 6%; right: 6%; height: 2px; top: 10%; background: linear-gradient(90deg, transparent, var(--accent-bright), transparent); box-shadow: 0 0 12px var(--accent); animation: laser 2.2s ease-in-out infinite; }
@keyframes laser { 50% { top: 88%; } }
.guide.steady::after { border-color: var(--accent-bright); }
.guide.hit::after { border-color: var(--good); filter: drop-shadow(0 0 16px var(--good)); }
.guide.hit { animation: hit .45s; }
@keyframes hit { 30% { scale: 1.04; } }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .35s; }
@keyframes flash { 10% { opacity: .35; } }
.scan-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(12px + var(--safe-t)) 14px 0; display: flex; align-items: center; gap: 8px; }
.glass { background: #0a0715b8; border: 1px solid #ffffff1f; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.scan-top .iconbtn { color: #fff; }
.scan-top .iconbtn.on { color: var(--warn); border-color: var(--warn); }
.status-pill { margin: 0 auto; padding: 8px 14px; border-radius: 999px; font: 600 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-pill.search i { background: var(--accent); animation: pulse 1s infinite; }
.status-pill.steady i { background: var(--warn); }
.status-pill.hit i { background: var(--good); }
.scan-count { position: absolute; top: calc(64px + var(--safe-t)); left: 50%; translate: -50% 0; font: 700 12px var(--mono); padding: 5px 12px; border-radius: 999px; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px calc(14px + var(--safe-b)); }
.last { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 18px; min-height: 92px; }
.last .art { width: 54px; flex: none; }
.last.pop { animation: pop .4s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: translateY(16px) scale(.96); opacity: .3; } }
.last .vars { display: flex; gap: 6px; overflow-x: auto; margin-top: 6px; scrollbar-width: none; }
.last .vars button { flex: none; font: 600 10px var(--mono); padding: 4px 8px; border-radius: 8px; border: 1px solid #ffffff26; background: #ffffff10; color: #ddd; cursor: pointer; }
.last .vars button.on { border-color: var(--accent); color: #fff; background: #a855f740; }
.scan-actions { display: flex; gap: 8px; margin-top: 10px; }
.scan-actions .btn { flex: 1; min-height: 46px; }
.camera-off { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 30%, #241446, #0a0715); }

/* ---------- play / tracker ---------- */
.tracker { position: fixed; inset: 0; z-index: 50; display: grid; background: #000; gap: 3px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.tracker.p2 { grid-template-rows: 1fr 1fr; }
.tracker.p3 { grid-template-rows: 1fr 1fr; grid-template-columns: 1fr 1fr; }
.tracker.p3 .pl:first-child { grid-column: 1 / -1; }
.tracker.p4 { grid-template-rows: 1fr 1fr; grid-template-columns: 1fr 1fr; }
.pl { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 50%, color-mix(in srgb, var(--c) 38%, #0a0715), #0a0715 75%); }
.pl.flip { transform: rotate(180deg); }
.pl button.zone { all: unset; height: 100%; display: grid; place-items: center; cursor: pointer; color: #ffffff55; font: 300 44px var(--sans); }
.pl button.zone:active { background: #ffffff10; color: #fff; }
.pl .score { text-align: center; pointer-events: none; }
.pl .score b { display: block; font: 800 clamp(72px, 22vmin, 160px)/1 var(--sans); letter-spacing: -.04em; text-shadow: 0 0 40px color-mix(in srgb, var(--c) 70%, transparent); }
.pl .score small { font: 600 11px var(--mono); letter-spacing: .2em; text-transform: uppercase; color: #ffffffaa; }
.pl .pname { all: unset; position: absolute; bottom: calc(34px + var(--safe-b)); left: 50%; translate: -50% 0; font: 700 13px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #fff; padding: 4px 10px; border-radius: 99px; background: #00000040; cursor: pointer; }
.pl .pips { position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; translate: -50% 0; display: flex; gap: 5px; }
.pl .pips i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #ffffff60; }
.pl .pips i.on { background: var(--c); border-color: var(--c); box-shadow: 0 0 8px var(--c); }
.pl.won::after { content: "VICTORY"; position: absolute; inset: 22% 0 auto; text-align: center; font: 800 13px var(--mono); letter-spacing: .5em; color: var(--warn); text-shadow: 0 0 12px var(--warn); }
.tracker .hub { position: fixed; left: 50%; top: 50%; translate: -50% -50%; z-index: 3; display: flex; gap: 8px; padding: 6px; border-radius: 18px; }
.tracker.p3 .hub, .tracker.p4 .hub { top: 50%; }
.hub button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 0; background: #ffffff12; color: #fff; cursor: pointer; }
.hub button:active { background: var(--accent); }
.roll { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: #05030cd0; backdrop-filter: blur(6px); }
.roll .die { font: 800 120px var(--sans); color: var(--accent-bright); text-shadow: 0 0 40px var(--accent); animation: spin .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes spin { from { transform: rotate(-200deg) scale(.4); opacity: 0; } }
.wl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wl button { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: #0d0920; font: 800 18px var(--sans); cursor: pointer; }
.wl button.on[data-r=W] { border-color: var(--good); background: #3fbf7f22; color: #8fe6b8; }
.wl button.on[data-r=L] { border-color: var(--bad); background: #ef4b5c22; color: #ffb3bc; }
.wl button.on[data-r=D] { border-color: var(--warn); background: #f2c94c1a; color: #f7dd8a; }
.round { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.round .r { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; font: 800 13px var(--mono); }
.round .r.W { background: #3fbf7f22; color: #8fe6b8; } .round .r.L { background: #ef4b5c22; color: #ffb3bc; } .round .r.D { background: #f2c94c1a; color: #f7dd8a; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b) + 40px); z-index: 100; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; padding: 10px 14px; border-radius: 14px; background: #1e1238f2; border: 1px solid var(--panel-border); font-size: 14px; box-shadow: 0 12px 30px -10px #000; animation: pop .3s; transition: opacity .35s, transform .35s; }
.toast.out { opacity: 0; transform: translateY(8px); }
body.immersive #toasts { bottom: calc(150px + var(--safe-b)); }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .statrow { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
