:root {
  --shark: #272729;
  --black: #000000;
  --white: #ffffff;
  --jade: #00B24C;
  --azure: #0285F0;
  --muted: #c8cdd4;
  --line: rgba(255, 255, 255, 0.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
}

html {
  background: var(--shark);
  scroll-padding-top: 76px;
  scroll-padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

body {
  min-height: 100dvh;
  color: var(--white);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--shark) url("bg-board.jpg") center top / cover no-repeat;
  overflow-wrap: break-word;
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.78), rgba(39, 39, 41, 0.9));
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.opt.right:disabled, .opt.wrong:disabled, .mosaic button:disabled { opacity: 1; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--azure);
  outline-offset: 2px;
}

.shell {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: clamp(12px, 3vw, 32px);
}

#app {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 100dvh;
  padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

main { min-width: 0; }

#app[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(0, 0, 0, 0.9);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand { min-width: 0; flex: 1; }

.kicker {
  margin: 0;
  color: var(--azure);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: break-word; }

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 1.2vw + 1rem, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.id {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  overflow-wrap: anywhere;
}

#tools[hidden] { display: none !important; }

#tools {
  background: rgba(0, 0, 0, 0.94);
  border-bottom: 1px solid var(--line);
}

.tools-inner {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 14px;
}

#tool-meta { margin: 0; color: var(--muted); font-size: 0.85rem; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#tool-search label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.tool-search-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.tool-search-row input { flex: 1 1 auto; min-width: 0; }

.tool-search-row .btn { flex: 0 0 auto; }

.view { padding-top: 16px; padding-bottom: 8px; }

.view-head h2 {
  margin: 0;
  font-size: clamp(1.55rem, 1.4vw + 1rem, 2.15rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.view-head h2::after {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  margin-top: 8px;
  background: linear-gradient(90deg, var(--jade) 0 50%, var(--azure) 50% 100%);
}

.view-head p, .lede { max-width: 62ch; }

.view-head p { margin: 10px 0 0; color: var(--muted); }

.btn, .mem, .star, .mosaic button, .menu button {
  scroll-margin-top: 76px;
  scroll-margin-bottom: calc(108px + env(safe-area-inset-bottom));
}

.btn {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--black);
  color: var(--white);
}

.btn.jade { background: var(--jade); color: var(--black); }

.btn.azure { background: var(--azure); color: var(--black); }

.btn.ghost { background: transparent; border-color: var(--line); color: var(--white); }

.btn.on, .tool-grid button[aria-current="page"] {
  background: var(--azure);
  border-color: var(--azure);
  color: var(--black);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.stat {
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
  background: var(--black);
  border: 1px solid var(--line);
}

.stat span, .stat em {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.stat strong {
  display: block;
  margin: 2px 0;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.stat strong.hot { color: var(--jade); }

.board-wrap { width: min(100%, 560px); margin: 0 auto; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.5vw, 12px);
}

.mem {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  perspective: 700px;
}

.mem-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.38s ease;
}

.mem.up .mem-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.front {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 18%;
  background: #141416;
  border: 1px solid rgba(2, 133, 240, 0.45);
}

.front i { display: block; border-radius: 3px; min-width: 0; min-height: 0; }

.front i:nth-child(1), .front i:nth-child(4) { background: var(--jade); }

.front i:nth-child(2) { background: var(--azure); }

.front i:nth-child(3) { background: var(--white); }

.back {
  display: grid;
  place-items: center;
  background: #101113;
  border: 1px solid var(--line);
  transform: rotateY(180deg);
}

.mem.done .back { box-shadow: inset 0 0 0 2px var(--jade); }

.back img, .back svg {
  width: 68%;
  height: 68%;
  max-width: none;
  object-fit: contain;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.win {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: var(--jade);
  color: var(--black);
}

.win h3, .win p { margin: 0; }

.win p { margin-top: 4px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 14px 0;
  min-width: 0;
}

.filters label {
  display: grid;
  gap: 6px;
  flex: 1 1 150px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.filters .search { flex-basis: 100%; }

.chip { flex: 1 1 calc(50% - 8px); max-width: 100%; }

input, select, textarea {
  width: 100%;
  max-width: 100%;
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}

textarea { resize: vertical; min-height: 68px; max-height: 140px; }

.count { margin: 0 0 10px; color: var(--muted); font-size: 0.85rem; }

.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.card, .hrow, .panel {
  min-width: 0;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.card.pinned { box-shadow: inset 3px 0 0 var(--azure); }

.card-top, .actions, .score-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions { margin-top: 12px; }

.actions .btn, .confirm .btn { flex: 1 1 120px; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  text-transform: capitalize;
}

.pill.good { background: var(--jade); border-color: var(--jade); color: var(--black); }

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.team {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.team.away { justify-content: flex-end; text-align: right; }

.team span { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }

.star {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--white);
  padding: 0;
}

.star.on { color: var(--black); background: var(--jade); border-color: var(--jade); }

.vs {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }

.final {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.note { margin: 6px 0 0; overflow-wrap: anywhere; }

.score-inputs { align-items: end; }

.score-inputs label, .stack label {
  display: grid;
  gap: 6px;
  flex: 1 1 120px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.stack { display: grid; gap: 8px; margin-top: 10px; }

.form-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--white);
  background: var(--black);
}

.confirm p { margin: 10px 0; }

.empty {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
}

.dots { display: flex; gap: 4px; margin: 12px 0; }

.dots i {
  flex: 1 1 0;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  max-width: 36px;
}

.dots i.done { background: var(--jade); }

.dots i.now { background: var(--azure); }

fieldset { border: 0; margin: 14px 0 0; padding: 0; min-width: 0; }

legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 12px;
  max-width: 100%;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 750;
  line-height: 1.25;
}

.options { clear: both; display: grid; gap: 8px; }

.opt { text-align: left; }

.opt.right { background: var(--jade); border-color: var(--jade); color: var(--black); }

.opt.wrong { outline: 2px solid var(--white); }

.score-xl {
  margin: 8px 0;
  font-size: clamp(2.4rem, 8vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.banner {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 16px;
  background: #000 url("bg-mosaic.jpg") center / cover no-repeat;
}

.banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0.42));
}

.banner > * { position: relative; z-index: 1; }

.banner h2 { margin: 0; font-size: clamp(1.55rem, 2vw, 2.15rem); letter-spacing: -0.04em; }

.banner p { margin: 8px 0 0; max-width: 46ch; }

.streak-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.streak-num {
  margin: 0;
  min-width: 64px;
  font-size: 2.4rem;
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--jade);
}

.pips {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  width: min(100%, 420px);
}

.pips li {
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--black);
  border: 1px solid var(--line);
  font-size: 0.68rem;
}

.pips li.on { background: var(--jade); color: var(--black); border-color: var(--jade); }

.pips li.today { box-shadow: inset 0 0 0 2px var(--azure); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.legend li { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }

.legend i, .mini i {
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.legend i { width: 14px; height: 14px; border-radius: 3px; }

.mini, .mosaic {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mini { width: min(100%, 180px); gap: 4px; margin-top: 8px; }

.mini i { aspect-ratio: 1; border-radius: 3px; }

.mosaic { width: min(100%, 420px); gap: 8px; }

.mosaic button {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 0;
}

.mosaic button.miss { outline: 2px solid var(--white); outline-offset: 1px; }

.day-grid { display: grid; gap: 16px; }

.team-list, .history {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.team-list li, .hrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hrow { display: block; }

.team-list li {
  min-width: 0;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
}

.team-list li > span { min-width: 0; }

.team-list strong { display: block; overflow-wrap: anywhere; }

.team-list small, .hrow time { color: var(--muted); font-size: 0.75rem; }

.hrow h3 { margin: 8px 0 4px; font-size: 1rem; }

.hrow p { margin: 0; }

.bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  height: 230px;
  margin-top: 12px;
}

.bar {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 6px;
}

.track {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.col {
  width: min(100%, 36px);
  border-radius: 8px 8px 3px 3px;
  background: var(--jade);
}

.col.zero {
  background: var(--shark);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.col.today { background: var(--azure); }

.val, .day { font-size: 0.72rem; line-height: 1; }

.fine { color: var(--muted); font-size: 0.85rem; }

.fine p { margin: 8px 0 16px; }

.menu {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--black);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.menu-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.menu button {
  min-width: 0;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--white);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  font-size: 0.72rem;
}

.menu button svg {
  width: 22px;
  height: 22px;
  max-width: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.menu button[aria-current="page"] { background: var(--jade); color: var(--black); }

#splash {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #000 url("bg-mosaic.jpg") center / cover no-repeat;
  transition: opacity 0.3s ease;
}

#splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.64);
}

#splash.out { opacity: 0; pointer-events: none; }

.splash-card {
  position: relative;
  z-index: 1;
  width: min(100%, 40rem);
}

.splash-card h1 { font-size: clamp(1.8rem, 7vw, 3.4rem); }

.splash-card .lede { color: var(--white); font-size: 1rem; }

.splash-bar {
  height: 3px;
  margin-top: 18px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.splash-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--jade), var(--azure));
  animation: fillbar 1.5s linear forwards;
}

@keyframes fillbar { to { width: 100%; } }

#toast {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--white);
  color: var(--black);
  text-align: center;
  pointer-events: none;
}

#toast:empty { display: none; }

.noscript {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 16px;
  background: var(--black);
}

@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip { flex: 0 0 auto; }
  .tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 840px) {
  .day-grid { grid-template-columns: minmax(0, 240px) minmax(0, 1fr); align-items: start; }
}

@media (min-width: 1180px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .mem-inner, #splash { transition: none; }
  .splash-bar span { animation: none; width: 100%; }
}
