html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #1b0e06; color: #f6ebdd;
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
canvas#table { position: fixed; left: 0; top: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------- HUD ---------- */
.hud { position: fixed; left: 8px; right: 8px; z-index: 10; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.hud.bottom { bottom: calc(6px + env(safe-area-inset-bottom)); }
.hud.top { top: calc(6px + env(safe-area-inset-top)); }
.pill { background: rgba(12, 6, 2, 0.62); padding: 4px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.hud.quiet { justify-content: flex-end; }
.hud.quiet .dot, .hud.quiet .gear { opacity: 0.55; }
/* Phones in the middle of the line have joins at both ends: park the controls at the side, halfway along */
.hud.mid { top: 50%; bottom: auto; left: auto; right: 2px; transform: translateY(-50%); flex-direction: column; }
.banner.mid { top: 50%; transform: translateY(-50%); }
.overlay.mid { top: 50%; transform: translateY(-50%); }
button:disabled { opacity: 0.4; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b33; flex: 0 0 auto; box-shadow: 0 0 0 2px rgba(0,0,0,0.4); }
.dot.ok { background: #3c3; }
.gear { pointer-events: auto; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(12, 6, 2, 0.62); font-size: 18px; line-height: 34px; padding: 0; }

/* Beer Pong: choose the throwing arc (only on the phone whose throw it is) */
.arc { pointer-events: auto; flex: 0 0 auto; height: 34px; border-radius: 17px; border: 1px solid #f0b66e; background: rgba(60, 34, 14, 0.85);
  color: #fff3df; font-size: 13px; font-weight: 700; padding: 0 12px; white-space: nowrap; }

.toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 30; max-width: 80vw; background: rgba(12,6,2,0.9); padding: 10px 14px; border-radius: 10px; text-align: center; border: 1px solid #6b4a2b;
  pointer-events: none; /* messages never block a swipe or a shot */ }

/* ---------- "Draw the line" banner: lets touches through to the table ---------- */
.banner { position: fixed; left: 10px; right: 10px; z-index: 18; display: flex; flex-direction: column; gap: 4px; pointer-events: none;
  background: rgba(10, 18, 24, 0.86); border: 1px solid #2aa9c9; border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.banner.bottom { bottom: calc(50px + env(safe-area-inset-bottom)); }
.banner.top { top: calc(50px + env(safe-area-inset-top)); }
.banner b { color: #7fe3ff; font-size: 15px; }
.banner button { pointer-events: auto; align-self: flex-start; margin-top: 4px; background: #16313b; border: 1px solid #2aa9c9; border-radius: 8px; padding: 6px 12px; }

/* ---------- Frame overlay ---------- */
.overlay { position: fixed; left: 0; right: 0; z-index: 15; display: flex; justify-content: center; pointer-events: none; }
.overlay.bottom { bottom: calc(52px + env(safe-area-inset-bottom)); }
.overlay.top { top: calc(52px + env(safe-area-inset-top)); }
.overlay .box { pointer-events: auto; background: rgba(12,6,2,0.88); border: 1px solid #7a5532; border-radius: 12px; padding: 12px 16px; text-align: center; max-width: 86vw; }
.overlay .box div { margin-bottom: 8px; }

/* ---------- Settings panel (always on the side away from the seam) ---------- */
.panel { position: fixed; left: 0; right: 0; z-index: 20; max-height: 58vh; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: rgba(20, 11, 5, 0.95); padding: 10px 14px; box-sizing: border-box; }
.panel.bottom { bottom: 0; border-top: 1px solid #6b4a2b; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.panel.top { top: 0; border-bottom: 1px solid #6b4a2b; padding-top: calc(10px + env(safe-area-inset-top)); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.panel h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #d8b88f; }
.row { display: grid; grid-template-columns: 1fr 1.3fr 52px; align-items: center; gap: 8px; margin: 6px 0; }
.row output { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
input[type=range] { width: 100%; accent-color: #e0a35a; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.check input { width: 20px; height: 20px; accent-color: #e0a35a; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.buttons button, .overlay button, .calib-controls button { background: #3a2414; border: 1px solid #7a5532; border-radius: 8px; padding: 8px 12px; }
button.primary { background: #c9813a; border-color: #e7a660; color: #1b0e06; font-weight: 700; }
/* The game being played, and the chosen number of players */
.buttons button.on { background: #6b4322; border-color: #f0b66e; color: #fff3df; font-weight: 700; }
.buttons.players { align-items: center; }
.buttons.players button { min-width: 44px; }
button.link { background: none; border: 0; color: #f0b66e; text-decoration: underline; padding: 4px; }
.small { font-size: 12px; color: #cbb597; }

/* ---------- Start + calibration screens ---------- */
.screen { position: fixed; inset: 0; z-index: 40; background: radial-gradient(circle at 50% 20%, #3b2312, #160b04 75%); overflow-y: auto; touch-action: pan-y; }
.start-inner { padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); max-width: 460px; margin: 0 auto; }
.screen h1 { margin: 0; font-family: Georgia, serif; font-size: 30px; color: #ffd9a3; }
.sub { margin: 2px 0 14px; color: #d8b88f; }
.status { background: rgba(0,0,0,0.3); border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; font-size: 13px; }
.roles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.role { background: linear-gradient(#e6c08c, #c99659); color: #2a170a; border: 0; border-radius: 12px; padding: 14px 6px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.role b { font-size: 16px; }
.role span { font-size: 12px; }
.scale { margin: 6px 0; }
.tips { padding-left: 18px; color: #d8c3a5; font-size: 13px; }
.tips li { margin: 6px 0; }

.card-outline { position: absolute; left: 50%; transform: translateX(-50%); box-sizing: border-box; border: 2px solid #ffd27a; background: rgba(255, 210, 122, 0.08); display: flex; align-items: center; justify-content: center; color: #ffd27a; font-size: 12px; }
.calib-controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(12,6,2,0.85); }
.calib-controls p { margin: 0 0 8px; font-size: 13px; }
.calib-row { display: flex; align-items: center; gap: 10px; }
button.big { width: 44px; height: 44px; font-size: 22px; padding: 0; }

/* ---------- ShuffleBowl score sheet ---------- */
.scorecard { overflow-x: auto; margin: 4px 0 6px; }
.scorecard table { border-collapse: collapse; font-size: 11px; width: 100%; }
.scorecard th, .scorecard td { border: 1px solid #5a3c22; padding: 2px 3px; text-align: center; min-width: 18px; }
.scorecard th { color: #d8b88f; font-weight: 600; }
.scorecard th.red { color: #ff8a8a; }
.scorecard th.blue { color: #8ab0ff; }
.scorecard td .marks { font-weight: 700; letter-spacing: 1px; min-height: 13px; }
.scorecard td .tot { color: #cbb597; min-height: 13px; }
.scorecard td.now { background: rgba(224,163,90,0.25); }
.scorecard td.total { font-weight: 700; font-size: 13px; }
