@font-face { font-family: "Press Start 2P"; src: url(fonts/press-start-2p.woff2) format("woff2"); font-display: swap }
@font-face { font-family: VT323; src: url(fonts/vt323.woff2) format("woff2"); font-display: swap }

:root {
  /* Brand: Forest Green, Iron Range Red, Harvest Gold, Minnesota Wheat. */
  --green: #154734; --red: #A6192E; --gold: #EAAA00; --paper: #DDCBA4;
  /* Derived shades of the brand colors, for depth and for readable small text on green. */
  --ink: #0a2319; --panel: #154734; --edge: #2f6f55; --ice: #dbe7f3;
  --lime: #7ddc9f; --miss: #ff8a7a; --dim: #a9b8a6;
  --px: "Press Start 2P", ui-monospace, monospace; --body: VT323, ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0 }
html, body { height: 100%; background: #05130d; color: var(--paper); font: 22px/1.05 var(--body); -webkit-tap-highlight-color: transparent; overscroll-behavior: none }
button, input, select { font: inherit; color: inherit; border-radius: 0 }
button { cursor: pointer; touch-action: manipulation }
[hidden] { display: none !important }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px }
img.px, canvas { image-rendering: pixelated }

/* CRT scanlines over everything */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 90; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px) }

.btn, .opt { font: 10px/1.3 var(--px); text-transform: uppercase; min-height: 46px; padding: 10px 6px; background: var(--ink); border: 3px solid var(--paper); box-shadow: 0 4px 0 #000; position: relative }
.btn:active, .opt:not(:disabled):active { transform: translateY(4px); box-shadow: none }
.opt.on { background: var(--gold); color: var(--ink); border-color: #fff }
.opt:disabled { cursor: default; box-shadow: none; border-color: var(--edge); color: var(--dim) }
.opt.on:disabled { background: #a37700; color: var(--ink); border-color: var(--gold) }

/* ---------- title screen ---------- */
#title { max-width: 460px; min-height: 100dvh; margin: auto; padding: max(20px, env(safe-area-inset-top)) 20px 28px; background: var(--ink); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px }
#logo { width: 256px; height: 80px; margin-top: 6px }
h1 { font: 22px/1.2 var(--px); color: var(--paper); text-shadow: 3px 3px 0 #000; letter-spacing: 2px }
h1 span { display: block; font-size: 40px; color: var(--gold); text-shadow: 4px 4px 0 var(--red), 8px 8px 0 #000; letter-spacing: 0 }
.tag { color: var(--gold); font-size: 24px }
.step { width: 100%; display: grid; gap: 8px; text-align: left; margin-top: 8px }
.step label, legend { font: 10px var(--px); color: var(--dim); margin-top: 6px; padding: 0 }
.step input, #say input, dialog input, select { width: 100%; height: 48px; padding: 0 10px; background: #000; border: 3px solid var(--edge); font: 26px var(--body); text-transform: uppercase; color: var(--lime) }
.step input::placeholder, #say input::placeholder { color: #5f8a76 }
fieldset { border: 0; padding: 0; min-width: 0 }
#sprites { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 8px }
#sprites button { background: var(--panel); border: 3px solid var(--edge); padding: 4px 0; min-height: 46px }
#sprites button[aria-pressed=true] { border-color: var(--gold); background: #1f5f47 }
#sprites img { width: 24px; height: 24px; display: block; margin: auto }
#joinerr { color: var(--miss); font: 10px/1.4 var(--px); min-height: 14px }
.start { font-size: 14px; min-height: 58px; background: var(--red); animation: blink 1.1s steps(2) infinite }
@keyframes blink { 50% { color: var(--gold) } }

/* ---------- game shell ---------- */
#game { max-width: 460px; height: 100dvh; margin: auto; display: grid; grid-template-rows: auto auto 1fr auto; background: var(--ink) }
.tab { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px }

#bug { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 8px 8px; background: #000; border-bottom: 4px solid var(--edge) }
.team { display: flex; align-items: center; gap: 8px; font: 12px var(--px) }
.team:nth-child(3) { justify-content: flex-end }
.team.w span { color: var(--lime) }
.score { font: 22px var(--px); color: var(--gold); background: #1a1405; border: 2px solid #6b4e00; padding: 6px 6px 4px 8px; min-width: 38px; text-align: center }
.mid { text-align: center; display: grid; gap: 4px }
.mid small { font: 8px var(--px); color: var(--dim) }
.mid b { font: 14px var(--px); color: var(--paper) }
.helpbtn { font: 12px var(--px); width: 44px; height: 44px; background: var(--red); border: 3px solid var(--edge) }
.nogame { grid-column: 1 / 4; font: 10px/1.6 var(--px); color: var(--dim); text-align: center }

.alert { margin: 8px 10px 0; padding: 10px; background: var(--red); border: 3px solid var(--gold); font: 10px/1.5 var(--px); color: #fff; text-align: center }
.alert small { display: block; font-size: 8px; color: var(--paper); margin: 4px 0 }
.alert .row { margin-top: 8px }
.alert.sin { background: #000; border-color: var(--red) }
.alert.sin b { color: var(--gold) }
#sinbin { position: absolute; left: 0; bottom: 0; display: flex; gap: 2px; background: #000; border: 2px solid var(--red); border-left: 0; border-bottom: 0 }
#sinbin:empty { display: none }
#sinbin span { display: grid; justify-items: center; padding: 3px 4px; font: 7px var(--px); color: var(--gold) }
#sinbin img { width: 16px; height: 16px }
.boxed { font: 7px var(--px); font-style: normal; background: var(--red); color: #fff; padding: 2px 3px; vertical-align: middle }
.lines .btn.wide { margin-top: 8px }
.f.box { display: block; font: 9px/1.5 var(--px); color: #fff; border-left: 4px solid var(--red); padding-left: 8px }
.step .hint { margin-top: 0 }
#stage { display: grid; grid-template-columns: minmax(62px, 1fr) auto minmax(62px, 1fr); justify-content: center; gap: 6px; padding: 8px 6px 4px }
.col { display: grid; gap: 8px; min-width: 0 }
.col .btn { font-size: 8px; line-height: 1.5; padding: 4px 3px; min-height: 0; overflow-wrap: anywhere; border-color: var(--edge) }
#rinkbox { position: relative; border: 3px solid #000; box-shadow: 0 0 0 3px var(--edge) }
#rink { display: block; height: min(37dvh, (min(100vw, 460px) - 160px) * 4 / 3); min-height: 200px; aspect-ratio: 3 / 4 }
#msg { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; font: 14px/1.6 var(--px); color: var(--gold); text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000 }
#msg small { display: block; font-size: 8px; color: #fff }
#msg.big { font-size: 24px; animation: blink .3s steps(2) infinite }
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden }
.bub { position: absolute; max-width: 86%; background: #fff; color: #000; font: 8px/1.4 var(--px); padding: 5px 6px; border: 2px solid #000; box-shadow: 2px 2px 0 rgba(0, 0, 0, .5); animation: rise 3s steps(12) forwards; overflow-wrap: anywhere }
.bub b { color: #A6192E }
@keyframes rise { 0% { transform: translateY(8px); opacity: 0 } 10% { transform: none; opacity: 1 } 80% { opacity: 1 } 100% { transform: translateY(-24px); opacity: 0 } }

#prompt { position: absolute; left: 3%; right: 3%; bottom: 3%; z-index: 3 }
#prompt:empty { display: none }
.callov { background: rgba(10, 35, 25, .96); border: 3px solid var(--gold); box-shadow: 0 4px 0 #000; padding: 8px; animation: callin .5s steps(2) 4 }
.callov h2 { font: 8px/1.4 var(--px); color: var(--gold); display: flex; justify-content: space-between; gap: 6px; margin-bottom: 6px }
.callov h2 em { font-style: normal; color: var(--dim); white-space: nowrap }
.callov .q { font: 9px/1.5 var(--px); margin-bottom: 8px; overflow-wrap: anywhere }
.callov.next { animation: none }
.callov.next h2 { margin-bottom: 8px }
.callov .opt { min-height: 44px; padding: 6px 4px }
#ticker { margin: 6px 10px 0; padding: 4px 8px; background: #000; border: 2px solid var(--edge); color: var(--lime); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 30px }

.card { background: var(--panel); border: 3px solid var(--edge); padding: 10px; margin: 10px 10px 0 }
.card h2 { font: 10px/1.4 var(--px); color: var(--gold); margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline }
.card h2 em { font-style: normal; color: var(--dim); font-size: 8px; text-align: right }
.hint { color: var(--dim); font-size: 19px; margin-top: 10px }
.btn.wide { width: 100%; background: var(--red) }
.card.call { border-color: var(--gold); animation: callin .5s steps(2) 4 }
.card.call .q { font: 10px/1.6 var(--px); margin-bottom: 10px }
@keyframes callin { 50% { border-color: var(--red) } }
.f.prop { display: block; font: 9px/1.5 var(--px); color: var(--gold); border-left: 4px solid var(--gold); padding-left: 8px }
.snd { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch }
.snd select { height: auto; min-height: 46px; font-size: 22px }
.snd select:disabled { opacity: .45 }
.snd + .hint { margin: 6px 0 12px }
.hint.top { margin: -4px 0 10px }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 8px }
.numrow { display: grid; grid-template-columns: 1fr 52px 44px 52px; gap: 8px; align-items: center; margin-top: 8px }
.numrow span { font: 10px/1.5 var(--px) }
.numrow small { display: block; font-size: 8px }
.numrow small b { font-weight: normal }
.numrow output { font: 20px var(--px); color: var(--gold); text-align: center }
.numrow .opt { font-size: 16px; min-height: 44px; padding: 0 }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; align-items: center; text-align: center }
.stepper output { font: 26px var(--px); color: var(--gold) }
.stepper .opt { font-size: 18px }
.hit { color: var(--lime) } .live { color: var(--gold) } .miss { color: var(--miss) } .wait { color: var(--dim) }
h2 b { font-weight: normal; white-space: nowrap }
.mine { display: flex; justify-content: space-between; align-items: center; margin: 10px 10px 0; font: 10px var(--px); color: var(--dim) }
.mine b { font-size: 16px; color: var(--lime) }
.tally { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 4px; scrollbar-width: none }
.tally::-webkit-scrollbar { display: none }
.chip { flex: none; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 8px; background: var(--panel); border: 3px solid var(--edge); font: 9px var(--px); color: var(--paper) }
.chip.me { border-color: var(--lime) } .chip.on { background: var(--ink); border-color: var(--gold) }
.chip i { font-style: normal; color: var(--dim) } .chip b { color: var(--gold); font-size: 12px; font-weight: normal }
.chip img { width: 16px; height: 16px } .chip em { font: 7px var(--px); font-style: normal; background: var(--red); color: #fff; padding: 2px 3px }
.lines.how { border-top: 3px solid var(--edge); margin-top: 6px }
.note { margin: 10px 10px 0; font: 8px/1.6 var(--px); color: var(--dim); text-align: center }

/* ---------- table ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 10px 0 }
.prow { display: grid; grid-template-columns: 26px 32px 1fr auto; gap: 8px; align-items: center; width: calc(100% - 20px); margin: 8px 10px 0; padding: 8px; background: var(--panel); border: 3px solid var(--edge); font: 11px var(--px); text-align: left; min-height: 54px }
.prow.me { border-color: var(--lime) }
.prow img { width: 32px; height: 32px }
.prow .rk { color: var(--dim) }
.prow .pt { color: var(--gold); font-size: 14px; text-align: right }
.prow .pt small { display: block; font-size: 7px; color: var(--dim); margin-top: 4px }
.prow:first-of-type .rk { color: var(--gold) }
.lines { margin: 0 10px; padding: 6px 10px; background: #000; border: 3px solid var(--edge); border-top: 0 }
.rowl b { white-space: nowrap }
.editsay { display: block; width: calc(100% - 20px); margin: 8px 10px 0; min-height: 0; padding: 8px; font-size: 8px; border-color: var(--edge); color: var(--dim) }
#sayform { display: grid; gap: 8px }
#sayform .btn { margin-top: 0 }
.quick .btn { overflow-wrap: anywhere }
.rowl { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0 }
.lines div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0 }
.lines span:last-child { white-space: nowrap }

/* ---------- chirps ---------- */
#say { display: grid; grid-template-columns: 1fr 84px; gap: 8px; margin: 10px 10px 0 }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 10px 0 }
.f { display: grid; grid-template-columns: 24px 1fr; gap: 8px; margin: 8px 10px 0; align-items: start; overflow-wrap: anywhere }
.f img { width: 24px; height: 24px }
.f b { font: 9px var(--px); color: var(--gold); margin-right: 6px }
.f.sys, .f.gw, .f.go { display: block; font: 9px/1.5 var(--px); color: var(--dim); border-left: 4px solid var(--edge); padding-left: 8px }
.f.gw { color: var(--lime); border-color: var(--lime) } .f.go { color: var(--miss); border-color: var(--red) }

/* ---------- nav, dialog, effects ---------- */
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: #000; border-top: 4px solid var(--edge); padding-bottom: env(safe-area-inset-bottom) }
#tabs button { font: 9px var(--px); height: 58px; background: none; border: 0; border-right: 2px solid #0f3325; color: var(--dim); position: relative }
#tabs button[aria-current=page] { color: var(--ink); background: var(--gold) }
#tabs button i { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--red) }

dialog { margin: auto; width: min(430px, calc(100vw - 20px)); max-height: 88dvh; overflow-y: auto; background: var(--ink); color: var(--paper); border: 4px solid var(--paper); box-shadow: 8px 8px 0 #000; padding: 14px }
dialog::backdrop { background: rgba(0, 0, 0, .8) }
dialog h2 { font: 12px var(--px); color: var(--gold); margin: 6px 0 10px }
dialog table { width: 100%; border-collapse: collapse; margin-bottom: 8px }
dialog td { padding: 3px 0; vertical-align: top }
dialog td:last-child { text-align: right; color: var(--lime); white-space: nowrap; padding-left: 10px }
dialog .btn { width: 100%; margin-top: 10px }

#pop { position: fixed; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; z-index: 60; font: 40px var(--px); color: var(--lime); text-shadow: 4px 4px 0 #000; opacity: 0 }
#pop.go { animation: pop 1.4s steps(14) }
@keyframes pop { 0% { opacity: 0; transform: translateY(30px) scale(.6) } 15% { opacity: 1; transform: none } 75% { opacity: 1 } 100% { opacity: 0; transform: translateY(-60px) } }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 70; background: var(--paper); color: var(--ink); font: 9px/1.5 var(--px); padding: 8px 10px; border: 3px solid #000; max-width: 90vw; text-align: center; display: none }
#toast.on { display: block }
#game.strobe #rinkbox { animation: strobe .24s steps(2) 8 }
@keyframes strobe { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 0 9px var(--red) } }

#rotate { display: none; position: fixed; inset: 0; z-index: 80; background: var(--ink); place-content: center; text-align: center; font: 16px/1.8 var(--px); color: var(--gold) }
@media (orientation: landscape) and (max-height: 480px) { #rotate { display: grid } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important } #pop.go { opacity: 1; transition: opacity 1.4s; } }
