/* =============================================================
   8-Ball Pool League
   Look: match-room baize. Deep cloth green, brass rails, chalk blue.
   The one loud element is the rack of numbered position balls in the
   league table; everything around it stays quiet.
   ============================================================= */

:root {
  --cloth-900: #07231a;   /* page */
  --cloth-800: #0c3327;   /* panels */
  --cloth-700: #114430;   /* raised rows */
  --rail:      #5a3d28;   /* cushion timber, used for hairlines */
  --brass:     #c9973f;   /* pocket plates, leader highlights */
  --chalk:     #74b6d6;   /* links, focus, accents */
  --ivory:     #f2efe4;   /* cue ball: primary text */
  --sage:      #9db5a6;   /* secondary text */
  --red:       #c2453c;
  --shadow:    0 1px 0 rgba(255,255,255,.04), 0 10px 24px rgba(0,0,0,.28);

  --pad: 1rem;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background:
    radial-gradient(120% 60% at 50% 0%, #0e3a2b 0%, var(--cloth-900) 60%) fixed;
  color: var(--ivory);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(920px, 100% - 1.6rem); margin-inline: auto; }

main.wrap { padding-block: 1.25rem 3rem; }

a { color: var(--chalk); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #a7d5ea; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--brass); color: #16110a; padding: .5rem .75rem;
}
.skip:focus { left: .5rem; top: .5rem; z-index: 50; }

/* ---------- headings ---------- */

h1, h2, h3 {
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 .4rem;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; margin-top: 2rem; }
h3 { font-size: 1rem; }
.lede { color: var(--sage); margin: 0 0 1.25rem; }

/* ---------- masthead + nav ---------- */

.masthead {
  border-bottom: 1px solid rgba(90,61,40,.55);
  background: rgba(4,20,15,.72);
  backdrop-filter: blur(6px);
}
.masthead-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; min-height: 56px;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ivory); text-decoration: none; }
.brand .ball { width: 26px; height: 26px; }
.brand .ball i { width: 14px; height: 14px; font-size: 9px; }
.brand-name { font-weight: 800; letter-spacing: -.01em; font-size: 1.02rem; }
.who { color: var(--sage); font-size: .85rem; text-decoration: none; }
.tag {
  font-size: .68rem; border: 1px solid var(--brass); color: var(--brass);
  border-radius: 999px; padding: 0 .4em; vertical-align: 1px;
}

.nav { border-bottom: 1px solid rgba(90,61,40,.35); background: rgba(4,20,15,.45); }
.nav-inner { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav a {
  flex: 1 0 auto; text-align: center; white-space: nowrap;
  padding: .7rem .8rem; color: var(--sage); text-decoration: none;
  font-size: .9rem; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.nav a.on { color: var(--ivory); border-bottom-color: var(--brass); }

/* ---------- panels ---------- */

.card {
  background: var(--cloth-800);
  border: 1px solid rgba(90,61,40,.45);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }

.muted { color: var(--sage); }
.small { font-size: .85rem; }

/* ---------- league table ---------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.league {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.league th, table.league td { padding: .5rem .35rem; }
table.league thead th {
  font: 600 .7rem/1 "Archivo Narrow", Archivo, sans-serif;
  color: var(--sage);
  text-align: right;
  border-bottom: 1px solid rgba(90,61,40,.6);
  padding-bottom: .45rem;
}
table.league thead th.player, table.league thead th.pos { text-align: left; }
table.league td { text-align: right; border-bottom: 1px solid rgba(255,255,255,.05); }
table.league td.player { text-align: left; font-weight: 600; width: 99%; }
table.league td.pts { font-weight: 800; font-size: 1.05rem; }
table.league tbody tr:hover { background: rgba(255,255,255,.03); }
table.league .num { font-family: "Archivo Narrow", Archivo, sans-serif; font-weight: 600; }

.pname { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14ch; }
.pname.me { color: var(--brass); }

/* position balls: solids 1-7, stripes from 9 up, same as a real rack */
.ball {
  --ballcolor: #6b6b6b;
  position: relative;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: radial-gradient(circle at 34% 26%, rgba(255,255,255,.55) 0 8%, var(--ballcolor) 45%, #05150f 130%);
  box-shadow: inset 0 -3px 5px rgba(0,0,0,.45);
}
.ball::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
}
.ball.stripe::before {
  background: linear-gradient(to bottom,
    var(--ivory) 0 24%, transparent 24% 76%, var(--ivory) 76% 100%);
  opacity: .92;
}
.ball i {
  position: relative;
  display: grid; place-items: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ivory); color: #10130f;
  font: 700 10px/1 "Archivo Narrow", Archivo, sans-serif;
  font-style: normal;
}
.b1 { --ballcolor: #e2b13c; } .b2 { --ballcolor: #2b5aa5; }
.b3 { --ballcolor: #c2453c; } .b4 { --ballcolor: #6b4b8a; }
.b5 { --ballcolor: #d3762a; } .b6 { --ballcolor: #1c7a4c; }
.b7 { --ballcolor: #7c2f2c; } .b8 { --ballcolor: #15171a; }

tr.leader td { background: linear-gradient(to right, rgba(201,151,63,.14), transparent 60%); }

.form { display: inline-flex; gap: 3px; }
.form b {
  width: 16px; height: 16px; border-radius: 3px;
  font: 600 10px/16px "Archivo Narrow", Archivo, sans-serif;
  text-align: center; color: #06150f;
}
.form .W { background: #4fae7a; }
.form .D { background: #9aa8a0; }
.form .L { background: var(--red); color: #fff2f0; }

/* ---------- fixtures ---------- */

.round-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem; margin: 1.4rem 0 .5rem;
  border-bottom: 1px solid rgba(90,61,40,.5); padding-bottom: .3rem;
}
.round-head h3 { margin: 0; }
.round-head span { color: var(--sage); font-size: .8rem; }

.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  padding: .65rem .5rem;
  border-bottom: 1px solid rgba(255,255,255,.055);
}
.match:last-child { border-bottom: 0; }
.match .side { min-width: 0; }
.match .side.b { text-align: right; }
.match .side span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .side .win { font-weight: 700; }
.match .side .lose { color: var(--sage); }
.match .score {
  font: 700 1rem/1 "Archivo Narrow", Archivo, sans-serif;
  background: var(--cloth-700);
  border: 1px solid rgba(90,61,40,.6);
  border-radius: 6px; padding: .3rem .5rem; min-width: 3.4rem; text-align: center;
  font-variant-numeric: tabular-nums;
}
.match .score.todo { color: var(--sage); font-weight: 600; background: transparent; border-style: dashed; }
.match .meta { grid-column: 1 / -1; color: var(--sage); font-size: .78rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.match .meta a { text-decoration: none; font-weight: 600; }
.match .meta .lock { color: var(--brass); }

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

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.hint { color: var(--sage); font-size: .8rem; margin: .25rem 0 0; }

input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], select {
  width: 100%;
  font: inherit;
  color: var(--ivory);
  background: #08291e;
  border: 1px solid rgba(90,61,40,.7);
  border-radius: 8px;
  padding: .6rem .7rem;
  min-height: 44px;
}
input::placeholder { color: #6f8579; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--sage) 50%), linear-gradient(135deg, var(--sage) 50%, transparent 50%); background-position: right 1rem center, right .72rem center; background-size: 6px 6px; background-repeat: no-repeat; }

.frames {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: end;
}
.frames .v { padding-bottom: .7rem; color: var(--sage); font-weight: 700; }
.frames input { text-align: center; font-size: 1.3rem; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .95rem/1 Archivo, sans-serif;
  min-height: 44px; padding: .7rem 1.1rem;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--brass); color: #1b1305;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #dba94f; color: #1b1305; }
.btn-ghost { background: transparent; border-color: rgba(116,182,214,.45); color: var(--chalk); }
.btn-ghost:hover { background: rgba(116,182,214,.1); color: var(--chalk); }
.btn-danger { background: transparent; border-color: rgba(194,69,60,.6); color: #eb8b84; }
.btn-danger:hover { background: rgba(194,69,60,.15); color: #eb8b84; }
.btn-sm { min-height: 36px; padding: .4rem .7rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- flashes + notes ---------- */

.flash {
  border-radius: 8px; padding: .7rem .85rem; margin: 0 0 1rem;
  border-left: 3px solid var(--chalk); background: rgba(116,182,214,.12);
}
.flash-ok   { border-left-color: #4fae7a; background: rgba(79,174,122,.14); }
.flash-warn { border-left-color: var(--brass); background: rgba(201,151,63,.14); }
.flash-err  { border-left-color: var(--red);   background: rgba(194,69,60,.16); }

.empty {
  border: 1px dashed rgba(90,61,40,.7); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; color: var(--sage);
}
.empty p { margin: 0 0 .8rem; }

/* ---------- progress ---------- */

.progress { height: 6px; border-radius: 3px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: .6rem; }
.progress > span { display: block; height: 100%; background: var(--brass); }

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

.plist { list-style: none; margin: 0; padding: 0; }
.plist li {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .6rem 0; border-bottom: 1px solid rgba(255,255,255,.06);
}
.plist li:last-child { border-bottom: 0; }
.plist .who-name { font-weight: 600; flex: 1 1 8rem; min-width: 0; }
.plist .btn-row form { display: inline-flex; }
.plist summary { list-style: none; cursor: pointer; }
.plist summary::-webkit-details-marker { display: none; }
.plist details { flex: 0 0 auto; }
.plist details[open] { flex: 1 0 100%; }
.plist .state { font-size: .78rem; color: var(--sage); }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; margin: 0; }
dl.kv dt { color: var(--sage); font-size: .85rem; }
dl.kv dd { margin: 0; font-weight: 600; }

/* ---------- responsive trims ---------- */

@media (max-width: 620px) {
  .hide-sm { display: none !important; }
  h1 { font-size: 1.4rem; }
  table.league th, table.league td { padding: .45rem .25rem; }
}
@media (max-width: 420px) {
  .hide-xs { display: none !important; }
  .pname { max-width: 10ch; }
}
@media (min-width: 720px) {
  :root { --pad: 1.35rem; }
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
}

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
