/* Ringside Rumble 3D - stage, HUD, controls and menu screens. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --red:#d23a32; --red-d:#9c2620; --gold:#f2b21a; --blue:#2f6df0; --green:#2fbf8a; --ink:#141829; --panel:rgba(14,17,32,.9); --txt:#f4f6ff; --dim:#9aa3c4;
  position: relative; width: min(100%, calc(78vh * 0.5625)); width: min(100%, calc(78svh * 0.5625)); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: #10131e; color: var(--txt); font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; line-height: 1.25; }
#stage.is-big { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
#stage * { box-sizing: border-box; }
#app { position: absolute; inset: 0; }
#app canvas { touch-action: none; }
#stage button { font-family: inherit; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; border: 0; touch-action: manipulation; }
#stage button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud[hidden], #ctl[hidden], #ui[hidden], #stage [hidden] { display: none !important; }
.hb { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; padding: 8px 46px 0 8px; align-items: start; }
.hb .who { display: grid; gap: 3px; min-width: 0; }
.hb .who span { font-size: 11px; font-weight: 800; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.hb .who.r { text-align: right; }
.hb .who.r .meter u { margin-left: auto; }
.meter { display: block; height: 10px; border-radius: 6px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25); overflow: hidden; }
.meter.st { height: 6px; }
.meter u { display: block; height: 100%; width: 100%; text-decoration: none; border-radius: 6px; transition: width .12s linear; }
.meter.hp u { background: linear-gradient(#6ee57a, #2fbf4a); }
.who.r .meter.hp u { background: linear-gradient(#ff7d6e, #d23a32); }
.meter.st u { background: linear-gradient(#ffd75e, #f2b21a); }
.meter.st u.low, .meter.st u.exh { background: #ff6a3a; }
.hb .mid { display: grid; text-align: center; text-shadow: 0 1px 2px #000; }
.hb .mid b:first-child { font-size: 11px; color: var(--dim); }
.hb .mid b:last-child { font-size: 18px; font-family: "JetBrains Mono", monospace; }
.ib { width: 44px; height: 44px; border-radius: 12px; background: rgba(0,0,0,.45); font-weight: 800; font-size: 15px; }
.pause { position: absolute; top: 4px; right: 4px; pointer-events: auto; }
.tele { position: absolute; left: 50%; top: 21%; transform: translateX(-50%) scale(.9); padding: 5px 14px; border-radius: 20px; font-weight: 900; letter-spacing: .08em; font-size: 14px; background: rgba(0,0,0,.6); color: #fff; opacity: 0; transition: opacity .06s; white-space: nowrap; }
.tele.on { opacity: 1; transform: translateX(-50%) scale(1); }
.tele.k1 { background: #1d86b3; } .tele.k2 { background: #c9731a; } .tele.k3 { background: #b02c9a; } .tele.k4 { background: #c42323; }
.combo { position: absolute; left: 10px; top: 20%; font-weight: 900; font-size: 15px; color: var(--gold); text-shadow: 0 2px 3px #000; opacity: 0; transition: opacity .15s; }
.combo.on { opacity: 1; }
.banner { position: absolute; left: 0; right: 0; top: 33%; text-align: center; font-size: 34px; font-weight: 900; letter-spacing: .06em; text-shadow: 0 3px 6px #000; opacity: 0; transform: scale(1.2); transition: opacity .2s, transform .2s; }
.banner.on { opacity: 1; transform: scale(1); }
.hint { position: absolute; left: 14px; right: 14px; top: 27%; text-align: center; font-size: 13px; font-weight: 700; padding: 7px 10px; border-radius: 10px; background: rgba(0,0,0,.62); opacity: 0; transition: opacity .2s; }
.hint.on { opacity: 1; }
#h-pops { position: absolute; inset: 0; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,.6); opacity: 0; white-space: nowrap; }
.pop.go { animation: popup .8s ease-out forwards; }
.pop.big { font-size: 28px; color: var(--gold); } .pop.gold { color: var(--gold); font-size: 22px; } .pop.pink { color: #ff6af0; font-size: 22px; }
.pop.blue { color: #7ab5ff; } .pop.dim { color: #cfd6f0; font-size: 15px; } .pop.red { color: #ff6a5e; }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -130%) scale(1); } }
.tr { position: absolute; inset: 0; }
.trtop { display: flex; justify-content: space-between; padding: 10px 56px 0 12px; font-size: 16px; text-shadow: 0 1px 3px #000; }
.ring { position: absolute; left: 50%; top: 36%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border: 5px solid var(--gold); border-radius: 50%; opacity: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); }
.ico { font-size: 13px; font-weight: 900; text-align: center; padding: 0 2px; }
.ico.k1 { color: #6fdcff; } .ico.k2 { color: #ffb050; } .ico.k3 { color: #ff7fe8; }
.tmsg { position: absolute; left: 0; right: 0; top: 52%; text-align: center; font-weight: 900; font-size: 22px; color: var(--gold); text-shadow: 0 2px 4px #000; }

/* controls */
#ctl { position: absolute; left: 0; right: 0; bottom: 0; height: 33%; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; gap: 7px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(8,10,20,.62) 22%); touch-action: none; }
.cb { border-radius: 16px; display: grid; place-content: center; text-align: center; min-height: 48px; font-weight: 900; box-shadow: inset 0 -5px 0 rgba(0,0,0,.28); background: #2a3050; transition: transform .05s, filter .05s; }
.cb b { font-size: 17px; letter-spacing: .04em; }
.cb small { font-size: 10px; opacity: .8; font-weight: 600; }
.cb.down { transform: scale(.94); filter: brightness(1.35); }
.cb.k1 { background: #1d86b3; } .cb.k2 { background: #c9731a; } .cb.k3 { background: #b02c9a; }
.cb.bl { background: #2f6df0; } .cb.dd { background: #3a4170; }
#ctl.bag #b-dl, #ctl.bag #b-dr, #ctl.bag #b-block { visibility: hidden; }
#ctl.pads #b-jab, #ctl.pads #b-hook, #ctl.pads #b-upper { visibility: hidden; }

/* overlay screens */
.ui { position: absolute; inset: 0; z-index: 9; background: rgba(8,10,20,.8); display: flex; flex-direction: column; touch-action: pan-y; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px; }
.bar .ttl { flex: 1; font-size: 20px; letter-spacing: .02em; }
.bar .sp { visibility: hidden; }
.cash { background: rgba(255,255,255,.1); padding: 7px 12px; border-radius: 20px; font-weight: 900; color: var(--gold); font-family: "JetBrains Mono", monospace; }
.rank { padding: 0 12px 6px; font-size: 11px; color: var(--dim); display: grid; gap: 3px; }
.rank i { display: block; height: 6px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; }
.rank u { display: block; height: 100%; background: var(--blue); text-decoration: none; }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 4px 12px 14px; display: grid; gap: 10px; align-content: start; }
.hero h2 { font-size: 22px; } .hero p { color: var(--dim); font-size: 13px; margin-top: 3px; }
.big { display: grid; gap: 2px; text-align: left; padding: 13px 16px; min-height: 60px; border-radius: 16px; background: #2a3050; box-shadow: inset 0 -5px 0 rgba(0,0,0,.28); width: 100%; }
.big b { font-size: 18px; } .big small { font-size: 12px; opacity: .85; font-weight: 600; }
.big.red { background: var(--red); } .big.gold { background: #c78f0e; } .big.blue { background: var(--blue); } .big.green { background: #1f9a70; } .big.lock { background: #3a4060; }
.big:active, .sm:active, .row:active, .buy:active, .seg:active, .sw:active { filter: brightness(1.25); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sm { padding: 12px; min-height: 48px; border-radius: 12px; background: #2a3050; font-weight: 800; font-size: 15px; }
.sm em { font-style: normal; background: var(--red); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.sm.danger, .seg.danger { background: #8e2520; }
.list { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 52px; border-radius: 12px; background: #232846; text-align: left; width: 100%; }
.row.sel { outline: 2px solid var(--gold); } .row.off { opacity: .45; }
.row .dot { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid #fff3; }
.row .rt { flex: 1; display: grid; min-width: 0; } .row .rt small { color: var(--dim); font-size: 11px; }
.row .st { color: var(--gold); letter-spacing: 1px; font-size: 14px; }
.card { background: #1b2040; border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.card h3 { font-size: 17px; } .card h3 small { color: var(--dim); font-weight: 600; font-size: 12px; margin-left: 4px; }
.card p { font-size: 13px; color: #dfe4fb; } .meta { color: var(--dim) !important; font-size: 12px !important; }
.warn { color: #ffb4a8 !important; }
.note { font-size: 12px; color: var(--dim); }
.stat { display: flex; align-items: center; gap: 8px; background: #1b2040; border-radius: 12px; padding: 10px 12px; }
.stat .sl { flex: 1; display: grid; gap: 3px; } .stat .sl small { color: var(--dim); font-size: 11px; }
.pips { display: flex; gap: 3px; } .pips i { width: 14px; height: 7px; border-radius: 3px; background: rgba(255,255,255,.14); } .pips i.on { background: var(--gold); }
.buy { min-width: 76px; min-height: 44px; padding: 8px 12px; border-radius: 12px; background: var(--green); font-weight: 900; }
.buy.poor { background: #4a5070; } .max { color: var(--dim); font-weight: 800; font-size: 13px; min-width: 52px; text-align: center; }
.sw { display: grid; gap: 2px; justify-items: start; padding: 10px; min-height: 64px; border-radius: 12px; background: #232846; text-align: left; }
.sw.cur { outline: 2px solid var(--gold); } .sw.off { opacity: .45; } .sw small { color: var(--dim); font-size: 11px; }
.chip { width: 26px; height: 16px; border-radius: 6px; border: 1px solid #fff4; }
#stage h4 { font-size: 13px; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.goal, .setrow { display: flex; align-items: center; gap: 8px; justify-content: space-between; background: #1b2040; border-radius: 12px; padding: 10px 12px; min-height: 50px; }
.goal small, .ach small { display: block; color: var(--dim); font-size: 11px; }
.achs { display: grid; gap: 6px; } .ach { padding: 8px 12px; border-radius: 10px; background: #171b34; opacity: .6; } .ach.got { opacity: 1; background: #233a2e; }
.segs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.seg { min-height: 44px; padding: 8px 14px; border-radius: 10px; background: #2a3050; font-weight: 800; font-size: 13px; text-transform: capitalize; }
.seg.on { background: var(--blue); }
.modal { margin: auto; width: calc(100% - 28px); max-height: calc(100% - 24px); overflow-y: auto; touch-action: pan-y; display: grid; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--panel); border: 1px solid #fff2; }
.modal h2 { font-size: 26px; text-align: center; } .modal h2.win { color: var(--gold); } .modal h2.loss { color: #ff8a7e; }
.modal .meth { text-align: center; color: var(--dim); font-size: 13px; }
.tbl { display: grid; gap: 4px; } .tbl div { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 2px; border-bottom: 1px solid #ffffff14; }
.gotach { color: #8df0b8; font-size: 13px; text-align: center; }
.goal2 { text-align: center; font-size: 13px; color: #cfe0ff; background: #1b2650; border-radius: 10px; padding: 8px; }

/* fades and toasts: every one of these clears on a timer in the script */
.flash { position: absolute; inset: 0; z-index: 7; pointer-events: none; opacity: 0; }
.flash.hit { background: radial-gradient(transparent 40%, rgba(255,40,30,.45)); animation: fl .24s ease-out forwards; }
.flash.ko { background: rgba(255,255,255,.7); animation: fl .5s ease-out forwards; }
@keyframes fl { 0% { opacity: 1; } 100% { opacity: 0; } }
.toast { position: absolute; left: 14px; right: 14px; bottom: 36%; z-index: 12; text-align: center; font-size: 13px; font-weight: 700; padding: 9px 12px; border-radius: 12px; background: rgba(0,0,0,.8); opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.on { opacity: 1; }
#ctxlost { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; text-align: center; padding: 24px; background: rgba(8,10,20,.92); font-size: 15px; }
#loader { position: absolute; inset: 0; z-index: 40; display: grid; place-content: center; text-align: center; background: #10131e; }
#loader[hidden] { display: none; }
.load-in { display: grid; gap: 10px; justify-items: center; } .load-in span { color: var(--dim); font-size: 13px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #fff2; border-top-color: var(--red); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #stage * { animation-duration: .01s !important; transition: none !important; } }
@media (max-height: 520px) and (orientation: landscape) { #stage:not(.is-big) { width: min(100%, calc(95vh * 0.5625)); } }

/* page chrome under the game */
.bx-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.bx-bar .btn { min-height: 44px; min-width: 44px; }
.bx-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.bx-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.bx-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.bx-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.bx-guide p { margin-bottom: .5rem; font-size: .95rem; }

#hud.dng::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 60px 8px rgba(255,40,30,.5); animation: dng 1s ease-in-out infinite; }
@keyframes dng { 50% { opacity: .35; } }
.combo.c4 { font-size: 19px; color: #ffb347; }
.combo.c6 { font-size: 24px; color: #ff6a4d; }
@media (prefers-reduced-motion: reduce) { #hud.dng::after { animation: none; } }

/* Third pass: full screen on phones. The shell's stage (.game-wrap) is a fixed box under the dock; the game fills it. */
body:has(.pip-bar) .bx-bar { display: none; }
#app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(4,6,14,.38) 100%); }
html.pip-immersive .game-wrap, html.pip-native .game-wrap, .game-wrap:fullscreen, .game-wrap:-webkit-full-screen { display: flex; flex-direction: column; }
html.pip-immersive .game-wrap > .bx-bar, html.pip-immersive .game-wrap > .bx-keys, html.pip-immersive .game-wrap > .game-title,
html.pip-native .game-wrap > .bx-bar, html.pip-native .game-wrap > .bx-keys, html.pip-native .game-wrap > .game-title,
.game-wrap:fullscreen > .bx-bar, .game-wrap:fullscreen > .bx-keys, .game-wrap:fullscreen > .game-title { display: none; }
html.pip-immersive #stage, html.pip-native #stage, html.pip-immersive #stage.is-big, html.pip-native #stage.is-big,
.game-wrap:fullscreen #stage, .game-wrap:fullscreen #stage.is-big {
  position: relative; inset: auto; flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; height: auto; aspect-ratio: auto; border-radius: 0; z-index: 1; }
html.pip-immersive #ctl, html.pip-native #ctl, .game-wrap:fullscreen #ctl { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-immersive #ctl, html.pip-native #ctl, .game-wrap:fullscreen #ctl { height: 27%; grid-template-columns: repeat(6, 1fr); grid-template-rows: 1fr; }
  html.pip-immersive #ctl .cb, html.pip-native #ctl .cb, .game-wrap:fullscreen #ctl .cb { min-height: 44px; }
}
