/* Unhinged 8-Ball League */

:root {
  --cloth: #1d4f73;
  --cloth-deep: #143a56;
  --chalk: #f2f5f7;
  --surface: #ffffff;
  --ink: #16232e;
  --muted: #5b6b78;
  --line: #d6dee5;
  --focus: #e9b300;

  --b1: #e9b300; --b2: #1d4fb8; --b3: #c62f2f; --b4: #5b2d8e;
  --b5: #e0601b; --b6: #1f7a4a; --b7: #7a1f2b; --b8: #141414;

  --ok: #1f7a4a; --warn: #b4520f; --bad: #b42727; --info: #1d4fb8;

  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chalk: #0f1a22;
    --surface: #17242e;
    --ink: #e6edf2;
    --muted: #9aabb8;
    --line: #2a3a47;
    --cloth: #1b4a6b;
    --cloth-deep: #11324a;
    --ok: #4cbf86; --warn: #f0954f; --bad: #f07272; --info: #7fa6f2;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font: 16px/1.5 var(--body);
}
a { color: var(--info); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------- header */

.top {
  background: var(--cloth);
  color: #fff;
  border-bottom: 4px solid var(--cloth-deep);
}
.top-inner { max-width: 760px; margin: 0 auto; padding: 14px 16px 0; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: .01em;
  color: #fff;
  text-decoration: none;
}
.account { font-size: .9rem; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
@media (max-width: 420px) { .brand { font-size: 1.35rem; } }
.account a, .account button { color: #fff; }
.nav {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav { margin-left: -8px; margin-right: -16px; padding-right: 16px; }
.nav a {
  color: #d4e3ee;
  text-decoration: none;
  padding: 8px 9px 10px;
  white-space: nowrap;
  font-weight: 600;
  font-size: .95rem;
  border-radius: 8px 8px 0 0;
}
.nav a[aria-current="page"] { background: var(--chalk); color: var(--ink); }
.nav a:hover:not([aria-current]) { color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
footer { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: .85rem; }

/* ---------------------------------------------------------- type */

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; margin-top: 1.6em; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; max-width: 68ch; }
.lead { font-size: 1.05rem; color: var(--muted); }
.dates { display: block; font-size: 1.1rem; font-family: var(--body); font-weight: 500; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------------------------------------------------- blocks */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.deadline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  border-left: 6px solid var(--b1);
}
.deadline strong { font-family: var(--display); font-size: 1.35rem; }

.notice { border-left: 6px solid var(--cloth); }
.notice h3 { margin-bottom: .2em; }
.notice .when { color: var(--muted); font-size: .85rem; margin-bottom: .4em; }
.notice p { white-space: pre-line; }

.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border: 1px solid var(--ok); }
.flash.error, .errors { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad); }
.flash.info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); border: 1px solid var(--info); }
.errors { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 1.2em; }
.pin-reveal { border: 2px dashed var(--b1); }
.pin-reveal .pin { font-family: var(--display); font-size: 2.4rem; letter-spacing: .15em; }

/* ---------------------------------------------------------- matches */

.matches { list-style: none; margin: 0; padding: 0; }
.match {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.match:last-child { border-bottom: 0; }
.match .who { font-weight: 600; }
.match .who a { color: inherit; text-decoration: none; }
.match .who a:hover { text-decoration: underline; }
.match .vs { color: var(--muted); font-weight: 400; padding: 0 .3em; }
.match .score { font-family: var(--display); font-size: 1.25rem; font-weight: 700; text-align: right; }
.match .meta { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.win { font-weight: 700; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}
.status::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--line);
}
.status.unverified { color: var(--warn); }
.status.unverified::before { background: var(--b5); }
.status.confirmed { color: var(--info); }
.status.confirmed::before { background: var(--b2); }
.status.disputed { color: var(--bad); }
.status.disputed::before { background: var(--b3); }
.status.approved { color: var(--ok); }
.status.approved::before { background: var(--b6); }
.status.bye::before { background: transparent; border: 2px solid var(--line); width: 6px; height: 6px; }
.tag { font-size: .75rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
       background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

/* ---------------------------------------------------------- balls */

.ball {
  --c: #8a98a4;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
  box-shadow: inset -4px -5px 0 rgba(0,0,0,.18);
}
.ball span {
  display: grid;
  place-items: center;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font: 700 .72rem/1 var(--body);
}
.ball.stripe {
  background: linear-gradient(#fff 0 22%, var(--c) 22% 78%, #fff 78%);
  border: 1px solid var(--line);
}
.ball.plain { --c: var(--line); box-shadow: none; }
.ball.plain span { background: transparent; color: var(--muted); }
.ball.n1, .ball.n9  { --c: var(--b1); }
.ball.n2, .ball.n10 { --c: var(--b2); }
.ball.n3, .ball.n11 { --c: var(--b3); }
.ball.n4, .ball.n12 { --c: var(--b4); }
.ball.n5, .ball.n13 { --c: var(--b5); }
.ball.n6, .ball.n14 { --c: var(--b6); }
.ball.n7, .ball.n15 { --c: var(--b7); }
.ball.n8 { --c: var(--b8); }

/* ---------------------------------------------------------- standings */

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th {
  text-align: right;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 2px solid var(--line);
}
.table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; padding-left: 0; }
.table .name { text-align: left; font-weight: 600; }
.table .name a { color: inherit; text-decoration: none; }
.table .name a:hover { text-decoration: underline; }
.table .pts { font-family: var(--display); font-size: 1.2rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.rank { width: 46px; }
.hide-sm { }
@media (max-width: 520px) { .hide-sm { display: none; } }

.boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.board h2 { margin-top: 0; font-size: 1.25rem; }
.board ol { margin: 0; padding: 0; list-style: none; }
.board li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.board li:last-child { border-bottom: 0; }
.board .val { margin-left: auto; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--display); font-size: 1.6rem; font-weight: 700; }

/* ---------------------------------------------------------- match detail */

.scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  text-align: center;
  background: var(--cloth);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 12px;
  margin-bottom: 16px;
}
.scoreline .player { font-weight: 700; }
.scoreline .big { font-family: var(--display); font-size: 3rem; font-weight: 700; line-height: 1; }
.scoreline .dash { font-family: var(--display); font-size: 2rem; opacity: .6; }
.scoreline .sub { font-size: .85rem; opacity: .85; }

.games td:nth-child(n+2) { text-align: center; }
.games th:nth-child(n+2) { text-align: center; }

/* ---------------------------------------------------------- forms */

label { font-weight: 600; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[inputmode],
select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 600 1rem/1 var(--body);
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--cloth);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--cloth-deep); }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 7px 12px; min-height: 34px; font-size: .9rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline { display: inline; }

fieldset.game {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 4px;
  margin: 0 0 12px;
  background: var(--surface);
}
fieldset.game legend {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0 6px;
}
.game .breaker { font-weight: 400; color: var(--muted); font-family: var(--body); font-size: .85rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; border: 0; padding: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: grid;
  place-items: center;
}
.seg input:checked + label { background: var(--cloth); color: #fff; border-color: var(--cloth); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 420px) { .seg.three { grid-template-columns: 1fr; } }
fieldset.plain { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
fieldset.plain legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact { font-size: .9rem; line-height: 1.4; }
.contact a { word-break: break-all; }
.game-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .game-row { grid-template-columns: 1fr; } }
.preview {
  position: sticky;
  bottom: 0;
  background: var(--cloth);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  box-shadow: 0 -6px 18px rgba(0,0,0,.12);
}
.preview .num { font-size: 1.5rem; }
.preview .right { text-align: right; }
.preview [data-result] { text-align: center; }

/* ---------------------------------------------------------- admin */

.admin-bar { background: #2d1f12; color: #f5d9a8; font-size: .85rem; }
.admin-bar .inner { max-width: 760px; margin: 0 auto; padding: 6px 16px; display: flex; gap: 14px; flex-wrap: wrap; }
.admin-bar a { color: #f5d9a8; font-weight: 600; }
.queue h2 { display: flex; align-items: center; gap: 8px; }
.count { font-family: var(--body); font-size: .8rem; background: var(--line); color: var(--ink);
         border-radius: 999px; padding: 2px 9px; }
.roster td, .roster th { text-align: left; }
.log td, .log th { text-align: left; font-size: .85rem; vertical-align: top; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .seg label { transition: background-color .15s, color .15s; }
}
.mt { margin-top: 12px; }
input[type=datetime-local], input[type=email], input[type=tel] {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink);
}
details > summary { cursor: pointer; font-weight: 600; color: var(--info); min-height: 32px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 0 0 16px; }
.details dt { font-size: .8rem; color: var(--muted); }
.details dd { margin: 0; font-weight: 600; }
.games tfoot th { text-align: center; border-top: 2px solid var(--line); border-bottom: 0; color: var(--ink); }
.games tfoot th:first-child { text-align: left; }
.games td.win { font-weight: 700; }
.totals { align-items: flex-start; }
.totals [data-runs] { opacity: .85; margin-top: 2px; }
