:root {
  --page: #0b0b0c; --surface: #171718; --surface-2: #212123; --line: #2e2e31; --ink: #fff; --ink-2: #c6c5bf; --muted: #8d8c86;
  --accent: #3987e5; --gold: #ffd23f; --good: #0ca30c; --warn: #fab219; --bad: #d03b3b; --r: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 17px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
.view { max-width: 620px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
h1 { font-size: 2rem; line-height: 1.1; margin: .3rem 0 .5rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .centre { text-align: center; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: .45rem; color: var(--ink-2); }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.25); }
.lead { color: var(--ink-2); }
.back { display: inline-flex; min-height: 44px; align-items: center; color: var(--ink-2); text-decoration: none; }

/* buttons */
.big-btn { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 62px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 1.1rem; font-weight: 800; cursor: pointer; text-decoration: none; padding: .6rem 1rem; }
.big-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-btn.stop { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); text-decoration: none; padding: 0 1.1rem; font-weight: 700; cursor: pointer; }
.link { background: none; border: 0; color: var(--accent); padding: .4rem 0; min-height: 44px; cursor: pointer; }
.begin-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: .6rem; min-height: 72px; margin-top: .9rem; border: 0; border-radius: 999px; background: linear-gradient(135deg, #4b9bff, #2f6fd0); color: #fff; font-size: 1.35rem; font-weight: 900; cursor: pointer; box-shadow: 0 10px 34px rgba(57,135,229,.45); }
@media (prefers-reduced-motion: no-preference) { .begin-btn { animation: pulse 2.6s ease-in-out infinite; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 10px 34px rgba(57,135,229,.45); } 50% { box-shadow: 0 10px 46px rgba(57,135,229,.78); } }
.row-btns { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

/* camera */
.stage { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3; margin-top: 1rem; }
.stage.big { aspect-ratio: 9 / 16; max-height: 72vh; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage.big video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.stage video.mirror { transform: scaleX(-1); }
.stage canvas { width: 100%; height: 100%; object-fit: contain; }
.cam-off { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; background: var(--surface-2); }
.cam-off .big-btn { width: 100%; max-width: 300px; }
.count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 8rem; font-weight: 900; text-shadow: 0 4px 24px rgba(0,0,0,.8); }
.flip-pill { position: absolute; right: 10px; bottom: 10px; z-index: 3; display: inline-flex; align-items: center; gap: .45rem; min-height: 46px; padding: 0 1rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.62); color: #fff; font-weight: 800; font-size: .95rem; cursor: pointer; }
.live-badge { position: absolute; left: 10px; top: 10px; z-index: 3; display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .75rem; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; pointer-events: none; }
.dot-live { width: 9px; height: 9px; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 0 4px rgba(255,77,77,.25); }
@media (prefers-reduced-motion: no-preference) { .dot-live { animation: live 1.6s ease-in-out infinite; } }
@keyframes live { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.status { min-height: 1.5em; text-align: center; font-weight: 700; margin: .8rem 0; }
.run-actions { display: grid; gap: .6rem; }

/* board link on the home screen */
.board-link { display: grid; grid-template-columns: 46px 1fr auto; gap: .8rem; align-items: center; margin-top: 1.2rem; padding: .85rem 1rem; border-radius: var(--r); text-decoration: none; color: var(--ink); background: linear-gradient(135deg, rgba(255,210,63,.18), rgba(255,210,63,.04)); border: 1px solid rgba(255,210,63,.5); }
.board-link .crown { font-size: 2rem; } .board-link b { display: block; color: var(--gold); } .board-link > span:last-child { font-size: 1.5rem; color: var(--gold); }
.board-link span span { display: block; }

.tips { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem 1rem; margin-top: 1rem; }
.tips summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.tips ol { margin: .5rem 0 .2rem; padding-left: 1.2rem; display: grid; gap: .3rem; color: var(--ink-2); }

/* my sets */
.sets { display: grid; gap: .5rem; }
.set-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; text-decoration: none; color: var(--ink); }
.set-row .big { font-size: 1.2rem; font-weight: 800; } .set-row .sub { color: var(--muted); font-size: .85rem; }
.badge { min-width: 48px; text-align: center; font-weight: 800; border-radius: 999px; padding: .2rem .6rem; border: 2px solid; grid-row: span 2; }
.b-good { color: #7ee07e; border-color: var(--good); } .b-warn { color: var(--warn); border-color: var(--warn); } .b-bad { color: #ff8a8a; border-color: var(--bad); } .b-none { color: var(--muted); border-color: var(--line); }
.empty { text-align: center; color: var(--muted); padding: 1.4rem 0; }

/* result */
.verdict { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; align-items: center; margin-top: .4rem; }
.verdict .num { font-size: 3.6rem; font-weight: 900; line-height: 1; color: var(--gold); }
.verdict .lbl { color: var(--ink-2); font-weight: 700; }
.score-ring { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 900; border: 6px solid; grid-row: span 2; }
.reps { display: grid; gap: .45rem; margin-top: .8rem; }
.rep { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .2rem .6rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; }
.rep .n { font-weight: 900; font-size: 1.1rem; color: var(--ink-2); }
.rep .sb { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.rep .sb i { display: block; height: 100%; border-radius: 5px; }
.rep .sc { font-weight: 800; min-width: 2.5rem; text-align: right; }
.rep .why { grid-column: 2 / 4; color: var(--ink-2); font-size: .88rem; }
.coach { margin-top: .9rem; border-radius: var(--r); padding: .9rem 1rem; background: rgba(57,135,229,.12); border: 1px solid rgba(57,135,229,.55); }
.coach b { display: block; margin-bottom: .2rem; }
.post-box { margin-top: 1.1rem; display: grid; gap: .6rem; background: linear-gradient(135deg, rgba(255,210,63,.14), rgba(255,210,63,.03)); border: 1px solid rgba(255,210,63,.5); border-radius: var(--r); padding: 1rem; }
.post-box b { font-size: 1.1rem; }
.post-box label { display: grid; gap: .25rem; font-weight: 700; color: var(--ink-2); font-size: .9rem; }
.post-box input { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.posted-box { margin-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; border: 1px solid rgba(12,163,12,.5); background: rgba(12,163,12,.1); border-radius: var(--r); padding: .9rem 1rem; font-weight: 700; }

/* board */
.b-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.first 
.foot { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; border-top: 1px solid var(--line); padding-top: 1rem; }
.foot select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; min-height: 44px; }
.foot p { width: 100%; margin: 0; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); text-align: center; background: var(--surface-2); border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 16px; z-index: 50; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* faces on the board and in the post form */
.first .champ-banner .face-pick { display: flex; gap: .9rem; align-items: center; }
.face-shot { width: 86px; height: 86px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #3a3630; border: 3px solid var(--gold); flex: none; }
.face-shot img { width: 100%; height: 100%; object-fit: cover; }
.face-shot .ph { font-size: 2.2rem; font-weight: 900; color: var(--gold); }
.file-btn { cursor: pointer; }
#boardBox { margin-top: 1.2rem; }

/* ---------------------------------------------------------------- arcade fighter cards (original art, CSS only) */
.b-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.fighter { position: relative; background: linear-gradient(160deg, #23242a 0%, #15161a 55%, #101114 100%); border: 1px solid #3a3d46; border-radius: 4px; padding: .7rem .8rem;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); }
.fighter::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.045) 0 1px, transparent 1px 3px); }
.fighter.row { display: grid; grid-template-columns: 2.1rem 56px 1fr auto; gap: .7rem; align-items: center; min-height: 72px; }
.fighter.row.open { opacity: .45; border-style: dashed; background: none; }
.fighter.me { outline: 2px solid var(--accent); outline-offset: -2px; }
.fighter.row.first { border-color: var(--gold); background: linear-gradient(160deg, #3a3222 0%, #1d1a14 60%, #121113 100%); }
.b-rank { font-weight: 900; font-size: 1.25rem; text-align: center; color: #8c8f99; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.first .b-rank, .champ .b-rank { color: var(--gold); }
.b-main { display: grid; min-width: 0; gap: .1rem; }
.b-main b { font-size: 1.05rem; letter-spacing: .01em; }
.b-ev { color: var(--ink-2); font-size: .85rem; }

/* the portrait: duotone + posterised, so a selfie reads as a fighter portrait */
.b-face { position: relative; display: inline-grid; place-items: center; overflow: hidden; flex: none;
  border: 2px solid #5a5e69; border-radius: 3px; background: #2a2d34; color: var(--gold); font-weight: 900;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.b-face img { width: 100%; height: 100%; object-fit: cover; display: block; filter: contrast(1.45) saturate(.45) brightness(1.03); }
.b-face::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,210,63,.42), rgba(217,89,38,.42) 60%, rgba(40,60,120,.38)); mix-blend-mode: color; }
.b-face.ph::after { display: none; }
.b-face.empty { border-style: dashed; border-color: var(--line); background: none; }
.first .b-face, .champ .b-face { border-color: var(--gold); }

/* champion card */
.fighter.champ { margin: 1rem 0 .9rem; padding: 1.1rem 1rem .9rem; border: 2px solid var(--gold);
  background: radial-gradient(ellipse at 20% 0%, #4a3a12 0%, #241d10 45%, #121113 100%);
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px); }
.fighter.champ .plate { position: absolute; top: -1px; right: -1px; background: var(--gold); color: #17140a; font-weight: 900; font-size: .72rem;
  letter-spacing: .22em; padding: .3rem .7rem; clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%); }
.f-top { display: flex; gap: .9rem; align-items: center; }
.f-id { min-width: 0; }
.f-name { font-size: 1.6rem; font-weight: 900; line-height: 1.05; }
.f-title { color: var(--gold); font-weight: 900; letter-spacing: .14em; font-size: .82rem; text-transform: uppercase; }
.f-title.small { font-size: .7rem; letter-spacing: .1em; }
.f-sub { color: var(--ink-2); font-size: .85rem; margin-top: .15rem; }
@media (prefers-reduced-motion: no-preference) {
  .fighter.champ { animation: champGlow 3.2s ease-in-out infinite; }
  @keyframes champGlow { 0%, 100% { box-shadow: 0 0 0 rgba(255,210,63,0), inset 0 0 20px rgba(255,210,63,.08); } 50% { box-shadow: 0 0 26px rgba(255,160,40,.4), inset 0 0 26px rgba(255,160,40,.16); } }
}

/* stat bars */
.fighter .stats { display: grid; gap: .35rem; margin-top: .8rem; }
.fighter .stat { display: grid; grid-template-columns: 4.6rem 1fr 2.4rem; gap: .55rem; align-items: center; }
.fighter .stat .k { font-size: .68rem; font-weight: 900; letter-spacing: .14em; color: #9a9ca4; }
.fighter .stat .v { font-weight: 900; font-size: .9rem; text-align: right; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.fighter .stat .bar { height: 12px; background: #000; border: 1px solid #40434c; overflow: hidden; }
.fighter .stat .bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--gold) 0 7px, #c98c00 7px 9px); }
.fighter.row .stats { display: none; }

/* unhatched fighter: no photo posted yet */
.b-face.egg-face { background: radial-gradient(ellipse at 50% 35%, #2f3138 0%, #17181c 70%); border-style: solid; display: grid; place-items: center; }
.b-face.egg-face .egg { width: 62%; height: 62%; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); transform-origin: 50% 85%; }
@media (prefers-reduced-motion: no-preference) {
  .b-face.egg-face .egg { animation: eggWobble 3.6s ease-in-out infinite; }
  @keyframes eggWobble { 0%, 62%, 100% { transform: rotate(0deg); } 68% { transform: rotate(-7deg); } 74% { transform: rotate(6deg); } 80% { transform: rotate(-4deg); } 86% { transform: rotate(2deg); } }
  .champ .b-face.egg-face .egg { animation-duration: 2.4s; }
}
.perfect { display: inline-block; margin-left: .45rem; padding: .05rem .4rem; border: 1px solid var(--good); color: #7ee07e; font-size: .62rem; letter-spacing: .1em; vertical-align: middle; }
.f-title .tick { color: #7ee07e; margin-left: .3rem; font-size: .8rem; }
@media (max-width: 430px) { .fighter.row { grid-template-columns: 1.9rem 56px 1fr; } .fighter.row .b-date { display: none; } }
