/* Paper Football - Desk Stadium
   All styling lives here (no CSS framework). Menus are ruled notebook paper,
   the scoreboard is a dark broadcast score bug. */

:root {
  --floor: #14110f;
  --paper: #fbf8ef;
  --ink: #1d2740;
  --ink-soft: #3a4560;
  --rule: rgba(110, 165, 220, 0.42);
  --margin: rgba(224, 106, 106, 0.6);
  --home: #3b82f6;
  --away: #f97316;
  --gold: #fbbf24;
  --good: #22c55e;
  --bad: #ef4444;
  --font-marker: "Permanent Marker", "Marker Felt", "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  --font-hud: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", "Sofia Sans Extra Condensed", Oswald, Impact, "Inter Display", Inter, system-ui, sans-serif;
  --desk-x: 0px;
  --desk-y: 0px;
  --desk-w: 100vw;
  --desk-h: 100vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--floor);
  color: #fff;
  overflow: hidden;
  font-family: var(--font-hud);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

#safeProbe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#dim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(12, 9, 6, 0.28), rgba(6, 4, 3, 0.8));
  opacity: 0;
  transition: opacity 0.45s ease;
}
body.on-title #dim { opacity: 1; }

.marker {
  font-family: var(--font-marker);
  font-weight: 400;
  letter-spacing: 0.01em;
}
/* Until Permanent Marker is confirmed loaded, fake the hand-lettered energy. */
html.no-marker .marker {
  font-family: var(--font-hud);
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.01em;
}

/* ---------- score bug ---------- */

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translate(-50%, -8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
}
body.in-game #hud { opacity: 1; transform: translate(-50%, 0); }

.bug {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  width: min(420px, calc(100vw - 128px));
  height: 54px;
  background: linear-gradient(180deg, #232a39 0%, #121620 55%, #0a0d13 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 11px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.bug-team {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  min-width: 0;
}
.bug-team.home { border-left: 6px solid var(--home); background: linear-gradient(90deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0) 70%); }
.bug-team.away { border-right: 6px solid var(--away); background: linear-gradient(270deg, rgba(249, 115, 22, 0.28), rgba(249, 115, 22, 0) 70%); justify-content: flex-end; }
.t-col { display: none; }
.t-name { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.away .t-name { align-items: flex-end; }
.t-label { font-weight: 700; font-size: 16px; letter-spacing: 0.08em; }
.t-sub { font-weight: 600; font-size: 11px; letter-spacing: 0.16em; opacity: 0.6; margin-top: 3px; }
.t-score {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-width: 1.25em;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
.home .t-score { margin-left: auto; }
.away .t-score { margin-right: auto; }
.poss {
  position: absolute;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.25s, transform 0.25s;
  flex: none;
}
.home .poss { right: 6px; }
.away .poss { left: 6px; }
.has-ball .poss { opacity: 1; transform: none; }
.bug-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  min-width: 74px;
  background: #06080c;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}
.q { font-size: 12px; font-weight: 700; color: var(--gold); letter-spacing: 0.16em; line-height: 1.1; }
.clock { font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: 0.02em; }
.clock.warn { color: var(--bad); animation: tick 1s steps(2) infinite; }
.clock.zero { color: var(--bad); }
.clock.ot { font-size: 13px; letter-spacing: 0.14em; color: #cbd5e1; padding-top: 3px; }
@keyframes tick { 50% { opacity: 0.45; } }

.bug-team.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  animation: flash 1.1s ease-out both;
  pointer-events: none;
}
.home.flash::after { background: var(--home); }
.away.flash::after { background: var(--away); }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
.t-score.flip { animation: flip 0.6s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes flip { 0% { transform: perspective(200px) rotateX(90deg); } 100% { transform: none; } }

.pill {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 5px 14px 5px 12px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--home);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
.pill.show { opacity: 1; transform: none; }
.pill-clock { display: inline-block; min-width: 1.9em; text-align: left; font-variant-numeric: tabular-nums; }
.pill-clock.warn { color: var(--bad); }
.pill.away { border-left-color: var(--away); }

.icon-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 13px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  width: 46px;
  height: 46px;
  display: none;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 16, 0.8);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  z-index: 6;
  transition: transform 0.12s, background 0.15s;
}
.icon-btn svg { width: 20px; height: 20px; fill: #fff; }
.icon-btn:hover { background: rgba(30, 34, 44, 0.92); }
.icon-btn:active { transform: scale(0.92); }
body.in-game .icon-btn { display: grid; }
body.modal-open .icon-btn { opacity: 0; pointer-events: none; }

/* ---------- bottom bar ---------- */

#bottomBar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 9px);
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
  width: max-content;
  max-width: calc(100vw - 24px);
}
body:not(.in-game) #bottomBar { display: none; }
#bottomBar > * { pointer-events: auto; }

.hint {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  pointer-events: none !important;
}
.hint { animation: bob 1.6s ease-in-out infinite; display: flex; align-items: center; gap: 9px; }
.hint-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  box-shadow: 0 6px 0 -3px rgba(251, 191, 36, 0.5), 0 12px 0 -5px rgba(251, 191, 36, 0.25);
}
@keyframes bob { 50% { transform: translateY(3px); } }

/* ---------- banners ---------- */

#banner {
  position: fixed;
  left: var(--desk-x);
  top: var(--desk-y);
  width: var(--desk-w);
  height: var(--desk-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  transition: opacity 0.2s ease;
}
#banner::before {
  content: "";
  position: absolute;
  left: -40vw;
  right: -40vw;
  top: 32%;
  bottom: 32%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.55) 30%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0));
}
#banner.show { opacity: 1; }
.b-title {
  position: relative;
  font-family: var(--font-marker);
  font-size: clamp(34px, calc(var(--desk-w) * 0.13), 74px);
  line-height: 1;
  text-align: center;
  color: var(--gold);
  transform: rotate(-5deg);
  padding: 0 8px;
  text-shadow: 0 0 1px #000, 3px 3px 0 #111, -2px -2px 0 #111, 2px -2px 0 #111, -2px 2px 0 #111, 0 3px 0 #111, 6px 8px 0 rgba(0, 0, 0, 0.35);
  max-width: 96vw;
}
html.no-marker .b-title { font-family: var(--font-hud); font-style: italic; font-weight: 900; letter-spacing: -0.01em; }
#banner.big .b-title { font-size: clamp(38px, calc(var(--desk-w) * 0.125), 92px); }
#banner.home .b-title { color: #93c5fd; }
#banner.away .b-title { color: #fdba74; }
#banner.big.home .b-title { color: #fff; text-shadow: 0 0 1px #000, 4px 4px 0 var(--home), -3px -3px 0 #0c1a3a, 3px -3px 0 #0c1a3a, -3px 3px 0 #0c1a3a, 0 4px 0 #0c1a3a, 8px 10px 0 rgba(0, 0, 0, 0.35); }
#banner.big.away .b-title { color: #fff; text-shadow: 0 0 1px #000, 4px 4px 0 var(--away), -3px -3px 0 #3a1505, 3px -3px 0 #3a1505, -3px 3px 0 #3a1505, 0 4px 0 #3a1505, 8px 10px 0 rgba(0, 0, 0, 0.35); }
#banner.bad .b-title { color: #fecaca; }
.b-sub {
  position: relative;
  margin-top: 16px;
  font-size: clamp(14px, calc(var(--desk-w) * 0.042), 20px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff;
  background: #121212;
  padding: 7px 16px 6px;
  transform: rotate(1.6deg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  clip-path: polygon(0 6%, 3% 0, 97% 4%, 100% 0, 99% 50%, 100% 96%, 96% 100%, 4% 95%, 0 100%, 1% 50%);
  white-space: nowrap;
}
.b-sub:empty { display: none; }
#banner.bad .b-sub { background: #7f1d1d; }
#banner.show .b-title { animation: slam 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
#banner.show .b-sub { animation: tapeIn 0.4s 0.18s ease-out both; }
#banner.big.show .b-title { animation: slamBig 0.62s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
@keyframes slam { 0% { transform: scale(1.9) rotate(-11deg); opacity: 0; } 60% { transform: scale(0.95) rotate(-4deg); opacity: 1; } 100% { transform: scale(1) rotate(-5deg); } }
@keyframes slamBig { 0% { transform: scale(3) rotate(-14deg); opacity: 0; } 50% { transform: scale(0.9) rotate(-4deg); opacity: 1; } 72% { transform: scale(1.07) rotate(-6deg); } 100% { transform: scale(1) rotate(-5deg); } }
@keyframes tapeIn { 0% { transform: translateX(-30px) rotate(-4deg); opacity: 0; } 100% { transform: rotate(1.6deg); opacity: 1; } }

/* ---------- paper sheets ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  overflow-y: auto;
  z-index: 10;
}
.screen.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.22s ease; }
.screen:not(#scrTitle):not(#scrDifficulty):not(#scrHowto):not(#scrSettings) { background: rgba(8, 6, 4, 0.62); }
.screen.open .sheet { animation: sheetIn 0.42s cubic-bezier(0.2, 1.25, 0.4, 1) both; }
@keyframes sheetIn { 0% { transform: translateY(40px) rotate(-5deg) scale(0.94); opacity: 0; } 100% { transform: rotate(var(--rot, -1deg)); opacity: 1; } }

.sheet {
  --rot: -1deg;
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 22px 22px 58px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 42px, var(--margin) 42px, var(--margin) 44px, transparent 44px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 40%, rgba(120, 100, 60, 0.06)),
    repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px);
  background-position: 0 0, 0 0, 0 10px;
  border-radius: 3px 3px 5px 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 4px 10px rgba(0, 0, 0, 0.35), 0 26px 50px rgba(0, 0, 0, 0.55);
  transform: rotate(var(--rot));
  scrollbar-width: thin;
}
.sheet::after {
  /* corner curl shading */
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 60px;
  height: 60px;
  background: linear-gradient(315deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0) 55%);
  pointer-events: none;
}
.tape {
  position: absolute;
  top: -13px;
  width: 98px;
  height: 28px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 3px, rgba(0, 0, 0, 0.02) 3px 6px), rgba(236, 226, 196, 0.72);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  clip-path: polygon(2% 8%, 6% 0, 12% 6%, 18% 0, 82% 2%, 88% 0, 94% 6%, 100% 2%, 98% 50%, 100% 96%, 94% 100%, 88% 94%, 6% 100%, 0 92%, 2% 50%);
  z-index: 2;
}
.tape.tl { left: 14px; transform: rotate(-7deg); }
.tape.tr { right: 14px; transform: rotate(6deg); }
.holes { position: absolute; left: 13px; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-around; padding: 40px 0; pointer-events: none; }
.holes i { display: block; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #0e0b09, #2a2420); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.6); }

.sheet-h {
  margin: 0 0 6px;
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.05;
  color: var(--ink);
  transform: rotate(-1.5deg);
  transform-origin: left center;
}
.sheet-note { margin: 0 0 14px; font-size: 16px; font-weight: 500; color: var(--ink-soft); line-height: 1.25; }
.sheet-note.small { font-size: 14px; margin-top: 12px; }

/* title */
#scrTitle { background: none; }
.title-sheet { --rot: -1.2deg; width: min(430px, 100%); }
.lockup { position: relative; margin: 4px 0 4px; }
.lockup h1 { margin: 0; line-height: 0.88; }
.lk-1 { font-size: clamp(44px, 13.6vw, 74px); color: var(--ink); transform: rotate(-3deg); transform-origin: left; text-shadow: 0 0 1px rgba(29, 39, 64, 0.4); }
.lk-2 {
  display: inline-block;
  font-size: clamp(40px, 12.2vw, 62px);
  color: var(--home);
  transform: rotate(-3deg) translateX(-2px);
  transform-origin: left;
  background: linear-gradient(176deg, transparent 58%, rgba(251, 191, 36, 0.6) 58%, rgba(251, 191, 36, 0.6) 86%, transparent 86%);
  padding: 0 6px 0 2px;
  text-shadow: 2px 2px 0 rgba(29, 39, 64, 0.85);
}
.lk-ball { display: none; position: absolute; right: 6px; top: -6px; width: 48px; transform: rotate(14deg); filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.25)); }
.tagline { margin: 10px 0 16px; font-size: 17px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.02em; }
.menu { display: grid; gap: 12px; }
.menu-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.menu-row .btn { font-size: clamp(15px, 4.3vw, 18px); letter-spacing: 0.03em; white-space: nowrap; padding: 6px 6px; }
.record { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; color: #5b6478; }
.record span { white-space: nowrap; }
.record b { color: var(--ink); font-weight: 700; }

/* buttons */
.btn {
  --r: -0.5deg;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 14px;
  font-family: var(--font-hud);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 2.5px solid var(--ink);
  border-radius: 12px 9px 13px 10px / 10px 13px 9px 12px;
  box-shadow: 3px 4px 0 var(--ink);
  transform: rotate(var(--r));
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease, filter 0.15s;
  text-transform: uppercase;
}
.btn:nth-child(even) { --r: 0.6deg; }
.btn:hover { transform: rotate(var(--r)) translate(-1px, -2px); box-shadow: 5px 6px 0 var(--ink); background: #fff; }
.btn:active { transform: rotate(var(--r)) translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.big { min-height: 58px; font-size: 26px; letter-spacing: 0.07em; }
.btn.small { min-height: 44px; font-size: 16px; padding: 4px 18px; }
.btn.primary { background: var(--home); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.btn.primary:hover { background: #4f8ff7; }
.btn.away { background: var(--away); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.btn.away:hover { background: #fb8a3c; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn.ghost:hover { background: rgba(29, 39, 64, 0.06); box-shadow: none; }
.btn:disabled { cursor: default; filter: saturate(0.8); }
.btn:disabled:hover { transform: rotate(var(--r)); box-shadow: 3px 4px 0 var(--ink); }
button:focus { outline: none; }
button:focus-visible, .card:focus-visible { outline: 3px dashed var(--home); outline-offset: 4px; }
.back { margin-top: 14px; width: 100%; }

/* difficulty cards */
.cards { display: grid; gap: 12px; margin-top: 8px; }
.card {
  --r: -0.6deg;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  text-align: left;
  padding: 11px 14px 12px;
  color: var(--ink);
  background-color: #fffef9;
  background-image: linear-gradient(180deg, transparent 30px, rgba(224, 106, 106, 0.55) 30px, rgba(224, 106, 106, 0.55) 31.5px, transparent 31.5px), repeating-linear-gradient(180deg, transparent 0 21px, rgba(110, 165, 220, 0.3) 21px 22px);
  background-position: 0 6px, 0 14px;
  border: 2.5px solid var(--ink);
  border-left-width: 9px;
  border-radius: 8px;
  box-shadow: 3px 4px 0 var(--ink);
  transform: rotate(var(--r));
  transition: transform 0.1s, box-shadow 0.1s;
}
.card:nth-child(2) { --r: 0.7deg; }
.card[data-level="rookie"] { border-left-color: var(--good); }
.card[data-level="pro"] { border-left-color: var(--home); }
.card[data-level="legend"] { border-left-color: var(--bad); }
.card:hover { transform: rotate(var(--r)) translate(-1px, -2px); box-shadow: 5px 6px 0 var(--ink); }
.card:active { transform: rotate(var(--r)) translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.card-name { font-size: 28px; line-height: 1.1; }
.stars { color: #e0a40c; font-size: 20px; letter-spacing: 0.08em; text-shadow: 1px 1px 0 rgba(29, 39, 64, 0.6); }
.stars b { color: rgba(29, 39, 64, 0.18); text-shadow: none; font-weight: 400; }
.card-desc { grid-column: 1 / -1; font-size: 16px; font-weight: 600; color: var(--ink-soft); line-height: 1.2; }

/* how to play */
.howto-sheet { padding-top: 22px; padding-bottom: 18px; }
.steps { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; gap: 9px; }
.steps li { display: grid; grid-template-columns: 50px 1fr; gap: 12px; align-items: center; }
.steps svg { width: 50px; height: 50px; background: rgba(255, 255, 255, 0.6); border: 2px solid var(--ink); border-radius: 10px; padding: 3px; }
.steps b { display: block; font-size: 19px; letter-spacing: 0.06em; }
.steps span { display: block; font-size: 15px; font-weight: 500; color: var(--ink-soft); line-height: 1.18; }
.howto-sheet .btn { width: 100%; }
.row-btns { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; margin-top: 16px; }
.row-btns .btn { white-space: nowrap; font-size: clamp(15px, 4.4vw, 20px); padding: 6px 6px; letter-spacing: 0.04em; }
.row-btns .btn.big { font-size: clamp(17px, 5vw, 23px); }
#scrSettings .btn.primary { width: 100%; }
.share-btn { width: 100%; margin-top: 12px; }
.sheet-note a { color: inherit; text-decoration: underline; }
.row-btns > :only-child { grid-column: 1 / -1; }

/* settings */
.set-list { margin: 6px 0 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1.5px dashed rgba(29, 39, 64, 0.25); font-size: 19px; font-weight: 600; color: var(--ink); }
.set-row small { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.seg { display: inline-flex; border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden; flex: none; box-shadow: 2px 3px 0 var(--ink); background: rgba(255, 255, 255, 0.7); }
.seg button { min-width: 50px; min-height: 40px; padding: 0 8px; background: transparent; border: 0; border-left: 2px solid var(--ink); font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: 0.04em; }
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.switch { position: relative; flex: none; width: 60px; height: 34px; border-radius: 999px; border: 2.5px solid var(--ink); background: #e2e2de; box-shadow: 2px 3px 0 var(--ink); transition: background 0.15s; }
.switch::before { content: ""; position: absolute; inset: -6px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%; background: var(--ink); transition: left 0.15s; }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { left: 28px; background: #fff; box-shadow: 0 0 0 2px var(--ink); }

/* pause */
.small-sheet { width: min(380px, 100%); }
#scrPause .menu { gap: 10px; }
#scrPause .set-row { min-height: 50px; }

/* game over */
.over-sheet { --rot: 0.8deg; width: min(460px, 100%); padding-top: 22px; }
.over-kicker { font-size: 14px; font-weight: 700; letter-spacing: 0.22em; color: #6b7280; }
.over-h { margin: 2px 0 6px; font-size: clamp(40px, 11vw, 54px); line-height: 1; transform: rotate(-2deg); transform-origin: left; color: var(--ink); }
.over-h.home { color: var(--home); text-shadow: 2px 2px 0 var(--ink); }
.over-h.away { color: var(--away); text-shadow: 2px 2px 0 var(--ink); }
.final { display: flex; align-items: flex-end; justify-content: center; gap: 18px; margin: 6px 0 10px; }
.f-team { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.f-team.away { flex-direction: column-reverse; }
.f-team span { font-size: 15px; font-weight: 700; letter-spacing: 0.14em; padding: 3px 8px; border-radius: 5px; color: #fff; }
.f-team.home span { background: var(--home); }
.f-team.away span { background: var(--away); }
.f-team b { font-size: 58px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.f-dash { font-size: 40px; font-weight: 600; opacity: 0.5; }
.stats { width: 100%; border-collapse: collapse; font-size: 16px; }
.stats th, .stats td { padding: 4px 4px; border-bottom: 1.5px dashed rgba(29, 39, 64, 0.22); }
.stats tbody th { text-align: left; font-weight: 600; color: var(--ink-soft); }
.stats td { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; width: 24%; }
.stats thead th { font-size: 13px; letter-spacing: 0.16em; border-bottom: 2px solid var(--ink); }
.stats thead th.home { color: var(--home); }
.stats thead th.away { color: var(--away); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  transform: translate(-50%, 20px);
  z-index: 30;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  background: #0c0e13;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; }

/* ---------- landscape phones: HUD beside the desk ---------- */
body.layout-side #hud {
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: 12px;
  transform: none;
  align-items: flex-start;
  width: calc(var(--desk-x) - 24px);
}
body.layout-side .bug { width: 100%; }
body.layout-side #bottomBar {
  left: auto;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  bottom: 12px;
  transform: none;
  flex-direction: column;
  align-items: flex-end;
  width: calc(var(--desk-x) - 24px);
}
body.layout-side .pill { white-space: normal; font-size: 13px; }

body.layout-side .bug-team { padding: 0 8px; gap: 5px; }
body.layout-side .t-score { font-size: 30px; min-width: 1.05em; }
body.layout-side .t-label { font-size: 14px; letter-spacing: 0.05em; }
body.layout-side .t-sub { font-size: 10px; }
body.layout-side .bug-mid { min-width: 62px; padding: 0 6px; }
body.layout-side .clock { font-size: 22px; }

.screen > * { margin: auto 0; }
.screen { place-items: start center; }

@media (max-height: 520px) {
  .sheet { padding-top: 16px; padding-bottom: 14px; }
  .tagline, .record { display: none; }
  .lockup .lk-1 { font-size: 38px; }
  .lockup .lk-2 { font-size: 36px; }
  .btn.big { min-height: 46px; font-size: 21px; }
  .menu { gap: 8px; }
  .sheet-h { font-size: 28px; }
  .cards { gap: 8px; }
  .card { padding: 6px 12px 8px; }
  .card-desc { font-size: 14px; }
}

@media (max-width: 599px) {
  body:not(.layout-side) #hud { left: calc(env(safe-area-inset-left, 0px) + 10px); transform: translate(0, -8px); width: calc(100vw - 76px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); }
  body.in-game:not(.layout-side) #hud { transform: none; }
  body:not(.layout-side) .bug { width: 100%; }
  .bug-team { padding: 0 8px; gap: 5px; }
  .t-score { font-size: 31px; min-width: 1.05em; }
  .t-label { font-size: 15px; letter-spacing: 0.05em; }
  .t-sub { font-size: 10px; }
  .bug-mid { min-width: 66px; padding: 0 8px; }
  .pill { font-size: 13px; letter-spacing: 0.07em; padding: 5px 12px 5px 10px; }
  #pauseBtn { right: calc(env(safe-area-inset-right, 0px) + 10px); top: calc(env(safe-area-inset-top, 0px) + 12px); }
}
@media (max-width: 380px) {
  .t-score { font-size: 30px; }
  .t-label { font-size: 14px; }
  .bug-mid { min-width: 64px; padding: 0 8px; }
  .clock { font-size: 22px; }
  .sheet { padding-left: 50px; padding-right: 16px; }
  .sheet { background-image: linear-gradient(90deg, transparent 36px, var(--margin) 36px, var(--margin) 38px, transparent 38px), linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 40%, rgba(120, 100, 60, 0.06)), repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px); }
  .holes { left: 10px; }
  .holes i { width: 13px; height: 13px; }
}
@media (max-height: 700px) {
  .sheet { padding-top: 20px; padding-bottom: 16px; }
  .btn.big { min-height: 52px; font-size: 23px; }
  .menu { gap: 10px; }
  .steps { gap: 6px; }
  .steps svg { width: 44px; height: 44px; }
  .steps li { grid-template-columns: 44px 1fr; }
  .steps span { font-size: 14px; }
  .lk-1 { font-size: clamp(44px, 13vw, 66px); }
  .lk-2 { font-size: clamp(40px, 12vw, 62px); }
}

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