/* YoYo web app — same language as the native apps. */
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #000; --surface: #141414; --surface-2: #212121; --line: #2e2e2e;
  --ink: #fff; --ink-soft: #a3a3a3; --ink-mute: #6e6e6e;
  --go: #21ff33; --back: #ff290f; --track: #808080; --warn: #ffb021;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .12em; color: var(--ink-soft); }
.card-title { font-size: .72rem; font-weight: 700; letter-spacing: .14em; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-title .count { background: #2e2e2e; border-radius: 999px; padding: 1px 8px; font-size: .7rem; letter-spacing: 0; }
.field-label { display: block; font-size: .66rem; font-weight: 700; letter-spacing: .12em; color: var(--ink-soft); margin: 14px 0 6px; }
.hint { font-size: .8rem; color: var(--ink-soft); margin: 14px 0 0; line-height: 1.45; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: .9rem; color: var(--ink); text-decoration: none; display: inline-block; }

/* Setup */
.setup { padding: 12px 16px 96px; max-width: 760px; width: 100%; margin: 0 auto; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 16px; }
.app-header h1 { margin: 0; font-size: 2.1rem; font-weight: 900; letter-spacing: -.02em; }
.header-actions { display: flex; gap: 8px; }
.cards { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border-radius: 18px; padding: 18px; }
.level-select { width: 100%; background: var(--surface-2); color: var(--ink); border: 0; border-radius: 12px; padding: 14px; font: inherit; font-weight: 700; font-size: 1.05rem; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { border-radius: 10px; padding: 10px; font-weight: 600; color: var(--ink-soft); }
.segmented button.on { background: #4a4a4a; color: var(--ink); }
.chips { display: flex; gap: 10px; margin-top: 14px; }
.chip { flex: 1; border-radius: 999px; padding: 11px; font-weight: 600; background: var(--surface-2); color: var(--ink-soft); border: 1px solid transparent; }
.chip.on { background: rgba(33,255,51,.16); border-color: var(--go); color: var(--go); }
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 13px 14px; color: var(--ink); font: inherit; font-size: 1rem; }
.add-row input:focus { outline: none; border-color: var(--line); }
.add-row .add { width: 50px; border-radius: 12px; background: var(--go); color: #000; font-size: 1.4rem; font-weight: 800; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 24px 0; color: var(--ink-soft); font-size: .85rem; }
.empty strong { color: var(--ink); font-size: 1rem; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 14px; }
.roster-chip { display: flex; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 6px 4px 6px 12px; font-weight: 600; font-size: .95rem; }
.roster-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-chip button { width: 30px; height: 30px; color: var(--ink-soft); font-size: .75rem; font-weight: 800; }
.arm-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.arm { display: block; width: 100%; max-width: 728px; margin: 0 auto; background: var(--go); color: #000; border-radius: 16px; padding: 16px; font-size: 1.1rem; font-weight: 900; }

/* Test */
.test { flex-direction: column; }
.field { position: relative; flex: 1; min-height: 42dvh; background: var(--bg); overflow: hidden; display: grid; place-items: center; text-align: center; user-select: none; }
.field .bar { position: absolute; inset: 0; background: var(--track); display: none; }
.field .bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--frac, 0) * 100%); }
.field.out .bar, .field.back .bar { display: block; }
.field.out .bar::before { background: var(--go); }
.field.back .bar::before { background: var(--back); }
.field .label { position: relative; padding: 16px; width: 100%; }
.field .code { font-size: clamp(6rem, 28vmin, 16rem); font-weight: 900; letter-spacing: -.03em; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.field .sub { font-weight: 600; letter-spacing: .12em; font-size: clamp(.8rem, 2.4vmin, 1.4rem); margin-top: 6px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.field.rest .sub { color: var(--ink-soft); }
.field .next { font-size: clamp(1.4rem, 4.5vmin, 2.6rem); font-weight: 800; }
.field .count { font-size: clamp(8rem, 38vmin, 22rem); font-weight: 900; letter-spacing: -.04em; line-height: 1; margin-top: 8px; }
.field .count.red { color: var(--back); }
.armed-text { padding: 32px; max-width: 520px; }
.armed-text .big { font-size: 2.8rem; font-weight: 900; margin-bottom: 12px; }
.armed-text p { color: var(--ink-soft); margin: 6px 0; }
.panel { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.status { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 8px 0; }
.cell { padding: 0 12px; }
.cell small { display: block; font-size: .6rem; font-weight: 700; letter-spacing: .12em; color: var(--ink-soft); }
.cell b { font-size: .95rem; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; padding: 8px; max-height: 220px; overflow: auto; border-top: 1px solid var(--line); }
.tile { text-align: left; background: #121212; border: 1px solid rgba(163,163,163,.25); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile small { font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.tile.warned { border-color: var(--warn); } .tile.warned small { color: var(--warn); }
.tile.out { border-color: var(--back); background: #1f0a08; opacity: .6; } .tile.out small { color: var(--back); }
.tile:disabled { opacity: .6; }
.spacer { flex: 1; }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #2a2a2a; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.controls button { background: #0d0d0d; padding: 18px; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.controls button.danger { color: var(--back); }

@media (min-width: 900px) and (orientation: landscape) {
  .test { flex-direction: row; }
  .field { min-height: 100dvh; }
  .panel { width: max(340px, 32vw); border-top: 0; border-left: 1px solid var(--line); }
  .status { grid-auto-flow: row; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 0; }
  .tiles { max-height: none; flex: 1; align-content: start; }
}

/* Result */
.result { padding: 16px 16px 24px; max-width: 760px; width: 100%; margin: 0 auto; }
.result h2 { text-align: center; font-size: 1.1rem; margin: 8px 0 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat small { font-size: .62rem; font-weight: 700; letter-spacing: .12em; color: var(--ink-soft); }
.stat b { font-size: 1.7rem; font-weight: 900; letter-spacing: -.02em; }
.stat span { font-size: .72rem; color: var(--ink-soft); }
.athlete-list { margin-top: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.row small { display: block; color: var(--ink-soft); font-size: .78rem; }
.row .right { text-align: right; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; align-items: center; }
.result-actions .arm { flex: 1 1 100%; }
dialog.history { background: var(--surface-2); color: var(--ink); border: 0; border-radius: 18px; padding: 20px; width: min(560px, 92vw); max-height: 80vh; }
dialog.history::backdrop { background: rgba(0,0,0,.7); }
dialog.history h2 { margin: 0 0 12px; }
dialog.history .list { max-height: 55vh; overflow: auto; margin-bottom: 12px; }
.link.danger { color: var(--back); font-size: .78rem; font-weight: 600; display: block; }

@media (max-width: 420px) {
  .app-header .eyebrow { font-size: .58rem; letter-spacing: .1em; }
  .app-header h1 { font-size: 1.8rem; }
  .header-actions .pill { padding: 8px 12px; font-size: .82rem; }
}
