/* The same teal palette as the desktop app, laid out for a phone first: most of
   this gets used courtside on Monday nights with one thumb. */

:root {
  --deep: #0F5C4E;
  --pine: #266B5D;
  --forest: #3B786B;
  --sea: #5A9084;
  --sage: #83AFA2;
  --mist: #D2DFDC;
  --surface: #FFFFFF;
  --hover: #E7EFEC;
  --line: #BCD1CB;
  --ink: #14231F;
  --soft: #527068;
  --danger: #8C2F2F;
  --good: #1B6B4A;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule is weaker than any of ours, so anything given
   a display below would ignore it and stay on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }

/* -- the door ---------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--deep);
  z-index: 40;
}
.gate-card {
  width: 100%;
  max-width: 340px;
  padding: 26px 22px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
  text-align: center;
}
.gate-card h1 { font-size: 1.2rem; margin-bottom: 6px; }
.gate-card p { margin: 0 0 16px; font-size: .88rem; color: var(--soft); }
.gate-card input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  margin-bottom: 12px;
}
.gate-card button { width: 100%; }
.gate-card .error { margin: 0 0 12px; }

/* -- top bar ----------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  background: var(--deep);
  color: #fff;
}
.bar h1 { font-size: 1.1rem; }
.bar-right { display: flex; align-items: center; gap: 10px; }

/* -- the season picker, hung off the title ----------------------------- */

.bar-title { position: relative; min-width: 0; }

.season-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 4px 8px 4px 0;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
}
.season-button:hover { background: rgba(255, 255, 255, .12); }
.season-button .caret { font-size: .7rem; opacity: .8; }

.season-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 15;
  min-width: 250px;
  max-width: min(88vw, 340px);
  padding: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 35, 31, .22);
}
.menu-heading {
  margin: 2px 8px 6px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--soft);
}
.season-menu ul { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.season-menu li button,
.menu-action {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: .9rem;
  color: inherit;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.season-menu li button:hover, .menu-action:hover { background: var(--hover); }
.season-menu li button.on { background: var(--deep); color: #fff; font-weight: 600; }
.menu-action {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
  color: var(--deep);
  font-weight: 600;
}

.live {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 3px 9px 3px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  position: relative;
}
.live::before {
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  width: 6px; height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: #7BD6AE;
}
.live.stale::before { background: #E0B252; }
.live.gone::before { background: #D98A8A; }

/* -- tabs -------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  background: var(--deep);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--mist);
  font: inherit;
  font-size: .9rem;
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tabs button.on { color: #fff; border-bottom-color: var(--sage); font-weight: 600; }

main { padding: 14px; max-width: 1100px; margin: 0 auto; }

/* -- week pickers ------------------------------------------------------ */

.weeks {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}
.weeks button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--soft);
  font: inherit;
  font-size: .85rem;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.weeks button:hover { background: var(--hover); }
.weeks button.on {
  background: var(--deep);
  border-color: var(--deep);
  color: #fff;
  font-weight: 600;
}

/* -- cards ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.split { display: grid; gap: 12px; grid-template-columns: 1fr; }
.split-inner { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (min-width: 860px) { .split { grid-template-columns: 1fr 1fr; } }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
/* The points note on the left, the download on the right, their tops level. */
.ladder-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  margin-top: 12px;
}
.ladder-footer .note { flex: 1 1 240px; margin: 0; }
/* Stays in the corner when the note pushes it onto its own line. */
.ladder-footer button { flex: 0 0 auto; margin-left: auto; }
.note { margin: 6px 0 10px; font-size: .82rem; color: var(--soft); }
.empty { text-align: center; color: var(--soft); padding: 40px 20px; }
.error { color: var(--danger); font-size: .85rem; }

/* -- buttons ----------------------------------------------------------- */

button { font-family: inherit; }
.primary, .ghost, .danger {
  border-radius: 8px;
  font: inherit;
  font-size: .88rem;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
}
.primary { background: var(--deep); color: #fff; }
.primary:hover { background: var(--pine); }
a.primary { display: inline-block; text-decoration: none; }
.danger { background: var(--danger); color: #fff; }
.danger:hover { background: #A33A3A; }
.ghost { background: transparent; border-color: var(--sage); color: inherit; }
.bar .ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.ghost:hover { background: rgba(255, 255, 255, .12); }
main .ghost:hover { background: var(--hover); }
button:disabled { opacity: .45; cursor: default; }

.link { color: var(--deep); font-size: .88rem; }

/* -- scoring ----------------------------------------------------------- */

.game { margin-bottom: 12px; }

/* -- the quarter clocks ------------------------------------------------ */

.clock-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.clock-bar .note { flex: 1 1 220px; margin: 0; }

.clock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  vertical-align: 2px;
}
.clock-face {
  font-variant-numeric: tabular-nums;
  font-size: .82rem;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
  color: var(--soft);
}
.clock-face.running { color: var(--deep); }
.clock-face.done { color: var(--danger); }

.clock-key {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: inherit;
  font-size: .8rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.clock-key:hover { background: var(--hover); }
.clock-key:disabled { opacity: .3; cursor: default; }

.lock {
  margin-left: 10px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: .74rem;
  color: var(--soft);
  cursor: pointer;
  white-space: nowrap;
  vertical-align: 2px;
}
.lock:hover { background: var(--hover); }
.lock.shut {
  background: var(--deep);
  border-color: var(--deep);
  color: #fff;
  font-weight: 600;
}
/* A locked game still shows its score - it is only the buttons that go quiet. */
.game.locked .quarter button,
.final-game.locked .quarter button { opacity: .35; cursor: default; }
.game.locked .total,
.final-game.locked .total { color: var(--soft); }
.game-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.game-time { font-weight: 700; color: var(--deep); }
.game-duty { font-size: .78rem; color: var(--soft); text-align: right; }

.score {
  display: grid;
  grid-template-columns: minmax(84px, 1.4fr) repeat(4, minmax(64px, 1fr)) minmax(56px, .8fr);
  gap: 6px;
  align-items: center;
  min-width: 460px;
}
.score .head { font-size: .74rem; color: var(--soft); text-align: center; text-transform: uppercase; letter-spacing: .05em; }
.score .side { font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.score .total { font-size: 1.25rem; font-weight: 700; text-align: center; color: var(--deep); }

.quarter { text-align: center; }
.quarter .count {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  padding: 2px 0;
}
.quarter .keys { display: flex; gap: 4px; justify-content: center; }
.quarter button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  touch-action: manipulation;
}
.quarter .plus { background: var(--deep); border-color: var(--deep); color: #fff; }
.quarter .plus:hover { background: var(--pine); }
.quarter .minus:hover { background: var(--hover); color: var(--danger); }
.scroller { overflow-x: auto; }

/* -- finals ------------------------------------------------------------ */

.final-game { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--hover); }
.final-game:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.final-game.pending { opacity: .72; }
.final-label { font-size: .82rem; color: var(--soft); }

.umpire-box {
  width: 190px;
  max-width: 46vw;
  margin-top: 4px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: .82rem;
  text-align: right;
}

.warn-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #FBF1DC;
  border: 1px solid #E4CE94;
  font-size: .86rem;
}

/* -- tables ------------------------------------------------------------ */

.grid { width: 100%; border-collapse: collapse; font-size: .88rem; }
.grid th, .grid td { padding: 7px 8px; text-align: center; white-space: nowrap; }
.grid th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--soft); border-bottom: 1px solid var(--line); }
.grid td { border-bottom: 1px solid var(--hover); }
.grid .left { text-align: left; white-space: normal; }
.grid .strong { color: var(--deep); }
.grid tbody td.strong { font-weight: 700; }
.grid tbody tr:hover { background: var(--hover); }

/* -- votes ------------------------------------------------------------- */

.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: .9rem;
  margin-bottom: 10px;
}
.vote-list { max-height: 60vh; overflow-y: auto; }
.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--hover);
}
.vote-row .who { font-size: .9rem; overflow-wrap: anywhere; }
.vote-row .team { display: block; font-size: .76rem; color: var(--soft); }
.vote-row input {
  width: 58px;
  padding: 6px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.vote-row.has input { border-color: var(--sea); font-weight: 700; }

.standings { margin: 6px 0 0; padding-left: 22px; font-size: .88rem; }
.standings li { padding: 2px 0; }
.standings .count { float: right; font-weight: 700; color: var(--deep); }
.standings .team { display: block; font-size: .76rem; color: var(--soft); }

/* -- fixture / messages ------------------------------------------------ */

.week-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.week-head .when { font-size: .82rem; color: var(--soft); }
.bye { font-size: .82rem; color: var(--soft); margin-top: 8px; }

.message {
  white-space: pre-wrap;
  font: inherit;
  font-size: .95rem;
  margin: 10px 0 0;
  padding: 12px;
  background: var(--hover);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.night-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--hover);
  font-size: .88rem;
}
.night-row:last-child { border-bottom: 0; }
.night-when { flex: 0 0 auto; min-width: 120px; font-variant-numeric: tabular-nums; }
.night-what { flex: 1 1 auto; color: var(--soft); overflow-wrap: anywhere; }
.night-row.finals .night-what { color: var(--deep); font-weight: 600; }
.night-row.skipped .night-when { text-decoration: line-through; color: var(--soft); }
.ghost.small { padding: 4px 10px; font-size: .8rem; }

.names-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.names-row .captain { flex: 0 0 38%; font-size: .88rem; overflow-wrap: anywhere; }
.names-row input { flex: 1 1 auto; min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .9rem; }

.match .versus { color: var(--soft); font-size: .82rem; font-style: italic; }

.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: .78rem; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }
.field input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: .9rem;
}

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
/* The file picker carries its own bottom margin for when it stands alone. In a
   row it would leave its neighbours stretching past it, so it goes. */
.row-actions .file { margin-bottom: 0; }

/* A pair of buttons that do opposite halves of the same job, sized to match. */
.matched > .primary,
.matched > .ghost,
.matched > .danger,
.matched .file span {
  min-width: 168px;
  text-align: center;
}
.danger-card { border-color: #E2C4C4; }
.danger-card h2 { color: var(--danger); }

.summary { font-weight: 600; margin: 12px 0 0; }
.good { color: var(--good); font-size: .88rem; margin: 10px 0 0; }
.checks { margin: 4px 0 10px; padding-left: 18px; font-size: .84rem; color: var(--soft); }
.checks li { padding: 1px 0; }
.checks.warn li { color: var(--ink); }
.checks.bad li { color: var(--danger); font-weight: 600; }

.file { display: inline-block; margin-bottom: 10px; }
.file input { display: none; }
.file span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px dashed var(--sage);
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
}
.file span:hover { background: var(--hover); }

.activity { margin: 6px 0 0; padding-left: 18px; font-size: .82rem; color: var(--soft); }

/* -- overlays ---------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 31, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal-card { width: 100%; max-width: 340px; margin: 0; }
.modal input { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-top: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .85rem;
  z-index: 30;
}
.toast.bad { background: var(--danger); }
