* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #070504; color: #f1e6d4; font-family: Georgia, 'Times New Roman', serif; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

/* ── HUD ─────────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; }
#plates { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.plate { width: min(44vw, 240px); padding: 7px 12px 8px; background: rgba(14, 9, 6, 0.72); border: 1px solid rgba(214, 170, 96, 0.22); border-radius: 6px; opacity: 0.62; transition: opacity 0.25s, border-color 0.25s; }
.plate.up { opacity: 1; border-color: #d6aa60; }
.who { font-size: 15px; font-weight: 700; }
.group { float: right; font-size: 11px; line-height: 20px; letter-spacing: 0.08em; text-transform: uppercase; color: #cdb892; }
.tray { display: flex; gap: 3px; height: 17px; margin-top: 4px; }
.tray i { width: 15px; height: 15px; border-radius: 50%; font: 700 9px/15px Arial, sans-serif; text-align: center; color: #1a1408; background: var(--c); box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.45); }
.tray i.stripe { background: linear-gradient(#f3ecd9 22%, var(--c) 22%, var(--c) 78%, #f3ecd9 78%); }
.tray i.down { opacity: 0.16; }

#banner { position: absolute; top: calc(84px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 7px 18px; background: rgba(14, 9, 6, 0.8); border-radius: 4px; font-size: 16px; text-align: center; opacity: 0; transition: opacity 0.3s; }
#banner.on { opacity: 1; }
#banner.foul { color: #ffb0a0; }
#hint { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: 13px; color: #cdb892; text-shadow: 0 1px 3px #000; white-space: nowrap; }

#stroke { position: absolute; right: calc(16px + env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); width: 64px; height: min(58vh, 300px); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; touch-action: none; cursor: ns-resize; background: rgba(14, 9, 6, 0.6); border: 1px solid rgba(214, 170, 96, 0.25); border-radius: 8px; font: 700 10px Arial, sans-serif; letter-spacing: 0.1em; color: #cdb892; }
#stroke-track { position: relative; flex: 1; width: 12px; background: #1a120c; border-radius: 6px; overflow: hidden; }
#stroke-fill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: linear-gradient(#e7c37a, #d9622e); }
#stroke-cue { position: absolute; left: 3px; right: 3px; top: -60%; height: 100%; background: linear-gradient(#35608a 0 6px, #ece4cf 6px 12px, #c9a26c 12px); border-radius: 3px; }

#spin { position: absolute; left: calc(16px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto; touch-action: none; cursor: crosshair; font: 700 10px Arial, sans-serif; letter-spacing: 0.1em; color: #cdb892; }
#spin-ball { position: relative; width: 84px; height: 84px; border-radius: 50%; background: radial-gradient(circle at 36% 30%, #fff, #e9e1cf 48%, #93897a); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7); }
#spin-limit { position: absolute; inset: 20%; border: 1px dashed rgba(90, 60, 40, 0.5); border-radius: 50%; }
#spin-dot { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px; border-radius: 50%; background: #35608a; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8); }

#fine { position: absolute; left: 50%; bottom: calc(38px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(46vw, 300px); height: 34px; display: flex; align-items: center; justify-content: center; pointer-events: auto; touch-action: none; cursor: ew-resize; border-radius: 17px; background: repeating-linear-gradient(90deg, rgba(214, 170, 96, 0.2) 0 2px, rgba(14, 9, 6, 0.6) 2px 12px); border: 1px solid rgba(214, 170, 96, 0.25); font: 700 10px Arial, sans-serif; letter-spacing: 0.14em; color: #cdb892; }

#buttons { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: flex; gap: 6px; pointer-events: auto; }
.tb { padding: 8px 12px; background: rgba(14, 9, 6, 0.75); border: 1px solid rgba(214, 170, 96, 0.3); border-radius: 5px; font-size: 13px; }
.tb:hover { border-color: #d6aa60; }
#place-btn { background: #8a5d22; border-color: #d6aa60; }
body.watching #stroke, body.watching #spin, body.watching #fine { opacity: 0.25; pointer-events: none; }

/* ── Screens ─────────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; background: radial-gradient(ellipse at center, rgba(8, 5, 3, 0.45), rgba(4, 2, 1, 0.9)); }
.panel { width: min(620px, 100%); max-height: 100%; overflow-y: auto; padding: 26px 28px; background: rgba(16, 10, 6, 0.84); border: 1px solid rgba(214, 170, 96, 0.3); border-radius: 8px; backdrop-filter: blur(3px); }
.panel.narrow { width: min(390px, 100%); text-align: center; }
.panel.narrow button { display: block; width: 100%; margin-top: 8px; }
.logo { font-size: clamp(36px, 9vw, 58px); font-style: italic; color: #ffd9a0; text-shadow: 0 0 22px rgba(255, 74, 94, 0.55); }
.tag { margin: 2px 0 16px; color: #cdb892; font-style: italic; }
h2 { margin-bottom: 10px; font-size: 28px; color: #ffd9a0; }
h3 { margin-bottom: 8px; font-size: 13px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: #cdb892; }
#opponents { display: grid; gap: 7px; margin-bottom: 8px; }
.opp { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 10px 14px; text-align: left; background: rgba(50, 30, 16, 0.55); border: 1px solid rgba(214, 170, 96, 0.28); border-radius: 6px; }
.opp:hover { border-color: #e7c37a; background: rgba(80, 48, 24, 0.6); }
.opp b { font-size: 17px; }
.opp span { grid-column: 1; font-size: 13px; color: #cdb892; }
.opp em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-size: 13px; color: #e7c37a; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.row button, .panel.narrow button { padding: 10px; background: rgba(50, 30, 16, 0.55); border: 1px solid rgba(214, 170, 96, 0.28); border-radius: 6px; }
button.primary { background: #8a5d22; border-color: #d6aa60; font-weight: 700; }
button.big { padding: 13px; font-size: 17px; }
.settings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { padding: 5px 10px; background: rgba(50, 30, 16, 0.4); border: 1px solid rgba(214, 170, 96, 0.22); border-radius: 14px; font-size: 13px; }
.chip input { width: 72px; vertical-align: middle; accent-color: #d6aa60; }
.help { margin-top: 12px; font-size: 14px; line-height: 1.45; color: #dccdb2; }
.help summary { cursor: pointer; color: #e7c37a; }
.help p { margin-top: 6px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 6px; font-size: 13px; }
.touch-help { display: none; }
.muted { margin-top: 10px; font-size: 13px; color: #a8987e; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #070504; font-style: italic; color: #cdb892; }

/* ── Phones ──────────────────────────────────────────────────────────── */
body.touch .touch-help { display: block; }
body.touch #hint { display: none; }
body.touch #fine { bottom: calc(14px + env(safe-area-inset-bottom)); height: 44px; }
body.touch #stroke { width: 72px; }
@media (max-width: 720px) {
  .plate { padding: 5px 8px; }
  .who { font-size: 13px; }
  .tray i { width: 11px; height: 11px; font-size: 0; }
  #buttons { top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
  #banner { top: calc(74px + env(safe-area-inset-top)); font-size: 14px; }
  #spin-ball { width: 68px; height: 68px; }
  .panel { padding: 18px; }
}
@media (max-height: 460px) {
  #plates { gap: 6px; }
  .tray { display: none; }
  #banner { top: calc(46px + env(safe-area-inset-top)); }
  #stroke { height: 66vh; }
}
