/* Tokens: an ice sheet with rink markings. */
:root {
  --ice: #EDF3F7;
  --ice-deep: #DCE7EE;
  --boards: #0E1A2B;      /* text, header */
  --boards-soft: #4A5A6E;
  --goal-red: #C8102E;    /* goal line / losses / danger */
  --blue-line: #0B3D91;   /* actions, focus */
  --lamp: #FFB400;        /* goal lamp: the points readout */
  --white: #FFFFFF;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --led: "Doto", ui-monospace, monospace;

  --radius: 14px;
  --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 400 17px/1.45 var(--body);
  color: var(--boards);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--white), transparent 70%),
    var(--ice);
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue-line); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--boards);
  color: var(--white);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 12px;
}
.brand {
  font: 900 26px/1 var(--display);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
}
/* Blue line, red centre line, blue line: the rink seen from above. */
.rink-lines {
  position: absolute; left: 0; right: 0; bottom: -5px; height: 5px;
  background: var(--white) linear-gradient(90deg,
    transparent 0 30%, var(--blue-line) 30% 33%,
    transparent 33% 48.5%, var(--goal-red) 48.5% 51.5%,
    transparent 51.5% 67%, var(--blue-line) 67% 70%, transparent 70%);
}

main { max-width: 720px; margin: 0 auto; padding: 22px 16px 0; }
#view:focus, #view:focus-visible { outline: none; }
h1 {
  font: 800 40px/1 var(--display);
  text-transform: uppercase;
  letter-spacing: .02em;
  margin: 4px 0 16px;
}
h2 { font: 800 22px/1.1 var(--display); text-transform: uppercase; letter-spacing: .03em; margin: 24px 0 10px; }
.muted { color: var(--boards-soft); }
.small { font-size: 14px; }

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--white);
  border-top: 1px solid var(--ice-deep);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--boards-soft); text-decoration: none;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--blue-line); }
.tabs .tab-add svg {
  width: 44px; height: 44px; padding: 9px; margin-top: -18px;
  border-radius: 50%; background: var(--goal-red); color: var(--white);
  box-shadow: 0 4px 14px rgb(200 16 46 / .35);
}
.tabs .tab-add[aria-current="page"] { color: var(--goal-red); }

/* Standings cards — the signature */
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 16px 14px 22px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--ice-deep), 0 6px 18px rgb(14 26 43 / .06);
  overflow: hidden;
}
/* Sock stripes in the player's team colours. */
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 10px;
  background: linear-gradient(180deg,
    var(--c1) 0 38%, var(--c2) 38% 50%, var(--c1) 50% 62%, var(--c2) 62% 74%, var(--c1) 74%);
}
.rank { font: 800 30px/1 var(--display); color: var(--boards-soft); text-align: center; }
.card.leader .rank { color: var(--goal-red); }
.who { min-width: 0; }
.who .name { font: 800 24px/1.05 var(--display); text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .team { font-size: 14px; color: var(--boards-soft); }
.pts { text-align: right; }
.pts .n {
  display: block;
  font: 900 46px/0.9 var(--led);
  color: var(--boards);
}
.card.leader .pts .n { color: var(--lamp); text-shadow: 0 0 12px rgb(255 180 0 / .45); background: var(--boards); padding: 4px 8px 2px; border-radius: 8px; }
.pts .lbl { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--boards-soft); }
.line {
  grid-column: 2 / 4;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  font-size: 14px; color: var(--boards-soft);
  font-variant-numeric: tabular-nums;
}
.line b { color: var(--boards); font-weight: 700; }
.form { display: inline-flex; gap: 3px; margin-left: auto; }
.form i {
  width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center;
  font: 700 11px/1 var(--body); font-style: normal; color: var(--white);
}
.form .W { background: var(--blue-line); }
.form .L { background: var(--goal-red); }
.form .OTL { background: var(--boards-soft); }

/* Full table, for wider screens */
.table-wrap { overflow-x: auto; margin-top: 22px; background: var(--white); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font: 800 14px var(--display); letter-spacing: .08em; color: var(--boards-soft); border-bottom: 2px solid var(--ice-deep); }
tbody tr + tr td { border-top: 1px solid var(--ice); }
@media (max-width: 560px) { .table-wrap:not(.scroll) { display: none; } }

/* Forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 12px;
  background: var(--blue-line); color: var(--white);
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn.big { width: 100%; min-height: 64px; font: 800 24px var(--display); text-transform: uppercase; letter-spacing: .04em; }
.btn.red { background: var(--goal-red); }
.btn.ghost { background: transparent; color: var(--blue-line); box-shadow: inset 0 0 0 2px var(--ice-deep); }
.btn.link { background: none; color: var(--blue-line); min-height: 40px; padding: 0 4px; text-decoration: underline; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; }

label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 700; color: var(--boards-soft); }
input[type=text], input[type=password], input[type=datetime-local], select {
  width: 100%; min-height: 48px; padding: 0 12px;
  border: 2px solid var(--ice-deep); border-radius: 10px; background: var(--white);
  font-size: 17px; color: var(--boards);
}
.panel { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: 0 6px 18px rgb(14 26 43 / .06); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }

/* Game entry: away @ home, one row per field */
.matchup { display: grid; grid-template-columns: 1fr 22px 1fr; gap: 10px 6px; align-items: center; }
.matchup .tag { font: 800 14px var(--display); letter-spacing: .14em; color: var(--boards-soft); text-align: center; }
.matchup select { font-size: 16px; padding: 0 8px; } /* <16px makes iOS zoom in */
.dash { font: 800 26px var(--display); color: var(--boards-soft); text-align: center; }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; background: var(--boards); border-radius: 12px; overflow: hidden; }
.stepper button { height: 64px; border: 0; background: transparent; color: var(--white); font-size: 28px; cursor: pointer; }
.stepper output { font: 900 44px/1 var(--led); color: var(--lamp); text-align: center; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--ice-deep); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--white); color: var(--blue-line); box-shadow: 0 1px 4px rgb(14 26 43 / .15); }
.photo-preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: var(--boards); }
.note { padding: 12px 14px; border-radius: 12px; font-size: 15px; background: var(--ice-deep); }
.note.warn { background: #FFF1D6; }
.note.err { background: #FBE1E5; color: #7A0A1C; }
.reading { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.puck { width: 26px; height: 12px; border-radius: 50%; background: var(--boards); animation: slide 1s ease-in-out infinite alternate; }
@keyframes slide { from { transform: translateX(-12px); } to { transform: translateX(12px); } }

/* Game stats: entry form */
.stats-edit { border-top: 2px solid var(--ice-deep); padding-top: 10px; }
.stats-edit summary, .game-details summary { cursor: pointer; font-weight: 700; color: var(--blue-line); min-height: 40px; display: flex; align-items: center; }
.stat-row { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.stat-row span { text-align: center; font-size: 13px; font-weight: 700; color: var(--boards-soft); line-height: 1.2; }
.stat-row.head span { font: 800 13px var(--display); letter-spacing: .14em; }
.stat-row input { width: 100%; min-height: 44px; padding: 0 8px; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums;
  border: 2px solid var(--ice-deep); border-radius: 10px; background: var(--white); color: var(--boards); }

/* Game stats: read-only table */
.game-details { grid-column: 1 / -1; }
.game-stats { margin-top: 4px; font-size: 14px; }
.game-stats td, .game-stats thead th { text-align: center; width: 30%; font-weight: 700; }
.game-stats tbody th { text-align: center; font: 400 13px var(--body); color: var(--boards-soft); border: 0; }

/* Player stats: scrolls sideways on phones, name column stays put */
.table-wrap.scroll { display: block; }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; background: var(--white); z-index: 1; }

/* Games list */
.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.game { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.score {
  display: flex; align-items: baseline; gap: 10px;
  font: 800 24px/1 var(--display); text-transform: uppercase;
}
.score .num { font: 900 28px/1 var(--led); }
.score .win { color: var(--blue-line); }
.score .dec { font: 700 12px var(--body); letter-spacing: .08em; color: var(--boards-soft); }
.game .btn.link { grid-column: 1 / -1; justify-self: start; min-height: 32px; padding: 0; color: var(--goal-red); font-size: 14px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--ice-deep); }

/* Players */
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.player { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; }
.swatch { width: 10px; align-self: stretch; border-radius: 4px; background: linear-gradient(var(--c1) 60%, var(--c2) 60%); }
.player.inactive { opacity: .55; }

.empty { text-align: center; padding: 32px 16px; }
.empty p { margin: 0 0 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--boards); color: var(--white);
  padding: 12px 18px; border-radius: 12px; font-weight: 700;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

