/* Fonts are bundled, SIL Open Font License: see fonts/OFL-*.txt */
@font-face { font-family: 'Shrikhand'; src: url(fonts/shrikhand-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Grandstander'; font-weight: 500; src: url(fonts/grandstander-latin-500-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Grandstander'; font-weight: 800; src: url(fonts/grandstander-latin-800-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --ink: #1b1b4b; --paper: #fffdf5; --rim: #ff3d2e; --ball: #ff8b1f; --pink: #ff5fa2; --mint: #a9f0d1; --lemon: #ffe66d; --violet: #8e5cf7;
  --flood: #a9f0d1;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--flood); color: var(--ink); font: 500 16px/1.4 Grandstander, 'Trebuchet MS', system-ui, sans-serif; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hudScoreWrap { position: absolute; top: calc(8px + var(--safe-t)); right: calc(14px + var(--safe-r)); text-align: right; }
#hudScore { font: 400 44px/1 Shrikhand, Georgia, serif; text-shadow: 2px 2px 0 var(--paper); }
#hudMult { font: 800 18px/1.1 Grandstander, sans-serif; min-height: 20px; }
#hudTag { position: absolute; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%) rotate(-2deg); background: var(--ink); color: var(--paper); padding: 2px 12px 0; font-weight: 800; font-size: 15px; white-space: nowrap; }
#hudTag:empty { display: none; }
.icon { position: fixed; width: 44px; height: 44px; padding: 9px; background: transparent; border: 0; color: var(--ink); pointer-events: auto; z-index: 3; }
.icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }
#btnPause { top: calc(6px + var(--safe-t)); left: calc(6px + var(--safe-l)); }
#btnMute { top: calc(6px + var(--safe-t)); left: calc(50px + var(--safe-l)); }
#hud[hidden] ~ #btnMute { left: calc(6px + var(--safe-l)); }
#btnMute .off { display: none; } #btnMute.muted .on { display: none; } #btnMute.muted .off { display: inline; }
#hint { position: fixed; left: 50%; bottom: calc(26vh + var(--safe-b)); transform: translateX(-50%); width: min(92vw, 420px); text-align: center; font-weight: 800; font-size: 18px; line-height: 1.25; pointer-events: none; color: var(--ink); text-shadow: 0 0 6px var(--paper), 0 0 6px var(--paper), 0 0 2px var(--paper); }
#hint small { display: block; font-weight: 500; font-size: 14px; margin-top: 3px; }

/* Menu */
#menu { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l)); pointer-events: none; }
.menu-head { text-align: center; }
#logo { margin: 44px 0 0; font: 400 clamp(58px, 19vw, 118px)/.95 Shrikhand, Georgia, serif; transform: rotate(-4deg); color: var(--rim); text-shadow: 3px 3px 0 var(--ink); }
#tagline { margin: 10px auto 0; max-width: 24em; font-weight: 800; font-size: 17px; line-height: 1.25; }
.menu-actions { width: min(100%, 420px); margin: 0 auto; display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.btn { display: block; width: 100%; border: 0; padding: 11px 16px 9px; text-align: left; background: var(--ink); color: var(--paper); clip-path: polygon(0 4%, 100% 0, 99% 96%, 1% 100%); }
.btn .t { display: block; font: 400 24px/1.05 Shrikhand, Georgia, serif; }
.btn .s { display: block; font-size: 13.5px; line-height: 1.2; margin-top: 3px; }
.btn.alt { background: var(--rim); color: var(--paper); clip-path: polygon(1% 0, 99% 4%, 100% 100%, 0 95%); }
.btn.alt2 { background: var(--paper); color: var(--ink); clip-path: polygon(0 0, 100% 5%, 99% 100%, 1% 94%); }
.btn:focus-visible { outline-offset: -6px; outline-color: var(--lemon); }
.btn.alt2:focus-visible { outline-color: var(--rim); }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translate(1px, 2px); }
.link { background: none; border: 0; padding: 8px 4px; min-height: 40px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
#menuLinks { display: flex; justify-content: center; gap: 16px; margin: 0; }
/* The floor gets dark as panic climbs, so small text sits on printed paper labels. */
#menuLinks .link { background: var(--paper); padding-left: 10px; padding-right: 10px; }
#stats, #byline { justify-self: center; align-self: center; width: fit-content; margin: 0 auto; padding: 1px 8px; background: var(--paper); text-align: center; font-size: 13px; line-height: 1.25; }
#stats { font-weight: 800; }
#byline { font-size: 12.5px; }
#stats:empty { display: none; }

/* Panels */
#panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-t)) 16px calc(10px + var(--safe-b)); background: rgba(27, 27, 75, .28); z-index: 5; }
.card { position: relative; width: min(100%, 440px); max-height: 100%; overflow-y: auto; background: var(--paper); padding: 18px 20px 14px; box-shadow: 7px 7px 0 var(--pink); -webkit-user-select: text; user-select: text; touch-action: pan-y; }
.card .btn.alt2 { background: var(--mint); }
.card h2 { margin: 0 0 6px; font: 400 32px/1.05 Shrikhand, Georgia, serif; transform: rotate(-1.5deg); transform-origin: left; color: var(--rim); }
.bigscore { font: 400 66px/1 Shrikhand, Georgia, serif; margin: 2px 0 0; }
.bigscore small { font: 800 17px/1 Grandstander, sans-serif; margin-left: 6px; }
.row { font-size: 24px; letter-spacing: 3px; margin: 6px 0; line-height: 1; }
.card p { margin: 6px 0; }
.card .note { font-size: 14px; }
.card .strong { font-weight: 800; }
.card .quote { font-weight: 800; font-size: 18px; line-height: 1.25; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.facts div { border-top: 3px solid var(--ink); padding-top: 3px; font-size: 13px; line-height: 1.15; }
.facts b { display: block; font: 400 24px/1.1 Shrikhand, Georgia, serif; }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.versus div { padding: 8px 10px 6px; background: var(--mint); }
.versus div.win { background: var(--lemon); }
.versus b { display: block; font: 400 34px/1 Shrikhand, Georgia, serif; }
.versus span { font-size: 13.5px; display: block; }
#pBtns { position: sticky; bottom: -14px; display: flex; flex-direction: column; gap: 8px; margin: 12px -6px 0; padding: 6px 6px 8px; background: var(--paper); }
#pBtns .btn { padding: 10px 14px 8px; text-align: center; }
#pBtns .btn .t { font-size: 21px; }
#pToast { min-height: 1.3em; margin: 6px 0 0; font-size: 14px; font-weight: 800; }
#pToast:empty { display: none; }
#manualCopy { width: 100%; height: 5.5em; font: 500 13px/1.3 Grandstander, sans-serif; margin-top: 6px; }
.cos-title { font-weight: 800; margin: 12px 0 4px; }
.cos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.cos button { display: grid; grid-template-columns: 40px 1fr; gap: 0 7px; align-items: center; width: 100%; min-height: 64px; padding: 6px 7px; border: 2px solid var(--ink); background: var(--paper); text-align: left; font-size: 12.5px; line-height: 1.15; }
.cos canvas { width: 40px; height: 40px; display: block; }
.cos button b { display: block; font-weight: 800; }
.cos button.on { background: var(--lemon); }
.cos button:disabled { border-style: dashed; color: #55557c; cursor: default; }
.cos button:disabled canvas { opacity: .55; }

/* Wide screens: hoop on the left, everything else in one column on the right */
@media (orientation: landscape) and (max-height: 560px), (min-width: 900px) and (min-height: 600px) {
  #menu { align-items: flex-end; justify-content: center; gap: 10px; }
  .menu-head, .menu-actions { width: min(52%, 400px); text-align: left; }
  .menu-actions { margin: 0; }
  #logo { margin: 0; transform-origin: left; }
  #tagline { margin-left: 0; }
}
@media (orientation: landscape) and (max-height: 560px) {
  #menu { gap: 2px; padding-top: 4px; padding-bottom: 4px; }
  #logo { font-size: clamp(30px, 11vh, 46px); }
  #tagline, #byline { display: none; }
  .menu-actions { gap: 4px; }
  .btn { padding: 5px 12px 3px; }
  .btn .t { font-size: 18px; } .btn .s { font-size: 12px; margin-top: 0; }
  .link { min-height: 26px; padding: 2px 4px; }
  #stats { font-size: 12px; }
  .card { width: min(100%, 680px); padding: 10px 16px 8px; }
  #pBody { columns: 2; column-gap: 20px; }
  #pBody > * { break-inside: avoid; }
  #pBody .cos-title, #pBody .cos { column-span: all; }
  .card h2 { font-size: 24px; }
  .bigscore { font-size: 38px; }
  #pBtns { flex-direction: row; flex-wrap: wrap; margin-top: 4px; bottom: -8px; }
  #pBtns .btn { flex: 1 1 30%; }
  #pBtns .btn .t { font-size: 17px; }
  .facts { margin: 4px 0; } .facts b { font-size: 18px; }
  .row { margin: 3px 0; font-size: 20px; }
  .card p { margin: 3px 0; }
  .card .quote { font-size: 15px; }
  #hudScore { font-size: 32px; }
  #hint { bottom: 4vh; font-size: 16px; }
  #hint small { font-size: 12.5px; }
}
@media (min-width: 900px) and (min-height: 600px) {
  #menu { padding-right: 9vw; }
  #logo { font-size: 104px; }
}
@media (min-width: 1500px) and (min-height: 900px) {
  .menu-head, .menu-actions { width: 540px; }
  #logo { font-size: 150px; }
  #tagline { font-size: 22px; }
  .btn .t { font-size: 34px; } .btn .s { font-size: 17px; }
  #stats, #byline { font-size: 16px; } .link { font-size: 20px; }
  .card { width: 560px; font-size: 18px; }
}
/* Short portrait phones */
@media (orientation: portrait) and (max-height: 700px) {
  #logo { margin-top: 30px; font-size: clamp(48px, 15vw, 70px); }
  #tagline { font-size: 15px; margin-top: 4px; }
  .btn { padding: 8px 14px 6px; }
  .btn .t { font-size: 21px; }
  .menu-actions { gap: 5px; }
  .link { min-height: 32px; padding: 3px 4px; }
  #byline { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
