/* CUE CLUB — a pool hall after dark: walnut panels, green baize, brass and
   ivory, one warm lamp over the table. Nothing here depends on web/style.css
   (it is not loaded). The table itself is drawn on #table by js/table.js. */
:root {
  --ink: #0b0806;
  --panel: rgba(28, 18, 12, 0.88);
  --panel-solid: #1d130d;
  --edge: rgba(240, 214, 170, 0.18);
  --text: #f4ead6;
  --dim: rgba(244, 234, 214, 0.64);
  --accent: #e8b44c;
  --baize: #1b8a5a;
  --red: #e5584a;
  --fs-accent: #e8b44c;
  --fs-text: #f4ead6;
  --fs-dim: rgba(244, 234, 214, 0.62);
  --fs-edge: rgba(240, 214, 170, 0.16);
  --fs-panel: rgba(255, 255, 255, 0.05);
  --lb-accent: #e8b44c;
  --lb-text: #f4ead6;
  --lb-dim: rgba(244, 234, 214, 0.62);
  --lb-edge: rgba(240, 214, 170, 0.18);
  --lb-panel: #1d130d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; color: var(--text);
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(255, 196, 120, 0.16), transparent 70%),
    radial-gradient(ellipse at 50% 120%, #0d2a1d 0%, transparent 60%),
    linear-gradient(180deg, #1a110b 0%, #0d0907 100%);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
/* web/style.css pins .volume-slider position:fixed top:12px on pages that load
   it. This page does not, but a shared strip must never land in a corner. */
.volume-slider { position: static !important; top: auto !important; }

.cc-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.muted { color: var(--dim); font-size: 13px; }
.ball-icon { display: inline-block; vertical-align: middle; }

/* ── menus ─────────────────────────────────────────────────────────────── */
#lobbyOverlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-start;
  justify-content: center; overflow-y: auto; padding: 18px 12px 28px;
  background: rgba(8, 5, 3, 0.35);
}
.card {
  width: 100%; max-width: 900px; margin: auto; padding: 22px 22px 18px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); text-align: center;
}
#joinPane, #countPane, #errorPane, #trickEndPane { max-width: 440px; margin: 0 auto; }
#resultsPane { max-width: 640px; margin: 0 auto; }
.cc-title {
  margin: 4px 0 6px; font-size: 46px; font-weight: 900; letter-spacing: 0.02em; line-height: 1;
  font-family: Georgia, "Times New Roman", serif; color: var(--text);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}
.cc-title.small { font-size: 27px; margin: 0; }
.title-accent { margin-left: 0.22em; color: var(--accent); font-style: italic; }
.tagline { color: var(--dim); font-size: 15px; line-height: 1.45; margin: 8px 0 12px; }
.tagline b { color: var(--text); }
.join-balls { display: flex; justify-content: center; gap: 6px; margin: 6px 0 16px; }
#nameInput {
  width: 100%; padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; font-size: 16px;
  border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.35); color: var(--text); text-align: center;
}
button.primary {
  display: block; width: 100%; padding: 13px 16px; border: 0; border-radius: 12px;
  font-weight: 800; font-size: 16px; color: #1c1206;
  background: linear-gradient(180deg, #f6d27c, #d99a2b);
  box-shadow: 0 3px 0 #8a5a12, 0 8px 20px rgba(0, 0, 0, 0.35);
}
button.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a5a12; }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  padding: 9px 14px; border-radius: 11px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.06); font-weight: 700; font-size: 14px;
}
button.ghost:hover { background: rgba(255, 255, 255, 0.12); }
button.ghost.small { padding: 6px 10px; font-size: 13px; }
#joinPane .ghost { width: 100%; margin-top: 8px; }
.lobby-audio { margin: 12px auto 0; display: flex; justify-content: center; }
.back-link { display: inline-block; margin-top: 12px; color: var(--dim); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.btn-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.btn-row .primary { width: auto; flex: 1 1 160px; }
.btn-row .ghost { flex: 0 1 auto; }

.hub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hub-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; margin: 14px 0 12px; border-bottom: 1px solid var(--edge); }
.tab {
  padding: 10px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 12px 12px 0 0;
  background: transparent; font-weight: 800; color: var(--dim);
}
.tab.active { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--edge); }
.tab-stars { font-weight: 600; font-size: 12px; color: var(--accent); margin-left: 4px; }

.multi-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: left; }
.player-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.player-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 11px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.04);
}
.player-row.me { border-color: rgba(232, 180, 76, 0.55); background: rgba(232, 180, 76, 0.08); }
.pname { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptag { font-size: 12px; color: var(--dim); white-space: nowrap; }
.match-line {
  font-family: Georgia, serif; font-size: 21px; font-weight: 700; margin: 2px 0 6px; color: var(--text);
}
.small-note { margin: 0 0 12px; line-height: 1.4; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.setting > span { font-weight: 700; color: var(--dim); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 11px; overflow: hidden; }
.seg button { padding: 7px 12px; border: 0; background: transparent; font-weight: 700; font-size: 13px; color: var(--dim); }
.seg button.on { background: rgba(232, 180, 76, 0.24); color: var(--text); }
.seg button:disabled { cursor: default; }
#startBtn { margin-top: 6px; }
#waitHost { text-align: center; }
.live-note {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(232, 180, 76, 0.4);
  background: rgba(232, 180, 76, 0.08); font-size: 14px;
}

.path-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 10px; flex-wrap: wrap; text-align: left; }
.path-head h3 { margin: 0; font-family: Georgia, serif; font-size: 19px; }
.ladder { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.trick-card {
  position: relative; padding: 8px; border-radius: 13px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.05); text-align: left; display: flex; flex-direction: column; gap: 6px;
  align-items: center;
}
.trick-card:hover:not(.locked) { background: rgba(255, 255, 255, 0.11); border-color: rgba(232, 180, 76, 0.6); }
.trick-card.perfect { border-color: rgba(232, 180, 76, 0.55); }
.trick-card.locked { opacity: 0.5; cursor: default; }
.trick-mini { border-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); max-width: 100%; }
.trick-info { width: 100%; display: flex; flex-direction: column; gap: 1px; }
.trick-info b { font-size: 13px; }
.trick-info small { font-size: 11px; color: var(--dim); }
.trick-info em { color: var(--accent); font-style: normal; }
.trick-stars { color: var(--accent); letter-spacing: 1px; font-size: 14px; }
.trick-stars i { color: rgba(255, 255, 255, 0.18); font-style: normal; }
.lock { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); font-size: 22px; }

.count-info { font-family: Georgia, serif; font-size: 22px; font-weight: 700; margin-top: 6px; }
.countdown { font-size: 88px; font-weight: 900; color: var(--accent); line-height: 1.1; }
.end-line { color: var(--dim); margin: 6px 0; }
.end-frames { font-weight: 700; margin-bottom: 8px; }
.end-credits { color: var(--accent); font-weight: 800; margin: 8px 0; }
.end-stars { font-size: 44px; color: var(--accent); letter-spacing: 6px; margin: 8px 0 2px; }
.end-stars i { color: rgba(255, 255, 255, 0.15); font-style: normal; }
#resultTable, #resultAwards { text-align: left; }

/* ── the table screen ──────────────────────────────────────────────────── */
#playScreen {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#playTop {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; min-height: 48px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15));
}
.icon-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.07); font-size: 17px; font-weight: 800; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.plates { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.plate {
  flex: 1 1 0; min-width: 0; overflow: hidden; display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  border-radius: 12px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.plate.right { justify-content: flex-end; text-align: right; }
.plate.active { border-color: rgba(232, 180, 76, 0.85); background: rgba(232, 180, 76, 0.12);
  box-shadow: 0 0 0 2px rgba(232, 180, 76, 0.25), 0 0 18px rgba(232, 180, 76, 0.25); }
.pl-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.plate.right .pl-main { align-items: flex-end; }
.pl-main .mg-name-title { font-size: 10px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pl-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.plate.me .pl-name::after { content: " (you)"; font-weight: 600; color: var(--dim); font-size: 12px; }
.pl-balls { display: flex; gap: 2px; flex-wrap: nowrap; min-height: 15px; align-items: center; }
.pl-balls .gone { opacity: 0.18; filter: grayscale(1); }
.pl-open { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.pl-frames {
  font-family: Georgia, serif; font-size: 22px; font-weight: 900; color: var(--accent); min-width: 18px; text-align: center;
}
.clock { flex: 0 0 74px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.clock-track { width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.clock-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; }
.clock-track i.low { background: var(--red); }
#clockText { font-size: 12px; font-weight: 800; color: var(--dim); min-height: 14px; }
.trick-bar { flex: 1; display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.trick-bar b { font-family: Georgia, serif; font-size: 18px; }
.trick-bar span { font-size: 13px; color: var(--dim); }
.trick-left { color: var(--accent) !important; font-weight: 800; }
.watch-tag { font-size: 12px; font-weight: 800; color: var(--accent); white-space: nowrap; }

#playMain { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr auto; }
#tableWrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#table { position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair; }
#playScreen:not(.my-turn) #table { cursor: default; }
#controls {
  width: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 8px 8px 12px; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.3));
}
.power-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 1 auto; max-height: 300px; min-height: 120px; width: 100%; }
.power-bar {
  position: relative; flex: 1; width: 34px; border-radius: 17px; overflow: hidden; touch-action: none; cursor: ns-resize;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.35));
  border: 1px solid var(--edge); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}
.power-fill {
  --p: 0%;
  position: absolute; left: 0; right: 0; top: 0; height: var(--p);
  background: linear-gradient(180deg, #3dd68c, #e8c24c 60%, #e5584a);
  box-shadow: 0 0 12px rgba(232, 180, 76, 0.5);
}
.power-bar::after {
  content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px; width: 2px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0 2px, transparent 2px 12px);
}
.ctl-label { font-size: 11px; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; text-align: center; }
.spin-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spin-pad {
  position: relative; width: 62px; height: 62px; border-radius: 50%; touch-action: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #ffffff, #efe8d6 45%, #b9b1a0 100%);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.spin-pad::before, .spin-pad::after { content: ""; position: absolute; background: rgba(0, 0, 0, 0.12); }
.spin-pad::before { left: 50%; top: 8px; bottom: 8px; width: 1px; }
.spin-pad::after { top: 50%; left: 8px; right: 8px; height: 1px; }
.spin-pad i {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: #2a5ea8; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8); left: 50%; top: 50%;
}
.fine { display: flex; gap: 6px; }
.disabled { opacity: 0.4; pointer-events: none; }
.trick-hint {
  display: none; padding: 6px 14px 8px; font-size: 13px; color: var(--dim); text-align: center;
  background: rgba(0, 0, 0, 0.35);
}
#playScreen[data-mode="trick"] .trick-hint { display: block; }
#playScreen[data-mode="watch"] #controls { visibility: hidden; }

.toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 5; max-width: 86%;
  padding: 9px 16px; border-radius: 12px; background: rgba(15, 10, 6, 0.86); border: 1px solid var(--edge);
  font-weight: 700; font-size: 14px; text-align: center; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.toast.show { animation: toastIn 0.22s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; max-width: 90%;
  padding: 18px 26px; border-radius: 16px; background: rgba(15, 10, 6, 0.9); border: 1px solid rgba(232, 180, 76, 0.6);
  font-family: Georgia, serif; font-size: 26px; font-weight: 800; text-align: center; pointer-events: none;
}
.banner small { display: block; font-family: "Trebuchet MS", system-ui, sans-serif; font-size: 13px; color: var(--dim); font-weight: 600; margin-top: 6px; }

.pop {
  position: fixed; right: 10px; top: 58px; z-index: 30; padding: 10px 12px; border-radius: 14px;
  background: var(--panel-solid); border: 1px solid var(--edge); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ── help ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 18px 12px; background: rgba(5, 3, 2, 0.6);
}
.modal-card {
  position: relative; width: 100%; max-width: 860px; margin: auto; padding: 20px 22px;
  background: var(--panel-solid); border: 1px solid var(--edge); border-radius: 18px;
}
.help-card h2 { margin: 0 0 10px; font-family: Georgia, serif; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.help-grid h3 { margin: 4px 0 6px; color: var(--accent); font-size: 15px; }
.help-grid p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.help-close { position: absolute; right: 12px; top: 12px; }
#helpOk { margin-top: 12px; }

/* the leaderboard overlay must not be clamped by an .overlay-card cap */
.lb-panel, .lb-card { max-width: 640px; }

/* ── phones ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .multi-cols, .help-grid { grid-template-columns: 1fr; }
  #resultTable .fs-table { width: 100%; font-size: 13px; }
  #resultTable .fs-table th, #resultTable .fs-table td { padding-left: 5px; padding-right: 5px; letter-spacing: 0; }
  .card { padding: 16px 14px 14px; border-radius: 16px; }
  .cc-title { font-size: 38px; }
  .ladder { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
/* portrait: the table turns (js/table.js), the controls run along the bottom */
@media (orientation: portrait) {
  #playMain { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #controls {
    width: auto; flex-direction: row; justify-content: space-between; gap: 10px; padding: 8px 12px 12px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35));
  }
  .power-wrap { flex-direction: column; max-height: none; min-height: 0; flex: 1 1 auto; }
  .power-bar { flex: 0 0 auto; width: 100%; height: 40px; cursor: ew-resize; }
  .power-fill { top: 0; bottom: 0; left: 0; right: auto; width: var(--p); height: auto;
    background: linear-gradient(90deg, #3dd68c, #e8c24c 60%, #e5584a); }
  .power-bar::after { left: 6px; right: 6px; top: 50%; bottom: auto; width: auto; height: 2px; transform: translateY(-50%);
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 2px, transparent 2px 14px); }
  .spin-pad { width: 54px; height: 54px; }
  .fine { flex-direction: column; }
  .pl-name { font-size: 13px; }
  .pl-balls { gap: 1px; }
  .pl-balls .ball-icon { width: 11px !important; height: 11px !important; }
  .clock { flex-basis: 46px; }
  #playTop { padding: 5px 6px; gap: 5px; }
  .plate { padding: 4px 7px; }
  .icon-btn { width: 34px; height: 34px; }
}
/* short landscape phones: tighter chrome */
@media (orientation: landscape) and (max-height: 480px) {
  #playTop { min-height: 40px; padding: 3px 8px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  #controls { width: 84px; gap: 8px; padding: 4px 6px 6px; }
  .spin-pad { width: 50px; height: 50px; }
  .power-wrap { min-height: 90px; }
  .trick-hint { padding: 3px 10px 4px; font-size: 12px; }
}
