:root { --gold: #e9c27a; --gold2: #c9933f; --glass: rgba(12,14,18,.66); --glass2: rgba(20,22,28,.82); --line: rgba(255,255,255,.09); --text: #f1efe9; --muted: rgba(241,239,233,.6); --red: #ff6b5e; --blue: #5fb4ff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050506; font-family: Inter, system-ui, sans-serif; color: var(--text); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
#loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 22px; background: radial-gradient(ellipse at center, #11141a, #040405); z-index: 50; transition: opacity .6s; }
#loading .bar { width: 200px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin: auto; }
#loading .bar i { display: block; height: 100%; width: 40%; background: var(--gold); animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------- HUD ---------- */
.topbar { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; }
.pcard, .mode { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; transition: all .3s; }
.pcard { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; min-width: 210px; position: relative; overflow: hidden; }
.pcard .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(145deg, #2b3140, #161a22); border: 1px solid var(--line); flex: none; }
.pcard .pmeta { flex: 1; min-width: 0; }
.pcard .score { font-family: Oswald, Inter, sans-serif; font-size: 26px; font-weight: 700; color: var(--gold); min-width: 22px; text-align: center; }
.pcard .clock { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.05); }
.pcard .clock i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s linear, background .3s; }
.pcard .clock i.warn { background: var(--red); }
.pcard.active { border-color: rgba(233,194,122,.8); box-shadow: 0 0 0 1px rgba(233,194,122,.6), 0 0 28px rgba(233,194,122,.22); }
.pcard.active .av { background: linear-gradient(145deg, #f1d398, #c9933f); color: #1a1408; }
.pcard.noscore .score { display: none; }
.pname { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinfo { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 3px; align-items: center; min-height: 16px; flex-wrap: wrap; }
.mode { text-align: center; min-width: 120px; padding: 8px 14px; display: flex; flex-direction: column; justify-content: center; }
#modeName { font-family: Oswald, Inter, sans-serif; font-weight: 700; color: var(--gold); letter-spacing: .12em; font-size: 17px; }
#matchInfo { font-size: 10px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin-top: 1px; }
#target { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; justify-content: center; align-items: center; min-height: 22px; }
.mini { width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center; box-shadow: inset -2px -2px 3px rgba(0,0,0,.45), inset 1px 1px 2px rgba(255,255,255,.5); font-size: 7px; font-weight: 800; color: #111; flex: none; }
.mini i { font-style: normal; background: #f4efe2; border-radius: 50%; width: 62%; height: 62%; display: grid; place-items: center; }
.mini.big { width: 22px; height: 22px; font-size: 9px; }
.mini.gone { opacity: .25; filter: grayscale(1); }
#toast { position: fixed; top: 96px; left: 50%; transform: translateX(-50%) translateY(-8px); background: var(--glass2); backdrop-filter: blur(14px); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; transition: all .35s; pointer-events: none; max-width: min(92vw, 720px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.foul { border-color: rgba(255,107,94,.7); color: #ffc2bb; }
#tray { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; padding: 6px 10px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; min-height: 34px; }
#tray:empty { display: none; }
#power { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#power .track { width: 36px; height: 46vh; max-height: 340px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); position: relative; overflow: hidden; cursor: ns-resize; touch-action: none; }
#power .fill { position: absolute; left: 0; right: 0; top: 0; height: 0%; background: linear-gradient(180deg, #ffe08a, #f28b2c 60%, #e2364a); opacity: .92; }
#power .knob { position: absolute; left: 3px; right: 3px; height: 8px; top: 0; border-radius: 4px; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.6); }
.plabel { font-size: 9px; letter-spacing: .2em; color: var(--muted); font-weight: 700; text-align: center; line-height: 1.3; }
#roller { position: fixed; right: 66px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#roller .wheel { width: 30px; height: 30vh; max-height: 230px; border-radius: 15px; background: linear-gradient(90deg, #0b0c0f, #2a2d35 30%, #3a3e48 50%, #2a2d35 70%, #0b0c0f); border: 1px solid var(--line); overflow: hidden; position: relative; cursor: ns-resize; touch-action: none; box-shadow: inset 0 10px 14px rgba(0,0,0,.7), inset 0 -10px 14px rgba(0,0,0,.7); }
#roller .ridges { position: absolute; inset: -20px 0; background: repeating-linear-gradient(180deg, rgba(255,255,255,.22) 0 2px, transparent 2px 9px); }
#nudge { position: fixed; left: 50%; bottom: max(58px, calc(env(safe-area-inset-bottom) + 50px)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 4px; backdrop-filter: blur(14px); }
#nudge .nb { width: 42px; height: 38px; border-radius: 999px; border: 0; background: rgba(255,255,255,.07); cursor: pointer; display: grid; place-items: center; touch-action: none; }
#nudge .nb:active { background: var(--gold); color: #1a1408; }
#angle { font-family: Oswald, Inter, sans-serif; min-width: 76px; text-align: center; font-size: 15px; letter-spacing: .05em; }
#spin { position: fixed; left: 18px; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#spin .ball, .bigball { border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #ece7da 45%, #9d978a 100%); box-shadow: 0 6px 24px rgba(0,0,0,.5); position: relative; cursor: crosshair; touch-action: none; }
#spin .ball { width: 88px; height: 88px; }
.cross { position: absolute; inset: 0; background: linear-gradient(transparent 49.5%, rgba(0,0,0,.15) 49.5%, rgba(0,0,0,.15) 50.5%, transparent 50.5%), linear-gradient(90deg, transparent 49.5%, rgba(0,0,0,.15) 49.5%, rgba(0,0,0,.15) 50.5%, transparent 50.5%); border-radius: 50%; }
.cross::after { content: ''; position: absolute; inset: 25%; border: 1px dashed rgba(0,0,0,.2); border-radius: 50%; }
.dot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #d8232a; box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0,0,0,.5); left: 50%; top: 50%; pointer-events: none; }
.bigball { width: 220px; height: 220px; margin: 8px auto 14px; }
.bigball .dot { width: 22px; height: 22px; margin: -11px 0 0 -11px; }
.bigball .limit { position: absolute; inset: 10%; border-radius: 50%; border: 2px dashed rgba(216,35,42,.45); }
.spinpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 40px); gap: 6px; justify-content: center; }
.spinpad button { border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 10px; cursor: pointer; font-size: 14px; touch-action: none; }
.spinpad button:active { background: var(--gold); color: #1a1408; }
.spinpad [data-s="0,1"] { grid-column: 2; grid-row: 1; } .spinpad [data-s="-1,0"] { grid-column: 1; grid-row: 2; } .spinpad .mid { grid-column: 2; grid-row: 2; font-size: 12px; } .spinpad [data-s="1,0"] { grid-column: 3; grid-row: 2; } .spinpad [data-s="0,-1"] { grid-column: 2; grid-row: 3; }
.spinread { font-size: 13px; color: var(--muted); margin-top: 12px; min-height: 18px; }
#actions { position: fixed; left: 122px; bottom: max(26px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; font-weight: 700; font-size: 13px; backdrop-filter: blur(14px); }
.chip.on { background: var(--gold); color: #1a1408; border-color: var(--gold); }
#buttons { position: fixed; right: 14px; top: max(12px, env(safe-area-inset-top)); display: flex; gap: 8px; }
#buttons button { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; backdrop-filter: blur(14px); display: grid; place-items: center; }
#btnSound.muted .w { display: none; }
#hint { position: fixed; left: 50%; bottom: 122px; transform: translateX(-50%); font-size: 12px; color: var(--muted); white-space: nowrap; pointer-events: none; transition: opacity 1s; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(0,0,0,.3), rgba(0,0,0,.82)); z-index: 20; backdrop-filter: blur(3px); overflow: auto; padding: 16px; }
.overlay.screen { background: linear-gradient(180deg, rgba(5,6,8,.2), rgba(5,6,8,.75) 70%); backdrop-filter: none; }
.panel { width: min(440px, 94vw); background: rgba(16,18,22,.86); border: 1px solid var(--line); border-radius: 22px; padding: 26px; backdrop-filter: blur(20px); box-shadow: 0 30px 80px rgba(0,0,0,.6); text-align: center; }
.panel.wide { width: min(560px, 94vw); }
.panel.xwide { width: min(860px, 96vw); }
.panel.tall { max-height: 92vh; display: flex; flex-direction: column; }
.ptitle { font-family: Oswald, Inter, sans-serif; font-size: 24px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; }
.logo { font-family: Oswald, Inter, sans-serif; font-size: 64px; font-weight: 700; letter-spacing: .1em; line-height: 1; }
.logo span { color: var(--gold); margin-left: 6px; }
.logo em { font-style: normal; font-size: .28em; letter-spacing: .3em; vertical-align: top; margin-left: 8px; padding: 3px 8px; border: 1px solid var(--gold); color: var(--gold); border-radius: 6px; position: relative; top: 8px; }
.logo.small { font-size: 34px; color: var(--gold); }
.sub { color: var(--muted); margin: 6px 0 18px; font-size: 14px; line-height: 1.5; }
.home-wrap { width: min(980px, 96vw); display: flex; flex-direction: column; align-items: center; gap: 26px; padding-top: 4vh; }
.brand { text-align: center; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: 100%; }
.card { text-align: left; padding: 18px; border-radius: 20px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(30,33,41,.82), rgba(12,13,17,.86)); backdrop-filter: blur(16px); cursor: pointer; transition: transform .2s, border-color .2s, box-shadow .2s; min-height: 150px; display: flex; flex-direction: column; gap: 6px; }
.card:hover { transform: translateY(-3px); border-color: rgba(233,194,122,.6); box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(233,194,122,.3); }
.card .ci { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, #f1d398, #c9933f); margin-bottom: auto; }
.card .ci svg { width: 24px; height: 24px; fill: none; stroke: #1a1408; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card .ct { font-weight: 800; font-size: 18px; margin-top: 14px; }
.card .cd { font-size: 12.5px; color: var(--muted); }
.home-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pill { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; backdrop-filter: blur(14px); font-size: 13px; }
.pill span { color: var(--muted); } .pill b { color: var(--gold); }
.foot { font-size: 11px; color: var(--muted); opacity: .8; text-align: center; }
.row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; margin: 10px 0; }
.label { text-align: left; font-size: 11px; letter-spacing: .16em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.seg { display: flex; background: rgba(255,255,255,.05); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; color: #ddd; padding: 10px 6px; border-radius: 9px; font-weight: 600; cursor: pointer; transition: all .2s; }
.seg button.on { background: var(--gold); color: #1a1408; }
input#nameInput { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit; user-select: text; -webkit-user-select: text; }
.rulenote { font-size: 12px; color: var(--muted); text-align: left; background: rgba(255,255,255,.04); border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
button.primary, button.ghost { width: 100%; margin-top: 18px; padding: 14px; border-radius: 12px; border: 0; font-weight: 800; letter-spacing: .06em; cursor: pointer; background: linear-gradient(180deg, #f1d398, #d7a95a); color: #1a1408; box-shadow: 0 8px 24px rgba(215,169,90,.3); }
button.ghost { margin-top: 10px; background: transparent; color: #ddd; border: 1px solid var(--line); box-shadow: none; }
#cueList { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; text-align: left; max-height: 66vh; overflow: auto; padding: 2px; }
.cuecard { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: rgba(255,255,255,.03); cursor: pointer; transition: all .2s; }
.cuecard:hover { border-color: rgba(233,194,122,.5); }
.cuecard.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 24px rgba(233,194,122,.18); background: rgba(233,194,122,.06); }
.cuecard canvas { width: 100%; height: 34px; display: block; margin: 4px 0 10px; }
.cuecard .cn { font-weight: 800; display: flex; justify-content: space-between; } .cuecard .cn em { font-style: normal; font-size: 11px; color: var(--gold); }
.cuecard .cdsc { font-size: 12px; color: var(--muted); margin: 2px 0 8px; min-height: 30px; }
.stat { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); margin: 4px 0; }
.stat .b { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; } .stat .b i { display: block; height: 100%; background: linear-gradient(90deg, #c9933f, #f1d398); }
.tsub { color: var(--muted); font-size: 13px; margin: -6px 0 12px; }
#roundTabs { flex: none; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
#roundTabs button { flex: none; border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
#roundTabs button.on { background: var(--gold); color: #1a1408; border-color: var(--gold); }
#roundTabs button.cur::after { content: ' •'; color: var(--red); }
#matchList { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin-top: 10px; text-align: left; align-content: start; min-height: 200px; }
.mcard { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: rgba(255,255,255,.03); font-size: 13px; }
.mcard.me { border-color: var(--gold); background: rgba(233,194,122,.07); }
.mrow { display: grid; grid-template-columns: 26px 1fr 34px 22px; gap: 6px; align-items: center; padding: 2px 0; }
.mrow .cc { font-size: 9px; font-weight: 800; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; text-align: center; padding: 1px 0; }
.mrow .rt { font-size: 10px; color: var(--muted); text-align: right; }
.mrow .sc { font-family: Oswald, Inter, sans-serif; text-align: right; }
.mrow.w { font-weight: 800; } .mrow.l { opacity: .5; }
.mrow .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bactions { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; } .bactions .primary { grid-column: 1 / -1; }
.bigscore { font-family: Oswald, Inter, sans-serif; font-size: 44px; margin: 6px 0; letter-spacing: .08em; }
.rulebox { text-align: left; font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-top: 14px; max-height: 40vh; overflow: auto; }
.rulebox b { color: var(--text); }

@media (max-width: 860px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  .logo { font-size: 46px; }
  .pcard { min-width: 0; padding: 6px 8px 8px; gap: 6px; } .pcard .av { width: 26px; height: 26px; font-size: 12px; } .pcard .score { font-size: 20px; }
  .mode { min-width: 0; padding: 6px 8px; } #modeName { font-size: 14px; } #matchInfo { display: none; }
  .pname { font-size: 12px; max-width: 70px; } #hint { display: none; }
  .topbar { left: 10px; right: 64px; transform: none; gap: 6px; } .topbar > * { flex: 1; min-width: 0; } .topbar .mode { flex: .8; }
  #spin .ball { width: 70px; height: 70px; }
  #toast { top: 74px; font-size: 12px; }
  #buttons { flex-direction: column; }
  #power { top: 60%; } #power .track { height: 32vh; }
  #roller { right: 62px; top: 60%; } #roller .wheel { height: 24vh; }
  #actions { left: 100px; bottom: max(22px, env(safe-area-inset-bottom)); }
  .card { min-height: 120px; padding: 14px; } .card .ct { font-size: 15px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .bactions { grid-template-columns: 1fr; }
}
