/* Pool — top-down pocket billiards. Full-bleed canvas, warm felt-room chrome. */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0; height: 100%; overflow: hidden;
  background: #0a140d;
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  cursor: crosshair; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0;
  z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 1px;
  pointer-events: none; text-align: center; padding: 0 90px;
}
.hud__msg {
  font-size: clamp(1rem, 3.6vw, 1.35rem); font-weight: 800; letter-spacing: 0.01em;
  color: #f4ead2; text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
.hud__sub {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(226, 200, 150, 0.72); min-height: 0.9em;
}

/* ---------- Top buttons ---------- */
.topbtns {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 6; display: inline-flex; align-items: center; gap: 8px;
}
.pill, .iconbtn {
  appearance: none; font-family: inherit; cursor: pointer;
  border: 1.5px solid rgba(230, 190, 120, 0.3); background: rgba(18, 30, 20, 0.62);
  color: #f0e2c6; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.pill { height: 36px; padding: 0 15px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.04em; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.pill:hover, .iconbtn:hover { border-color: rgba(230, 190, 120, 0.7); }
.pill:focus-visible, .iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(230, 190, 120, 0.4); }
.iconbtn[aria-pressed="false"] { color: rgba(200, 175, 130, 0.4); }
#modeBtn { min-width: 68px; }

/* ---------- Spin picker ---------- */
.spin {
  position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(46px, calc(env(safe-area-inset-bottom) + 34px));
  z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.spin__ball {
  position: relative; width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ffffff 0%, #e9e6df 42%, #b9b4a8 100%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 0 1.5px rgba(120,110,90,0.35);
  cursor: pointer; touch-action: none;
}
.spin__ball::before, .spin__ball::after {
  content: ""; position: absolute; background: rgba(90, 80, 60, 0.18);
}
.spin__ball::before { left: 50%; top: 8%; bottom: 8%; width: 1px; transform: translateX(-50%); }
.spin__ball::after { top: 50%; left: 8%; right: 8%; height: 1px; transform: translateY(-50%); }
.spin__dot {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #c0392b; box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.4);
  transition: left 90ms ease, top 90ms ease;
}
.spin__cap {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(226, 200, 150, 0.62);
}

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 42%, rgba(12, 26, 16, 0.82), rgba(4, 10, 6, 0.95));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 260ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }
.panel {
  text-align: center; max-width: 460px; padding: 34px 30px 32px; border-radius: 24px;
  background: rgba(14, 26, 17, 0.9); border: 1px solid rgba(230, 190, 120, 0.18);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.8), inset 0 0 60px -30px rgba(230, 190, 120, 0.4);
  color: #d9cdb4;
  animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 8px; font-size: clamp(2.4rem, 10vw, 3.8rem); font-weight: 900; letter-spacing: -0.02em; line-height: 0.95;
  background: linear-gradient(176deg, #fff3d6 0%, #e9b45c 52%, #b07b28 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 4px 22px rgba(220, 160, 70, 0.35));
}
.panel__text { margin: 0 0 24px; font-size: clamp(0.96rem, 3.3vw, 1.05rem); line-height: 1.55; font-weight: 500; color: #c3b795; }
.play-btn {
  appearance: none; font-family: inherit; font-size: 1.05rem; font-weight: 800; color: #2a1c06;
  background: linear-gradient(180deg, #f6d281, #dca842); border: 0; padding: 16px 40px; border-radius: 999px;
  cursor: pointer; box-shadow: 0 10px 30px -6px rgba(220, 168, 66, 0.6);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px rgba(220, 168, 66, 0.75); }
.play-btn:active { transform: translateY(0); }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(210, 185, 140, 0.5);
}
.frame__corner--tl { top: max(14px, env(safe-area-inset-top)); left: 16px; }
/* the top-right corner is taken by the Solo / Rerack / sound controls */
.frame__corner--tr { display: none; }
.frame__corner--bl { bottom: 14px; left: 16px; }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #e9b45c; }

.hint {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; color: rgba(210, 185, 140, 0.55);
  pointer-events: none; white-space: nowrap; transition: opacity 300ms ease; max-width: 92vw; text-align: center;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 560px) {
  .frame__corner--bl { display: none; }
  .hud { padding: 0 100px 0 12px; align-items: flex-start; text-align: left; }
  .hint { display: none; }
}

/* The whole table is a drag surface, so the shared tip-jar / fullscreen badges
   docked at right-CENTRE sit over the felt and can swallow a shot. Dock them in
   the bottom-right corner (spin picker is bottom-left, so no clash). Doubled
   classes out-specify the components' injected styles. */
.opt-tipjar.opt-tipjar {
  top: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: none;
}
.opt-fs.opt-fs {
  top: auto;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px);
  transform: none;
}
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }
