:root {
  /* Beavercreek colors: orange and black, with white. Always dark. */
  --orange: #F47B20;
  --orange-ink: #FF9A4D;
  --orange-soft: #3A1F0C;
  --on-orange: #000000;
  --ink: #F5F5F5;
  --muted: #A3A3A3;
  --line: #2E2E2E;
  --bg: #000000;
  --card: #141414;
  --bar: #000000;
  --bar-ink: #FFFFFF;
  /* The opponent is shown in white/gray so every color on screen is a team color. */
  --them: #EDEDED;
  --them-ink: #000000;
  --them-soft: #222222;
  --danger: #D9412F;
  --ok: #3FA66A;
  --radius: 14px;
  --tap: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  /* Layout breakpoints follow the app's own width (container queries), so they stay right when the
     portrait lock turns the page. */
  container-type: inline-size;
}
:root { --sat: env(safe-area-inset-top); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 16px 40px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar); color: var(--bar-ink);
  padding: calc(var(--sat) + 8px) 12px 8px;
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  border-bottom: 2px solid var(--orange);
}
.top .tl { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.top .tt { display: flex; flex-direction: column; min-width: 0; }
.top .tt b { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .tt span { font-size: .75rem; color: #BDBDBD; }
.ib {
  min-width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: rgba(255,255,255,.1); color: #fff; font-size: 1.3rem; padding: 0 12px;
}
.ib.text { font-size: .95rem; font-weight: 600; }
.logo { height: 38px; width: auto; max-width: 84px; object-fit: contain; border-radius: 8px; flex: none; }
.logo.big { height: 110px; max-width: 240px; border-radius: 20px; }

/* Buttons */
.btn {
  min-height: var(--tap); padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn small { font-weight: 400; color: var(--muted); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.btn.dark { background: var(--bar); border-color: var(--bar); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 64px; font-size: 1.05rem; flex-direction: column; gap: 2px; }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .45; }
.btn:active, .act:active, .tile:active { transform: scale(.97); }
.home-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

/* Forms */
input[type=text], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); font-size: 16px;
}
textarea { min-height: 160px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
label.f { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; color: var(--ink); font-weight: 400; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--orange); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 44px; min-width: 52px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.chip.on { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.li {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px;
  border: 0; border-bottom: 1px solid var(--line); background: none; width: 100%; text-align: left;
}
.li:last-child { border-bottom: 0; }
.li .main { flex: 1; min-width: 0; }
.li .main b { display: block; }
.li .main span { font-size: .85rem; color: var(--muted); }
.li .num { font-weight: 800; font-size: 1.2rem; width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--orange-soft); color: var(--orange-ink); margin-left: 4px; vertical-align: 1px; }
.tag.b { background: var(--them-soft); color: var(--them); }
.tag.g { background: #2E2E2E; color: #D0D0D0; }
.tag.inprog { background: var(--danger); color: #fff; }
.res { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res.w { color: var(--ok); } .res.l { color: var(--danger); }

/* Avatars & player tiles */
.av { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; background: var(--orange-soft); }
.av.big { width: 84px; height: 84px; font-size: 1.6rem; }
.av.ph { display: grid; place-items: center; font-weight: 800; color: var(--orange-ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tile {
  position: relative; border: 2px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 104px;
}
.tile .av { width: 50px; height: 50px; }
.av.num { display: grid; place-items: center; background: var(--orange); color: var(--on-orange); font-weight: 900; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile.sel .av.num { box-shadow: 0 0 0 3px #fff; }
.tile .tl { font-size: .78rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.tile.sel { border-color: var(--orange); background: var(--orange-soft); }
.tile.off { opacity: .45; }
.tile .badge {
  position: absolute; top: 4px; right: 4px; min-width: 24px; height: 24px; border-radius: 12px; padding: 0 6px;
  background: var(--orange); color: var(--on-orange); font-size: .75rem; font-weight: 800; display: grid; place-items: center;
}
.tile .pos { position: absolute; top: 5px; left: 7px; font-size: .68rem; font-weight: 700; color: var(--muted); }

/* Lock */
.lock { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 16px 40px; text-align: center; }
.lock h1 { margin: 16px 0 20px; font-size: 1.5rem; }
.lock form { text-align: left; }

/* Live game */
.live { max-width: 1300px; margin: 0 auto; padding: 10px 12px 40px; display: grid; gap: 10px; }
.live-grid h3 { margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-ctrl { display: flex; flex-direction: column; gap: 8px; }

/* Live header: names outside, scores and shots in the middle; goalie left, period right. */
.top.lt {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto auto minmax(0, 1fr) 44px;
  grid-template-areas: "back nmus scus dash scthem nmthem menu" "gk gk sogus . sogthem pers pers";
  column-gap: 8px; row-gap: 6px; align-items: center;
}
.lt > .ib:first-child { grid-area: back; }
.lt > .menu { grid-area: menu; }
.lt .nm { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.lt .nm.us { grid-area: nmus; justify-self: end; }
.lt .nm.them { grid-area: nmthem; justify-self: start; }
.lt .nm span { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lt .scr { font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1.1em; text-align: center; justify-self: center; }
.lt .scr.us { grid-area: scus; color: var(--orange); }
.lt .scr.them { grid-area: scthem; }
.lt .dash { grid-area: dash; color: #666; font-weight: 700; }
.lt .sog { display: flex; align-items: baseline; gap: 4px; justify-self: center; white-space: nowrap; }
.lt .sog.us { grid-area: sogus; }
.lt .sog.them { grid-area: sogthem; }
.lt .sog small { font-size: .64rem; font-weight: 700; letter-spacing: .06em; color: #9A9A9A; }
.lt .sog b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.lt .sog.us b { color: var(--orange); }
.lt .pers { grid-area: pers; justify-self: end; display: flex; gap: 6px; }
.pchip {
  min-height: 36px; min-width: 42px; padding: 0 8px; border-radius: 999px; font-weight: 800; font-size: .85rem;
  background: #161616; border: 1px solid #3A3A3A; color: #fff;
}
.pchip.on { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.lt .gk { grid-area: gk; justify-self: start; display: flex; align-items: center; gap: 5px; }
.gk span { font-size: .68rem; font-weight: 800; color: var(--on-orange); background: var(--orange); border-radius: 5px; padding: 2px 5px; }
.gk select { min-height: 36px; height: 36px; width: auto; padding: 0 8px; border-radius: 10px; font-size: 16px; font-weight: 700; background: #161616; border: 1px solid #3A3A3A; color: #fff; }
@container (max-width: 599px) {
  .top.lt { column-gap: 5px; padding-left: 8px; padding-right: 8px; grid-template-columns: 42px minmax(0, .75fr) auto auto auto minmax(0, 1.25fr) 42px; }
  .lt > .ib { min-width: 42px; padding: 0; }
  .lt .logo { display: none; }
  .lt .scr { font-size: 1.8rem; }
  .lt .nm span { font-size: .74rem; letter-spacing: .02em; }
  .lt .pers { gap: 3px; }
  .pchip { min-width: 30px; min-height: 34px; padding: 0 6px; font-size: .8rem; }
  .pchip .pp { display: none; }
  .gk select { padding: 0 4px; }
}
.live-ctrl, .live-grid, .live-log { min-width: 0; }
.ctrl-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ctrl-row select { width: auto; min-width: 180px; flex: 1; }
.shotline { display: flex; gap: 8px; margin-bottom: 10px; }
.shotline div { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: center; font-size: .8rem; color: var(--muted); }
.shotline b { display: block; font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act {
  min-height: 52px; border-radius: 12px; border: 0; font-weight: 800; font-size: .95rem; letter-spacing: .03em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.act small { font-weight: 500; font-size: .7rem; letter-spacing: 0; opacity: .85; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.act.us { background: var(--orange); color: var(--on-orange); }
.act.us.pen { background: var(--orange-soft); color: var(--orange-ink); border: 2px solid var(--orange); }
.act.them { background: var(--them); color: var(--them-ink); }
.act.them.pen { background: var(--them-soft); color: var(--them); border: 2px solid var(--them); }
.act.wide { grid-column: 1 / -1; min-height: 52px; }
/* Bigger player tiles for one-tap shots during play. */
.live-grid .grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.live-grid .tile { height: var(--th, 148px); min-height: 0; padding: 8px 4px 6px; gap: 3px; border-radius: 16px; justify-content: center; overflow: hidden; }
.live-grid .compact .tile { padding: 4px 4px; gap: 1px; }
.live-grid .compact .tile .av { width: 50px; height: 50px; font-size: 1.45rem; }
.live-grid .tiny .tile .av { width: 38px; height: 38px; font-size: 1.15rem; }
.live-grid .tiny .tile .tl { font-size: .8rem; }
.live-grid .tile .av { width: 74px; height: 74px; font-size: 2.1rem; }

.live-grid .tile .tl { font-size: .95rem; font-weight: 600; }
.live-grid .tile .badge { min-width: 30px; height: 30px; border-radius: 15px; font-size: .95rem; }
.hint { font-size: .8rem; color: var(--muted); margin: 8px 2px 0; }
.log { display: flex; flex-direction: column; gap: 6px; }
.lg {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 48px;
}
.lg.us { border-left-color: var(--orange); }
.lg.them { border-left-color: var(--them); }
.lg.goal { font-size: 1.02rem; }
.lg .when { font-size: .75rem; color: var(--muted); width: 4.6em; flex: none; font-variant-numeric: tabular-nums; }
.lg .what { flex: 1; min-width: 0; }
.lg .by { font-size: .7rem; color: var(--muted); }
@container (min-width: 900px) {
  .live { grid-template-columns: minmax(330px, 400px) 1fr; grid-template-rows: auto 1fr; align-items: start; }
  .live-ctrl { grid-column: 1; }
  .live-grid { grid-column: 2; grid-row: 1 / span 2; }
  .live-log { grid-column: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}

/* Sheet (modal) */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-body {
  position: relative; background: var(--bg); width: 100%; max-width: 760px; max-height: 92%; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
  -webkit-overflow-scrolling: touch;
}
@container (min-width: 800px) { .sheet { align-items: center; } .sheet-body { border-radius: 20px; } }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.sheet.ask { z-index: 60; align-items: center; padding: 16px; }
.sheet.ask .sheet-body { max-width: 420px; border-radius: 20px; border: 1px solid var(--line); }
.sheet.ask p { margin: 10px 0 14px; color: var(--muted); }
.sheet.ask input { margin-bottom: 14px; }
.ask-btns > .btn { flex: 1; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.sheet-foot { display: flex; gap: 10px; margin-top: 18px; position: sticky; bottom: -18px; background: var(--bg); padding: 10px 0 4px; }
.sheet-foot .btn { flex: 1; }
.pickrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pick {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 12px 6px 6px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.pick .av { width: 34px; height: 34px; font-size: .8rem; }
.pick.none { padding-left: 12px; color: var(--muted); font-weight: 500; }
.sect { margin-top: 16px; }
.sect > h3 { margin-bottom: 8px; }

/* Tables */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; position: sticky; top: 0; background: var(--card); }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
tr:last-child td { border-bottom: 0; }
tr.tot td { font-weight: 800; border-top: 2px solid var(--line); }
td input { width: 70px; min-height: 36px; padding: 4px 6px; text-align: right; }
.final-score { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 18px; }
.final-score .s { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.final-score .n { font-weight: 700; text-align: center; }

/* Toast */
.toast {
  /* Pops up in the top bar, between the back and menu buttons, so it never covers the stat buttons. */
  position: fixed; left: 50%; top: calc(var(--sat) + 6px); transform: translateX(-50%); z-index: 80;
  background: #2b2b2b; color: #fff; padding: 4px 4px 4px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 4px 18px rgba(0,0,0,.35); border: 1px solid #444; min-height: 44px;
  width: max-content; max-width: calc(100% - 128px); font-size: .9rem;
}
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.err { background: var(--danger); }
.toast button { background: var(--orange); color: var(--on-orange); border: 0; border-radius: 9px; min-height: 36px; padding: 0 14px; font-weight: 700; flex: none; }

/* Print */
@media print {
  .top, .noprint, .toast, .sheet { display: none !important; }
  :root { --ink: #000; --muted: #555; --line: #BBB; --bg: #fff; --card: #fff; --orange-ink: #B4530A; --orange-soft: #FDEBDD; color-scheme: light; }
  body { background: #fff; color: #000; }
  .wrap { padding: 0; max-width: none; }
  .tbl-wrap, .card { border-color: #999; }
  th { position: static; }
}

code { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: .85em; }

@media (max-width: 440px) {
}

.nextup { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border-left: 6px solid var(--orange); }
.nextup .main { flex: 1; min-width: 0; }
.nextup .main b { display: block; font-size: 1.1rem; }
.nextup .main span { font-size: .9rem; color: var(--muted); }
.upc { margin-top: 10px; }
.upc summary { cursor: pointer; padding: 10px 2px; font-weight: 600; color: var(--orange-ink); min-height: 44px; }
input[type=time] { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 16px; }
select:has(option[value=""]:checked:disabled) { color: var(--muted); }

/* Portrait lock: the device is sideways, so the page is turned back upright (see applyPortrait in app.js). */
html.rot, html.rot body { overflow: hidden; height: 100%; }
html.rot { --sat: max(env(safe-area-inset-left), env(safe-area-inset-right)); }
html.rot body { position: fixed; top: 0; left: 0; width: var(--rw); height: var(--rh); min-height: 0; padding-bottom: 0; transform-origin: 0 0; }
html.rot.r-ccw body { transform: rotate(-90deg) translateX(-100%); }
html.rot.r-cw body { transform: rotate(90deg) translateY(-100%); }
html.rot #app { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Live: Shot against + Face-off (+ Shot map) stay on screen with the player grid. */
.ctrl1 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; }
.ctrl1.three { grid-template-columns: 1.3fr 1fr 1fr; }
.ctrl1 .act { white-space: nowrap; }
@container (max-width: 599px) { .ctrl1 .act { font-size: .82rem; letter-spacing: .01em; } }
.act.fo { background: #1E1E1E; color: #fff; border: 2px solid var(--orange); }
.act.map { background: #1E1E1E; color: var(--orange-ink); border: 2px solid #3A3A3A; }
.lockchip { align-self: flex-start; margin-top: 4px; }

/* Face-off sheet */
.fo-note { background: var(--orange-soft); border: 1px solid var(--orange); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem; line-height: 1.45; }
.fo-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: sticky; bottom: -18px; background: var(--bg); padding: 12px 0 4px; margin-top: 12px; }
.fo-btns .act { min-height: 64px; font-size: 1.15rem; }
.fo-btns .act:disabled { opacity: .35; }

/* Rink */
.rinkbox { position: relative; width: 100%; aspect-ratio: 102 / 87; cursor: crosshair; touch-action: manipulation; }
.rinkbox svg, .chart svg { display: block; width: 100%; height: 100%; }
.rink .ice { fill: #EEF3F7; stroke: #9AA7B2; stroke-width: .6; }
.rink .ln { fill: none; stroke-width: .5; }
.rink .red { stroke: #D33A2C; }
.rink .blue { stroke: #2B5FB8; stroke-width: 1; }
.rink .thick { stroke-width: 1; }
.rink .dot { fill: #D33A2C; }
.rink .crease { fill: #9CC3EA; stroke: #D33A2C; stroke-width: .4; }
.rink .net { fill: none; stroke: #555; stroke-width: .5; }
.rink .sh circle { stroke-width: .7; }
.rink .sh.us circle { fill: var(--orange); stroke: #000; }
.rink .sh.them circle { fill: #222; stroke: #fff; }
.rink .sh.goal circle { stroke-width: 1.2; }
.rink .sh.us.goal circle { stroke: #000; fill: var(--orange-ink); }
.rink .sh.ghost circle { fill: none; stroke-dasharray: 1 1; }
.rink text { font-size: 3px; text-anchor: middle; fill: #000; font-weight: 700; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px -1px; }
.sw.us { background: var(--orange); }
.sw.them { background: #222; border: 1.5px solid #fff; }
.chart { padding: 10px; }

/* Shot map screen */
.mapwrap { padding-top: 10px; }
.maprow { margin-bottom: 8px; }
.maphalf { margin-top: 6px; }
.maphalf h3 { margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.maphalf .rinkbox { width: min(100%, calc((var(--appH, 100vh) - 330px) / 2 * 1.17)); margin: 0 auto; }

/* Shot popup: opens at the top of the screen, ice ("from") and net ("to") side by side when there's room. */
.sheet.top { align-items: flex-start; }
.sheet.top .sheet-body { border-radius: 0 0 20px 20px; padding-top: calc(var(--sat) + 12px); border-bottom: 2px solid var(--orange); }
.locgrid { display: grid; gap: 10px; }
.locgrid h3 { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; margin-bottom: 4px; min-height: 28px; white-space: nowrap; overflow: hidden; }
@container (min-width: 600px) { .locgrid { grid-template-columns: 1.25fr 1fr; align-items: start; } }
.loc-foot { margin-top: 10px; }
.linkbtn { background: none; border: 0; color: var(--orange-ink); font: inherit; text-transform: none; letter-spacing: 0; padding: 0 4px; min-height: 28px; margin-left: auto; }
.netbox { width: 100%; aspect-ratio: 84 / 62; cursor: crosshair; touch-action: manipulation; max-height: 34vh; margin: 0 auto; }
.netbox svg, .netcharts svg { display: block; width: 100%; height: 100%; }
@container (max-width: 599px) { .netbox { width: min(100%, 300px); } }
.net-svg .net-back { fill: #151515; }
.net-svg .frame { fill: none; stroke: #D33A2C; stroke-width: 2.4; stroke-linejoin: round; }
.net-svg .ice-line { stroke: #9AA7B2; stroke-width: 1; }
.net-svg .goalie { opacity: .16; pointer-events: none; }
.net-svg .sh circle { stroke-width: .8; }
.net-svg .sh.us circle { fill: var(--orange); stroke: #000; }
.net-svg .sh.them circle { fill: #fff; stroke: #000; }
.net-svg .sh.goal circle { stroke: #FFD24D; stroke-width: 1.4; }
.rink .sh.faint, .net-svg .sh.faint { opacity: .35; }
.rink .sh.cur circle, .net-svg .sh.cur circle { stroke: #fff; stroke-width: 1.2; }
.rink .sh.us.cur circle { stroke: #000; stroke-width: 1.4; }
.netcharts { display: grid; gap: 10px; }
@container (min-width: 600px) { .netcharts { grid-template-columns: 1fr 1fr; } }
/* While the shot popup is at the top, messages (with Undo) show at the bottom instead. */
body:has(.sheet.top:not([hidden])) .toast { top: auto; bottom: calc(env(safe-area-inset-bottom) + 14px); }

/* Location steps */
.stepchips { margin-bottom: 8px; flex-wrap: wrap; }
.stepchip { min-height: 34px; font-size: .82rem; }
.stepchip.done:not(.on) { border-color: var(--orange); color: var(--orange-ink); }
.locpick h3 { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; margin-bottom: 4px; min-height: 28px; white-space: nowrap; overflow: hidden; }
.locpick .rinkbox { width: min(100%, calc((var(--appH, 100vh) - 300px) * 1.17)); margin: 0 auto; }
.locpick .netbox { max-height: none; width: min(100%, 420px); }
.loc-foot .notsure { flex: 1; min-height: 48px; font-weight: 700; }
.loc-foot .btn.on { background: var(--orange); color: var(--on-orange); border-color: var(--orange); }
.btn.sm.on { background: var(--orange); color: var(--on-orange); border-color: var(--orange); }
.rink.far .ice { fill: #E4EAF0; }
.rink .pass { fill: none; stroke: var(--orange); stroke-width: .8; stroke-dasharray: 2 1.4; }
.rink .sh text { font-size: 3.2px; }

/* Shot charts */
.cl { min-width: 4.5em; }
.pickgames { max-height: 180px; overflow-y: auto; }
.statline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0; }
.statline div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; }
.statline b { display: block; font-size: 1.35rem; color: var(--orange); font-variant-numeric: tabular-nums; }
.statline span { font-size: .72rem; color: var(--muted); }
.chartgrid { display: grid; gap: 12px; }
@container (min-width: 760px) { .chartgrid { grid-template-columns: 1.6fr 1fr; align-items: start; } }
.chart h3 { margin-bottom: 6px; }
@media print { .statline b { color: #000; } }

/* Shot popup: ice + net on one screen */
.locgrid section > h3 { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; min-height: 30px; white-space: nowrap; overflow: hidden; margin-bottom: 4px; }
.locgrid .linkbtn { margin-left: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; min-height: 30px; font-weight: 700; }
.okmark { color: var(--orange-ink); text-transform: none; letter-spacing: 0; }
.okmark.ns { color: var(--muted); font-weight: 500; }
.ice-tools { margin-top: 6px; gap: 8px; }
.locgrid.two { grid-template-columns: 1fr !important; }
/* Stacked: the ice gets ~55% of the free height and the net ~45%, so both fit without scrolling. */
.locgrid.two .rinkbox { width: min(100%, calc((var(--appH, 100vh) - 310px) * .55 * 1.17)); margin: 0 auto; }
.locgrid.two .netbox { width: min(100%, calc((var(--appH, 100vh) - 310px) * .45 * 1.35)); max-height: none; margin: 0 auto; }
.locgrid:not(.two) .rinkbox { width: min(100%, calc((var(--appH, 100vh) - 260px) * 1.17)); margin: 0 auto; }
/* Wide, short screens (landscape): side by side. */
@container (min-width: 900px) {
  .locgrid.two { grid-template-columns: 1.3fr 1fr !important; align-items: start; }
  .locgrid.two .rinkbox, .locgrid.two .netbox { width: 100%; }
}

/* Double mode role chooser */
.rolecard { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; width: 100%; padding: 18px; border-left: 6px solid var(--orange); }
.rolecard b { font-size: 1.25rem; }
.rolecard span { color: var(--muted); }
.maphalf h3 .linkbtn { margin-left: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; min-height: 30px; font-weight: 700; }
.maphalf h3 { display: flex; align-items: center; gap: 4px; }

/* Unknown shooter tile, assumed matches */
.live-grid .tile.unk { border-style: dashed; }
.live-grid .tile.unk .av.num { background: #2a2a2a; color: var(--orange-ink); border: 2px dashed var(--orange); }
.tag.assumed { background: #3a2e00; color: #FFD24D; }
.rink .sh.assumed circle, .net-svg .sh.assumed circle { stroke-dasharray: 1.2 .9; stroke: #FFD24D; }
.spotbtns { margin-left: auto; display: flex; gap: 6px; flex: none; }
.maphalf h3 .spotbtns .linkbtn { margin-left: 0; }

/* Stats page */
.statline { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
.linkbtn.tl { color: var(--ink); text-align: left; padding: 0; min-height: 0; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; font-weight: 600; }
.progress { padding: 10px 12px; margin-top: 4px; }
.progress .legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.progress .legend i { display: inline-block; width: 12px; height: 10px; margin-right: 5px; vertical-align: middle; border-radius: 2px; }
.lg-up { background: var(--orange); } .lg-down { background: #E8E8E8; } .lg-line { background: none !important; border-top: 2px solid #FFD24D; height: 0 !important; }
.pscroll { overflow-x: auto; }
.pscroll svg { display: block; width: 100%; height: 150px; }
.progress .pb.up { fill: var(--orange); } .progress .pb.down { fill: #E8E8E8; }
.progress .axis { stroke: #444; stroke-width: .5; }
.progress text { font-size: 7px; text-anchor: middle; fill: #BDBDBD; }
.progress .pv { fill: #fff; font-weight: 700; }
.progress .pline { fill: none; stroke: #FFD24D; stroke-width: 1.4; }
@media print { .progress .pb.down { fill: #999; } .progress text { fill: #000; } }

/* Player shot maps and share link */
.pmaps { display: grid; gap: 12px; }
@container (min-width: 700px) { .pmaps { grid-template-columns: 1fr 1fr; align-items: start; } }
.grink { width: min(100%, 300px); margin: 0 auto; }
.grink svg { display: block; width: 100%; height: auto; }
.ztitle { margin-top: 14px; }
.sharecard { margin-top: 18px; border-left: 6px solid var(--orange); }
.sharecard input { font-size: 14px; }

/* Demo mode badge, lock-screen footer */
.demobadge { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 70;
  background: #FFD24D; color: #000; font-weight: 700; font-size: .78rem; padding: 6px 12px; border-radius: 999px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.demobadge a { color: #000; margin-left: 8px; text-decoration: underline; }
.lockfoot { text-align: center; margin-top: 14px; }
.lockfoot a { color: var(--orange-ink); }
.pmaps .chart svg { height: auto; }

/* Teams and colors */
.teambtn { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: inherit; text-align: left; min-width: 0; }
.teambtn .caret { font-size: .7em; opacity: .7; }
.colorrow { gap: 14px; }
.colorpick { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.colorpick input[type=color] { width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: none; padding: 2px; }
.colorpick span { display: flex; flex-direction: column; font-weight: 700; }
.colorpick small { font-weight: 400; color: var(--muted); font-size: .75rem; }
.top .tt span, .top .ib { color: inherit; }

.seasonsel { width: auto; min-width: 110px; }
.myplayers { margin-bottom: 12px; align-items: center; }
.myplayers .chip { text-decoration: none; color: inherit; }
.myplayers .chip small { opacity: .7; font-weight: 400; margin-left: 4px; }
