@font-face {
  font-family: Outfit;
  src: url("../fonts/outfit-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Outfit;
  src: url("../fonts/outfit-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Outfit;
  src: url("../fonts/outfit-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #08110d;
  --bg-2: #102019;
  --card: #13261d;
  --card-2: #183228;
  --line: rgba(223, 242, 90, 0.16);
  --ink: #f4f7f2;
  --muted: #a9bdb1;
  --faint: #7e9488;
  --ball: #dff25a;
  --ball-2: #f6ffb0;
  --on-ball: #15200c;
  --grass: #3dba6e;
  --clay: #e07a45;
  --hard: #6aa2ff;
  --loss: #ff8b98;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(223, 242, 90, 0.08), transparent 55%),
    linear-gradient(180deg, #0c1813 0%, var(--bg) 28%);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, .slot:focus-visible, .pcard:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ball);
  outline-offset: 2px;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: -0.03em; font-size: 16px; line-height: 1; }
.brand-sub { color: var(--faint); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; margin-top: 3px; }
.ball-mark { width: 28px; height: 28px; display: block; flex: none; }
.top-gap { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  display: grid; place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.pips { display: flex; gap: 4px; }
.pip { width: 7px; height: 7px; border-radius: 99px; background: #3d5a4c; }
.pip.on { background: var(--ball); }

.view { min-height: 0; overflow: auto; padding: 4px 12px 12px; }
.draft { display: grid; gap: 10px; align-content: start; }

.slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.slot {
  position: relative;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--card);
  border-radius: 14px;
  padding: 8px 8px 7px;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: border-color 160ms ease, transform 160ms ease;
}
.slot.active { border-color: var(--ball); box-shadow: 0 0 0 1px rgba(223,242,90,0.35); }
.slot.filled { background: var(--card-2); }
.slot:active { transform: scale(0.98); }
.slot-k { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.slot-v { font-weight: 800; font-size: 18px; letter-spacing: -0.04em; line-height: 1.1; }
.slot-v.dim { color: #5d7c6c; }
.slot-sub {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot .dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
}
.dot.grass { background: var(--grass); }
.dot.clay { background: var(--clay); }
.dot.hard { background: var(--hard); }
.slot.seen:not(.filled)::after {
  content: "";
  position: absolute; top: 8px; right: 8px;
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(223,242,90,0.45);
}

.stage {
  border: 1px solid var(--line);
  background: rgba(12, 26, 20, 0.72);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 0;
}
.stage-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; min-height: 36px;
}
.era-window {
  position: relative;
  height: 36px; overflow: hidden; flex: 1;
  border-radius: 999px;
  background: #0c1a14;
  border: 1px solid var(--line);
}
.era-window::before, .era-window::after {
  content: ""; position: absolute; left: 0; right: 0; height: 10px; z-index: 1; pointer-events: none;
}
.era-window::before { top: 0; background: linear-gradient(#0c1a14, transparent); }
.era-window::after { bottom: 0; background: linear-gradient(transparent, #0c1a14); }
.era-strip { will-change: transform; }
.era-row {
  height: 36px; display: grid; place-items: center;
  font-weight: 800; letter-spacing: 0.04em; font-size: 15px;
}
.ghost {
  color: var(--muted); font-size: 14px; line-height: 1.35; padding: 8px 4px 4px;
}
.reroll {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0 12px;
  height: 36px;
  color: var(--ball);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.reroll:disabled { color: var(--faint); border-color: rgba(255,255,255,0.06); }

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pcard {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas:
    "mono name rate"
    "mono meta rate";
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.06);
  background: var(--card);
  border-radius: 14px;
  padding: 8px;
  min-height: 68px;
}
.pcard:active { transform: scale(0.985); }
.pcard.deal { animation: deal 460ms cubic-bezier(.16,.84,.32,1) both; }
.mono {
  grid-area: mono;
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: -0.04em; font-size: 13px;
  color: var(--ball-2);
}
.pcard-name {
  grid-area: name;
  font-weight: 700; font-size: 13.5px; letter-spacing: -0.02em; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pcard-meta { grid-area: meta; color: var(--faint); font-size: 11px; display: flex; gap: 4px; align-items: center; }
.pcard-rate {
  grid-area: rate;
  font-weight: 800; font-size: 22px; letter-spacing: -0.05em; line-height: 1;
}
.slot-v.hot, .build b.hot { color: var(--ball); }
.pcard-rate.hot { color: var(--ball); }
.chip {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 1px 6px;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700;
}
.chip.grass { color: #c8f5d8; background: rgba(61, 186, 110, 0.18); }
.chip.clay { color: #ffd4c2; background: rgba(224, 122, 69, 0.2); }
.chip.hard { color: #d5e4ff; background: rgba(106, 162, 255, 0.18); }
.flag-fallback {
  font-size: 10px; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; padding: 0 3px;
}

.go {
  width: 100%;
  border: 0;
  background: var(--ball);
  color: var(--on-ball);
  font-weight: 800;
  letter-spacing: -0.02em;
  border-radius: 14px;
  height: 52px;
  font-size: 16px;
}
.go:active { transform: translateY(1px); }
.go.pulse { animation: pulse 700ms ease 1; }

.ad-slot {
  height: calc(50px + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; align-items: center; justify-content: center;
  border-top: 1px solid rgba(223, 242, 90, 0.14);
  background: repeating-linear-gradient(-45deg, #0c1914, #0c1914 8px, #102018 8px, #102018 16px);
  color: var(--faint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
}
.ad-slot[hidden] { display: none; }

.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  animation: fade 180ms ease;
}
.sheet {
  position: fixed; z-index: 31;
  left: 0; right: 0; bottom: 0;
  background: #102019;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: var(--shadow);
  padding: 8px 16px calc(16px + var(--safe-b));
  max-height: min(86dvh, 720px);
  overflow: auto;
  animation: rise 280ms cubic-bezier(.16,.84,.32,1);
}
.handle {
  width: 42px; height: 4px; border-radius: 99px; background: #2c463a;
  margin: 4px auto 12px;
}
.sheet-top { display: flex; gap: 12px; align-items: center; }
.sheet-top .mono { width: 54px; height: 54px; border-radius: 16px; font-size: 18px; }
.who { font-weight: 800; font-size: 20px; letter-spacing: -0.03em; line-height: 1.1; }
.who-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.rate-block { margin: 14px 0 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.rate-block strong {
  font-size: 64px; line-height: 0.85; letter-spacing: -0.06em; font-weight: 800;
}
.rate-block strong.hot { color: var(--ball); }
.rate-label { color: var(--muted); font-size: 13px; }
.bars { display: grid; gap: 4px; margin: 8px 0 12px; }
.bar { display: grid; grid-template-columns: 72px 1fr 28px; gap: 8px; align-items: center; font-size: 11px; color: var(--faint); }
.bar i { display: block; height: 5px; border-radius: 99px; background: #24382e; position: relative; }
.bar i::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w);
  border-radius: inherit; background: #3d5c4c;
}
.bar.hot { color: var(--ink); }
.bar.hot i::before { background: var(--ball); }
.note { color: var(--muted); font-size: 13px; line-height: 1.4; margin: 0 0 12px; }
.stack { display: grid; gap: 8px; }
.btn {
  height: 48px; border-radius: 14px; border: 1px solid var(--line);
  background: transparent; font-weight: 700;
}
.btn.primary { background: var(--ball); color: var(--on-ball); border-color: transparent; font-weight: 800; }
.btn:disabled { color: var(--faint); }
.locked-tag { color: var(--ball); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }

.sim {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  background: rgba(8, 17, 13, 0.94);
  padding: 24px;
}
.sim-card { width: min(420px, 100%); text-align: center; }
.sim-ball {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 16px;
  background: radial-gradient(circle at 35% 32%, var(--ball-2), var(--ball) 60%, #b6cc3e);
  animation: bounce 0.7s ease-in-out infinite;
}
.sim-kicker { letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); font-size: 12px; margin: 0 0 8px; }
.sim-event { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; margin: 0; min-height: 1.2em; }
.sim-sub { color: var(--muted); min-height: 1.3em; margin: 6px 0 16px; }
.sim-bar { height: 4px; border-radius: 99px; background: #1c3127; overflow: hidden; }
.sim-bar span { display: block; height: 100%; width: 0; background: var(--ball); }

.result { max-width: 720px; margin: 0 auto; display: grid; gap: 14px; }
.kicker { letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); font-size: 12px; margin: 0; }
.headline { margin: 0; font-size: 15px; color: var(--muted); font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--card); border-radius: 16px; padding: 10px 10px 12px;
  border: 1px solid rgba(255,255,255,0.05);
}
.stat b { display: block; font-size: clamp(28px, 8vw, 40px); letter-spacing: -0.05em; line-height: 1; font-weight: 800; }
.stat span { color: var(--faint); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.rank-line { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.rank-line em { font-style: normal; color: var(--ball); }
.meta-line { margin: 0; color: var(--muted); font-size: 14px; }
.cmp-list { display: grid; gap: 6px; }
.cmp {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) auto auto;
  gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 10px;
}
.cmp.you { background: rgba(223, 242, 90, 0.08); }
.cmp .who { font-size: 13px; font-weight: 700; }
.cmp .who small { display: block; color: var(--faint); font-weight: 500; font-size: 11px; }
.cmp .wl { font-weight: 800; font-size: 14px; }
.track { height: 6px; background: #1c3127; border-radius: 99px; overflow: hidden; min-width: 64px; }
.fill { display: block; height: 100%; background: #7ea892; border-radius: inherit; }
.cmp.you .fill { background: var(--ball); }
.section-title { margin: 4px 0 0; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.build {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.build div {
  background: var(--card); border-radius: 12px; padding: 8px 10px;
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.build b { font-size: 16px; }
.build span { color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.summary {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.05);
  padding: 4px 12px 8px;
}
details.summary summary {
  cursor: pointer; font-weight: 800; padding: 10px 0; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
details.summary summary::-webkit-details-marker { display: none; }
details.summary summary::after { content: "▾"; color: var(--faint); }
details[open] summary::after { content: "▴"; }
.stop { padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.05); }
.stop-top { display: flex; gap: 8px; align-items: center; }
.stop-name { font-weight: 700; flex: 1; min-width: 0; }
.stop-round { font-size: 12px; color: var(--muted); }
.stop.won .stop-round { color: var(--ball); }
.stop.lost .stop-round { color: var(--loss); }
.stop-detail { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.row-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }

.history-list { display: grid; gap: 8px; margin-top: 8px; }
.history-list button {
  text-align: left; background: var(--card); border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px; padding: 10px 12px;
}
.history-list small { color: var(--faint); }

.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0 4px;
}
.switch {
  width: 48px; height: 28px; border-radius: 99px; border: 0;
  background: #24382e; position: relative; flex: none;
}
.switch.on { background: var(--ball); }
.switch i {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: white; transition: transform 160ms ease;
}
.switch.on i { transform: translateX(20px); background: var(--on-ball); }
.fine { color: var(--faint); font-size: 13px; line-height: 1.4; }

.toast {
  position: fixed; left: 50%; bottom: calc(70px + var(--safe-b)); z-index: 40;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-weight: 700; border-radius: 999px; padding: 8px 14px;
  animation: fade 160ms ease;
}

.loading, .error { padding: 32px 8px; color: var(--muted); }

@keyframes deal {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { transform: translateY(24px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
@keyframes pulse {
  0% { transform: scale(0.98); }
  40% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
@keyframes flip {
  0% { transform: rotateX(0); }
  45% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
.flipping .pcard-rate, .flipping .chip, .rate-block.flipping strong { animation: flip 420ms ease; }

.score-hero { text-align: center; padding: 2px 0 0; }
.score-num {
  margin: 0;
  font-size: clamp(76px, 22vw, 104px);
  font-weight: 800;
  letter-spacing: -0.07em;
  line-height: 0.82;
  color: var(--ball);
}
.score-label { margin: 8px 0 0; font-weight: 700; font-size: 16px; }
.achieve { margin: 10px 0 0; font-size: 15px; line-height: 1.35; }
.score-math { margin: 4px 0 12px; }
.score-math p { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.score-line {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 5px 0; border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}
.score-line b { font-weight: 800; }
.score-line.total b { color: var(--ball); }

.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tab {
  flex: 1; height: 36px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; font-weight: 700; font-size: 13px;
}
.tab.on { background: var(--ball); color: var(--on-ball); border-color: transparent; }
.tab:disabled { color: var(--faint); }
.board { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.board-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px; align-items: center;
  background: var(--card); border-radius: 14px; padding: 8px 12px;
  animation: deal 420ms cubic-bezier(.16,.84,.32,1) both;
}
.board-row.mine { box-shadow: inset 0 0 0 1px var(--ball); background: #1a2c16; }
.board-rank { color: var(--faint); font-weight: 800; }
.board-name { font-weight: 700; }
.board-name small { display: block; color: var(--faint); font-weight: 500; font-size: 12px; }
.board-score { font-weight: 800; font-size: 22px; letter-spacing: -0.04em; color: var(--ball); }
.soon { padding: 28px 8px; color: var(--muted); text-align: center; }
.name-field {
  width: 100%; height: 48px; border-radius: 14px;
  border: 1px solid var(--line); background: #0c1a14; padding: 0 12px;
}

@media (min-width: 760px) {
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .view { padding-left: 20px; padding-right: 20px; }
  .slots { gap: 10px; }
  .slot { min-height: 72px; }
  .build { grid-template-columns: repeat(3, 1fr); }
  .row-actions { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 1040px) {
  .draft {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: start;
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
  }
  .slots { grid-template-columns: 1fr; align-content: start; }
  .slot { min-height: 0; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; }
  .slot .dot { top: auto; bottom: 10px; }
  .slot-v { grid-column: 2; grid-row: 1; }
  .slot-sub { grid-column: 1 / -1; }
  .stage { display: flex; flex-direction: column; }
  .cards { flex: 1; align-content: start; }
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, calc(100% - 48px));
    border-radius: 22px;
    border-bottom: 1px solid var(--line);
    animation: pop 220ms cubic-bezier(.16,.84,.32,1);
  }
  .handle { display: none; }
}
@keyframes pop {
  from { transform: translate(-50%, -46%) scale(0.98); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .era-window::before, .era-window::after { display: none; }
}

@media (max-height: 740px) {
  .slot { min-height: 54px; padding: 6px; }
  .slot-v { font-size: 16px; }
  .pcard { min-height: 60px; padding: 6px; }
  .stage { padding: 8px; }
}
