/* 10-Ball Break & Run - styled after a dark billiard-club theme:
   black surfaces, yellow accent, condensed uppercase headings (Fjalla One),
   light body text (Heebo), pill buttons. */

:root {
  --bg: #0b0b0b;
  --bg-2: #121212;
  --panel: #181818;
  --panel-2: #202020;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: #959595;
  --accent: #ffbb35;
  --accent-2: #ff9f1a;
  --accent-ink: #0b0b0b;
  --green: #39d98a;
  --red: #ff5c5c;
  --blue: #6cb4ff;
  --radius: 6px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  --head: "Fjalla One", "Oswald", "Arial Narrow", sans-serif;
  --body: "Heebo", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 300;
  min-height: 100vh;
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 400; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 0.4em; line-height: 1.1; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 0.85rem; color: var(--muted); letter-spacing: 0.14em; margin-bottom: 0.9em; }
h3 .num { color: var(--accent); margin-right: 0.6em; }
h1 .accent, h2 .accent { color: var(--accent); }
p { margin: 0 0 0.75em; color: var(--muted); }
p.lead { color: var(--text); font-weight: 400; }
b, strong { color: var(--text); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.error { color: var(--red); font-weight: 500; }
.ok { color: var(--green); }
.warn { color: var(--accent); }
.num, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  padding: 0.75em 1.5em; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--panel-2); color: var(--text);
  font-family: var(--head); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; text-decoration: none; min-height: 2.6em; transition: transform 0.12s, filter 0.12s, background 0.12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: transparent; border-color: rgba(255, 92, 92, 0.5); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 0.45em 0.95em; font-size: 0.7rem; min-height: 2.1em; }
.btn.wide { width: 100%; }
.btn.huge { font-size: 1.25rem; padding: 0.9em 2.4em; box-shadow: 0 0 0 8px rgba(255, 187, 53, 0.12), 0 10px 30px rgba(255, 187, 53, 0.2); }
.btn.round { width: 3.2em; height: 3.2em; padding: 0; font-size: 1.1rem; border-radius: 50%; min-height: 0; }

label { display: block; font-family: var(--head); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0.9em 0 0.35em; }
input, select, textarea {
  width: 100%; padding: 0.7em 0.9em; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: #0e0e0e; color: var(--text); font: inherit; font-weight: 400;
}
input::placeholder { color: #5e5e5e; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); transform: scale(1.15); margin-right: 0.45em; }
input.inline { width: 5.5em; display: inline-block; }
input.code { font-family: var(--head); font-size: 2rem; letter-spacing: 0.4em; text-align: center; }
.check { display: flex; align-items: center; gap: 0.3em; color: var(--text); font-family: var(--body); font-size: 0.95rem; text-transform: none; letter-spacing: 0; margin-top: 1em; }
.row { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 10rem; }
.row > .shrink { flex: 0 0 auto; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1.1rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.8rem 1.25rem; background: #000; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { margin-right: auto; }
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
/* Optional club logo, uploaded from Settings. Height follows the bar it sits in; width follows the image. */
.brand .logo { height: 2.4rem; width: auto; max-width: min(10rem, 30vw); object-fit: contain; flex: 0 0 auto; }
.login-card .brand .logo { height: 2.8rem; }
.hero .logo { height: clamp(3rem, 9vw, 5.5rem); width: auto; max-width: min(18rem, 38vw); object-fit: contain; flex: 0 0 auto; }
.hero .brand-row { display: flex; align-items: center; gap: clamp(0.8rem, 2vw, 1.5rem); min-width: 0; }
.logo-preview { max-height: 5rem; max-width: 16rem; object-fit: contain; background: #000; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem; }
/* Small drop-down menu under a button (Display page: tab / window / here) */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 30; min-width: 13rem; background: #000; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.4rem; }
.menu-title { font-family: var(--head); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0.4rem 0.7rem; }
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); font: inherit; font-weight: 400; padding: 0.55rem 0.7rem; border-radius: 4px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }
.menu button.current { color: var(--accent); }
.menu button.current::after { content: " \2713"; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.12em; }
.brand h1 .accent { color: var(--accent); }
.brand p { margin: 0; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.tabs { display: flex; gap: 0.1rem; flex-wrap: wrap; }
.tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 0.55em 0.9em;
  font-family: var(--head); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.page { max-width: 1140px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card, .card.mt { margin-top: 1rem; }
.card.accent { border-color: rgba(255, 187, 53, 0.45); background: linear-gradient(180deg, rgba(255, 187, 53, 0.06), rgba(255, 187, 53, 0) 40%), var(--panel); }
.stats { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-strong); }
.stat.gold::before { background: var(--accent); }
.stat .label { font-family: var(--head); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.stat .value { font-family: var(--head); font-size: 1.9rem; margin-top: 0.1em; line-height: 1.1; }
.stat .value.money { color: var(--accent); }
.banner { padding: 0.8rem 1.1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; font-weight: 400; }
.banner.warn { background: rgba(255, 187, 53, 0.08); border-color: rgba(255, 187, 53, 0.45); color: #ffd88a; }
.banner.info { background: rgba(108, 180, 255, 0.07); border-color: rgba(108, 180, 255, 0.35); color: #cfe8ff; }
.banner.err { background: rgba(255, 92, 92, 0.08); border-color: rgba(255, 92, 92, 0.45); color: #ffc9c9; }
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 20;
  background: #000; border: 1px solid var(--accent); color: var(--text); padding: 0.75em 1.4em;
  border-radius: 999px; box-shadow: var(--shadow); font-weight: 400; max-width: 90vw;
}
.toast.err { border-color: var(--red); color: #ffc9c9; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.6em 0.6em; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-family: var(--head); color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 400; }
td { color: #dcdcdc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.dim td { color: var(--muted); }
tr.highlight td { background: rgba(255, 187, 53, 0.07); }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 0.15em 0.7em; border-radius: 999px; font-family: var(--head); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--line-strong); background: var(--panel-2); color: #dcdcdc; }
.pill.good { color: var(--green); border-color: rgba(57, 217, 138, 0.45); }
.pill.bad { color: var(--red); border-color: rgba(255, 92, 92, 0.45); }
.pill.gold { color: var(--accent); border-color: rgba(255, 187, 53, 0.55); }
.pill.pending { color: var(--blue); border-color: rgba(108, 180, 255, 0.5); }
.tick { color: var(--accent); margin-right: 0.4em; }

/* Pool balls */
.ball {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2em; height: 2.2em; border-radius: 50%; font-family: var(--head); color: #111;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #ececec 28%, #bcbcbc 100%);
  box-shadow: inset -3px -4px 8px rgba(0, 0, 0, 0.32), 0 3px 6px rgba(0, 0, 0, 0.5);
  font-size: 0.95em; flex: 0 0 auto;
}
.ball-10 { background: radial-gradient(circle at 35% 30%, #fff 0%, #fff 30%, #ffbb35 32%, #e08a00 100%); color: #111; }
.ball.off { filter: grayscale(1) brightness(0.45); }

/* Login */
.login-body { display: grid; place-items: center; padding: 1rem; background: radial-gradient(900px 500px at 50% -10%, rgba(255, 187, 53, 0.12), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 1.25rem; }
.login-card form { margin-bottom: 1rem; }
.steps { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.steps span { flex: 1; height: 3px; background: var(--line-strong); border-radius: 2px; }
.steps span.on { background: var(--accent); }

/* Draw page */
.draw-page { max-width: 1280px; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2.5rem) 3rem; }
.hero {
  margin: 0 calc(-1 * clamp(1rem, 3vw, 2.5rem)); padding: 2.5rem clamp(1rem, 3vw, 2.5rem) 2rem;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.75) 55%, rgba(0, 0, 0, 0.6) 100%),
    radial-gradient(700px 360px at 85% 40%, rgba(255, 187, 53, 0.35), transparent 70%),
    radial-gradient(500px 300px at 15% 90%, rgba(20, 90, 50, 0.6), transparent 70%),
    #0a0a0a;
  border-bottom: 1px solid var(--line);
}
.hero-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.hero .kicker { font-family: var(--head); color: var(--accent); letter-spacing: 0.22em; text-transform: uppercase; font-size: 0.78rem; margin-bottom: 0.5rem; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.6rem); margin: 0; line-height: 1; }
.hero .meta { text-align: right; color: var(--muted); font-size: 0.95rem; }
.hero .meta b { display: block; font-family: var(--head); font-size: 1.2rem; letter-spacing: 0.08em; text-transform: uppercase; }
.pot-hero { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1rem; margin: 1.25rem 0 1rem; }
.pot-hero .stat { padding: 1.2rem 1.5rem; }
.pot-hero .stat.main .value { font-size: clamp(3.2rem, 9vw, 6.8rem); line-height: 1; color: var(--accent); text-shadow: 0 6px 30px rgba(255, 187, 53, 0.25); }
.pot-hero .stat .value { font-size: clamp(2rem, 5vw, 3.4rem); }
.ball-strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.5rem; margin: 0.5rem 0 1.25rem; }
.ball-strip .cell { text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.25rem; transition: background 0.2s, border-color 0.2s; }
.ball-strip .cell .ball { font-size: clamp(0.9rem, 1.8vw, 1.4rem); margin-bottom: 0.35em; }
.ball-strip .cell .amt { font-family: var(--head); color: var(--accent); font-size: clamp(0.85rem, 1.7vw, 1.3rem); font-variant-numeric: tabular-nums; }
.ball-strip .cell .muted { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.ball-strip .cell.full { border-color: rgba(255, 187, 53, 0.6); }
.ball-strip .cell.made { background: rgba(255, 187, 53, 0.14); border-color: var(--accent); }
.ball-strip .cell.made .muted { color: var(--accent); }
.draw-panel { text-align: center; padding: 2rem 1.5rem; }
.draw-panel .status { font-family: var(--head); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.winner-name {
  font-family: var(--head); font-size: clamp(2.2rem, 7vw, 5rem); text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.05;
  min-height: 1.2em; color: var(--text);
}
.winner-name.reveal { color: var(--accent); animation: pop 0.6s ease-out; }
.winner-name.gold { color: var(--accent); }   /* steady state: no replayed animation on each refresh */
.winner-name.spinning { color: var(--muted); }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }
.winner-sub { color: var(--muted); font-size: 1.05rem; margin-top: 0.5rem; }
.at-table { border-color: rgba(255, 187, 53, 0.5); background: linear-gradient(180deg, rgba(255, 187, 53, 0.08), rgba(255, 187, 53, 0) 50%), var(--panel); }
/* "Balls pocketed" and "Won so far" blocks. Each block is a label over a big
   figure; the label gets its own line box and a gap so the tall condensed
   digits never run into it, and figures never wrap mid-amount. */
.sofar { display: flex; justify-content: center; align-items: flex-start; gap: 1.5rem 3rem; flex-wrap: wrap; margin-top: 1.25rem; }
.sofar > div { min-width: 0; }
.sofar .lbl { display: block; font-family: var(--head); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); line-height: 1.4; margin-bottom: 0.45rem; }
.sofar .big { display: block; font-family: var(--head); font-size: clamp(2.2rem, 6vw, 4.2rem); line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sofar .big.money { color: var(--accent); }
.sofar.compact { justify-content: flex-start; margin: 0.5rem 0 1.25rem; }
.sofar.compact .big { font-size: clamp(2rem, 4vw, 3rem); }
.sofar.compact .muted.small { margin-top: 0.3rem; }
.counter { display: inline-flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.sofar .counter { margin-top: 0; }
.counter .big { display: inline-block; font-family: var(--head); font-size: 2.6rem; line-height: 1.15; min-width: 1.6em; text-align: center; white-space: nowrap; }
.draw-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; }
.chance-list { list-style: none; margin: 0; padding: 0; }
.chance-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 0.75rem; align-items: center; padding: 0.45em 0; border-bottom: 1px solid var(--line); color: #dcdcdc; }
.chance-list li .bar { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.chance-list li .bar span { display: block; height: 100%; background: var(--accent); }
.chance-list li.drawn .name { color: var(--muted); text-decoration: line-through; }
.foot { margin-top: 1.75rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* ---------------------------------------------------------------------------
   TV layout for the display page. draw.js adds body.tv on wide landscape
   screens (16:9 / 16:10 TVs and projectors). Everything is sized in viewport
   units so the page fills the screen exactly, with no scrolling:
   header | pot figures | ball strip | draw panel + side lists | footer.
   --------------------------------------------------------------------------- */
body.tv { overflow: hidden; height: 100vh; }
body.tv .draw-page {
  height: 100vh; max-width: none; padding: 0 2vw 1vh;
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 1.2vh;
}
body.tv .hero { margin: 0 -2vw; padding: 1.6vh 2vw 1.4vh; }
body.tv .hero-inner { max-width: none; }
body.tv .hero .kicker { font-size: 1.7vh; margin-bottom: 0.4vh; }
body.tv .hero h1 { font-size: 5.2vh; }
body.tv .hero .logo { height: 7.5vh; max-width: 24vw; }
body.tv .hero .meta { font-size: 1.9vh; }
body.tv .hero .meta b { font-size: 2.4vh; }
body.tv .pot-hero { margin: 0; gap: 1vw; }
body.tv .pot-hero .stat { padding: 1.2vh 1.5vw; }
body.tv .pot-hero .stat .label { font-size: 1.6vh; }
body.tv .pot-hero .stat.main .value { font-size: 10vh; }
body.tv .pot-hero .stat .value { font-size: 5.5vh; }
body.tv .ball-strip { margin: 0; gap: 0.6vw; }
body.tv .ball-strip .cell { padding: 1vh 0.3vw; }
body.tv .ball-strip .cell .ball { font-size: 2.6vh; width: 2.1em; height: 2.1em; margin-bottom: 0.3em; }
body.tv .ball-strip .cell .amt { font-size: 2.6vh; }
body.tv .ball-strip .cell .muted { font-size: 1.4vh; }
body.tv .main-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1vw; min-height: 0; }
body.tv .main-row.solo { grid-template-columns: minmax(0, 1fr); }
body.tv .draw-panel { min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 2vh 2vw; overflow: hidden; }
body.tv .draw-panel .status { font-size: 2vh; margin-bottom: 1.2vh; }
body.tv .winner-name { font-size: 8.5vh; }
body.tv .winner-sub { font-size: 2.3vh; margin-top: 0.6vh; }
body.tv .sofar { margin-top: 1.5vh; gap: 2vh 5vw; }
body.tv .sofar .lbl { font-size: 1.7vh; margin-bottom: 0.4vh; }
body.tv .sofar .big { font-size: 7.5vh; }
body.tv .counter { margin-top: 1vh; }
body.tv .draw-panel .actions { margin-top: 1vh; }
body.tv .counter .big { font-size: 4vh; }
body.tv .btn.huge { font-size: 2.8vh; }
body.tv .btn.round { width: 6vh; height: 6vh; font-size: 2.4vh; }
body.tv .draw-grid { margin-top: 0 !important; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 1vh; min-height: 0; }
body.tv .draw-grid .card { min-height: 0; overflow: hidden; padding: 1.4vh 1.2vw; }
body.tv .draw-grid h3 { font-size: 1.7vh; margin-bottom: 0.8vh; }
body.tv .draw-grid table { font-size: 1.9vh; }
body.tv .draw-grid th, body.tv .draw-grid td { padding: 0.5vh 0.4vw; }
body.tv .draw-grid .pill { font-size: 1.3vh; }
body.tv .chance-list { columns: 2; column-gap: 1.5vw; font-size: 1.9vh; }
body.tv .chance-list li { break-inside: avoid; padding: 0.35vh 0; }
body.tv .chance-list li .bar { height: 0.4vh; }
body.tv .foot { margin-top: 0; padding-top: 0.8vh; font-size: 1.5vh; }
body.tv .foot a { color: var(--muted); }
body.tv .foot a:hover { color: var(--accent); }
body.tv .toast { font-size: 2vh; }

@media (max-width: 760px) {
  .pot-hero { grid-template-columns: 1fr 1fr; }
  .pot-hero .stat.main { grid-column: 1 / -1; }
  .ball-strip { grid-template-columns: repeat(5, 1fr); }
  .draw-grid { grid-template-columns: 1fr; }
  .hero .meta { text-align: left; }
}
