/* Surf Rider 3D - stage and in-game UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
.sr-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.sr-bar .btn { min-height: 44px; min-width: 44px; }
.sr-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.sr-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.sr-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.sr-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.sr-guide p { margin-bottom: .5rem; font-size: .95rem; }

#stage { --deep:#0b2a4a; --teal:#19c2b5; --teal-d:#0e8fa8; --coral:#ff6b57; --sun:#ffc94d; --sand:#ffe7a8; --ink:#10324f; --good:#4ee08a;
  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: linear-gradient(#3c9df0, #cdeeff); color: #fff;
  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, #stage:fullscreen, #stage:-webkit-full-screen, #stage.pip-stage { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage #app { position: absolute; inset: 0; z-index: 0; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#stage #ui button, #stage #ui .panel, #stage #ui input, #stage #ui .pad { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#stage [hidden] { display: none !important; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#0e8fa8 0%, #19c2b5 60%, #cdf7ef 100%); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 0 18px; text-shadow: 0 3px 0 rgba(0,40,70,.4); }
#stage .load-in b { font-size: clamp(20px, 6vw, 32px); letter-spacing: 3px; }
#stage .load-in span { font-size: 14px; }
#stage .spinner { width: 42px; height: 42px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); border-top-color: var(--sun); animation: srspin .8s linear infinite; }
@keyframes srspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(11,42,74,.88); font-weight: 700; }

/* ---------- buttons and panels ---------- */
#stage .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 16px; border: 0; border-radius: 12px; font-weight: 800; font-size: 15px; letter-spacing: .3px; background: rgba(255,255,255,.18); color: #fff; text-decoration: none; box-shadow: none; }
#stage .btn.primary { background: linear-gradient(#ff8a5b, var(--coral)); box-shadow: 0 4px 0 #b83d2c; }
#stage .btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b83d2c; }
#stage .btn.ghost { background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
#stage .btn.danger { background: #d92f2f; }
#stage .btn.small { min-height: 44px; padding: 6px 12px; font-size: 14px; }
#stage .btn.big { font-size: 24px; min-height: 58px; padding: 10px 28px; width: 100%; }
#stage .btn.off { opacity: .55; }
#stage .panel { background: rgba(8,36,64,.82); border-radius: 18px; padding: 12px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); touch-action: pan-y; }
#stage .panel.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; max-height: 100%; }
#stage .panel h2 { font-size: 24px; text-align: center; margin-bottom: 6px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
#stage .panel h3 { font-size: 15px; margin: 10px 0 6px; color: var(--sun); letter-spacing: .5px; }
#stage .meta, #stage .tip, #stage .sub { font-size: 13px; opacity: .85; text-align: center; margin: 3px 0; }
#stage .chip { display: inline-flex; align-items: center; min-height: 30px; padding: 3px 10px; border-radius: 15px; background: rgba(0,0,0,.35); font-weight: 800; font-size: 14px; }
#stage .bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(255,255,255,.2); overflow: hidden; }
#stage .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--sun)); }
#stage .stars { color: var(--sun); font-size: 22px; letter-spacing: 3px; text-align: center; }
#stage .btnrow { display: flex; gap: 8px; margin-top: 8px; }
#stage .btnrow .btn { flex: 1; padding-left: 6px; padding-right: 6px; }

#stage .screen { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#stage .screen > * { pointer-events: auto; }
#stage .screen.center { display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(5,25,45,.55); }
#stage .screen.center .panel { width: 100%; max-width: 330px; max-height: 100%; overflow-y: auto; }
#stage .panel.small { display: flex; flex-direction: column; gap: 8px; }
#stage .screen.full { display: flex; flex-direction: column; padding: max(8px, env(safe-area-inset-top)) 10px 10px; background: linear-gradient(rgba(5,25,45,.78), rgba(5,25,45,.92)); }
#stage .screen.full .panel { flex: 1; min-height: 0; }
#stage .bar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
#stage .bar-top h2 { flex: 1; text-align: center; font-size: 20px; margin: 0; }
#stage .toast { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 30; max-width: 86%; padding: 9px 14px; border-radius: 12px; background: rgba(0,0,0,.78); font-weight: 700; font-size: 14px; text-align: center; pointer-events: none; }

/* ---------- home ---------- */
#stage .home { display: flex; flex-direction: column; justify-content: space-between; padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
#stage .home-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
#stage .logo { display: flex; align-items: baseline; gap: 6px; text-shadow: 0 3px 0 rgba(0,40,70,.55); }
#stage .logo b { font-size: clamp(22px, 7vw, 32px); letter-spacing: 2px; }
#stage .logo span { font-size: 18px; color: var(--sun); font-weight: 800; }
#stage .chips { display: flex; gap: 6px; }
#stage .rankbar { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
#stage .rankbar .bar { height: 8px; }
#stage .panel.dock { display: flex; flex-direction: column; gap: 6px; max-height: 66%; overflow-y: auto; }
#stage .modes { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; touch-action: pan-x; }
#stage .pill { flex: 0 0 auto; min-height: 44px; padding: 4px 12px; border: 0; border-radius: 22px; background: rgba(255,255,255,.14); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
#stage .pill.on { background: var(--teal); color: #052a3a; }
#stage .pill.lock { opacity: .6; }
#stage .pill small { font-size: 10px; font-weight: 700; }
#stage .picker { display: flex; align-items: center; gap: 6px; }
#stage .picker .arrow { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.16); font-size: 18px; }
#stage .beach { flex: 1; text-align: center; display: flex; flex-direction: column; }
#stage .beach b { font-size: 19px; }
#stage .beach small { font-size: 12px; opacity: .85; }
#stage .info { min-height: 0; font-size: 13px; text-align: center; }
#stage .info p { margin: 2px 0; }
#stage .info .meta { opacity: .8; }
#stage .board { margin: 0; }

/* ---------- shop / goals / settings ---------- */
#stage .list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#stage .card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255,255,255,.1); }
#stage .card.sel { box-shadow: inset 0 0 0 2px var(--teal); }
#stage .card .ct { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#stage .card .ct small { font-size: 12px; opacity: .8; }
#stage .card .sw { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
#stage .lv { display: flex; gap: 4px; margin-top: 3px; }
#stage .lv i { width: 16px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.2); }
#stage .lv i.on { background: var(--sun); }
#stage .mission, #stage .ach { padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.1); margin-bottom: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
#stage .mission.done, #stage .ach.done { background: rgba(78,224,138,.22); }
#stage .mission small, #stage .ach small { font-size: 12px; opacity: .8; }
#stage .set { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 4px 2px; border-bottom: 1px solid rgba(255,255,255,.12); font-weight: 700; font-size: 15px; }
#stage .set input[type=range] { flex: 1; max-width: 55%; height: 32px; touch-action: pan-x; accent-color: var(--teal); }
#stage .seg { display: flex; gap: 4px; }

/* ---------- HUD ---------- */
#stage .hud { position: absolute; inset: 0; z-index: 3; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) 10px 0; }
#stage .danger { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(255,255,255,0) 45%, rgba(255,255,255,.7) 100%); }
#stage .hud-top { position: relative; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; padding-right: 50px; }
#stage .stat { background: rgba(8,36,64,.6); border-radius: 12px; padding: 4px 9px; display: flex; align-items: baseline; gap: 5px; min-height: 32px; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#stage .stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
#stage .stat .lbl { font-size: 10px; opacity: .8; letter-spacing: 1px; }
#stage .mult { background: rgba(255,255,255,.25); color: #fff; border-radius: 8px; padding: 0 6px; font-weight: 800; font-size: 13px; }
#stage .mult.on { background: var(--sun); color: #4a3200; }
#stage .hud-sub { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-right: 50px; }
#stage .pips { display: flex; gap: 4px; }
#stage .pips i { width: 14px; height: 18px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; background: rgba(255,255,255,.25); }
#stage .pips i.on { background: #4dd6ff; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
#stage .prog { flex: 1; position: relative; height: 18px; border-radius: 9px; background: rgba(8,36,64,.55); overflow: hidden; display: flex; align-items: center; justify-content: center; }
#stage .meter { position: absolute; inset: 0; }
#stage .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--sun)); transform-origin: left; transform: scaleX(0); }
#stage .prog b { position: relative; font-size: 11px; letter-spacing: .5px; }
#stage .breakbar { position: relative; height: 16px; margin: 6px 50px 0 0; border-radius: 8px; background: linear-gradient(90deg, #fff, rgba(255,255,255,.25) 35%, rgba(8,36,64,.5)); overflow: hidden; }
#stage .breakbar span { position: absolute; left: 6px; top: 0; font-size: 10px; line-height: 16px; font-weight: 800; color: #0b2a4a; letter-spacing: 1px; }
#stage .breakbar i { position: absolute; top: 2px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 2px #fff; left: 100%; }
#stage .breakbar.low i { background: #ff4d4d; animation: srblink .35s infinite alternate; }
@keyframes srblink { to { transform: scale(1.4); } }
#stage .pausebtn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(8,36,64,.7); font-weight: 800; font-size: 16px; pointer-events: auto; letter-spacing: 1px; }
#stage .feed { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#stage .pop { padding: 3px 12px; border-radius: 14px; background: rgba(8,36,64,.65); font-weight: 800; font-size: 15px; animation: srpop 1.6s ease-out forwards; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
#stage .pop.trick { background: rgba(255,201,77,.92); color: #4a3200; text-shadow: none; }
#stage .pop.beat { background: rgba(25,194,181,.9); color: #03333a; text-shadow: none; }
@keyframes srpop { 0% { transform: translateY(8px) scale(.7); opacity: 0; } 12% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-16px); opacity: 0; } }
#stage .hint-bubble { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); width: 84%; max-width: 300px; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 800; font-size: 15px; text-align: center; padding: 10px 14px; border-radius: 16px; pointer-events: none; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
#stage .banner { position: absolute; left: 0; right: 0; top: 18%; text-align: center; display: flex; flex-direction: column; align-items: center; pointer-events: none; text-shadow: 0 3px 0 rgba(0,40,70,.6); animation: srpop 1.8s ease-out forwards; }
#stage .banner b { font-size: 34px; letter-spacing: 2px; }
#stage .banner span { font-size: 15px; font-weight: 700; }
#stage .flash { position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .22s; }
#stage .flash.on { opacity: .42; }
#stage .flash.white { background: #fff; }
#stage .flash.red { background: #ff2d2d; }

#stage .exitbig { position: absolute; left: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 130px); z-index: 40; min-height: 44px; min-width: 44px; padding: 6px 12px; border: 0; border-radius: 12px; background: rgba(8,36,64,.75); color: #fff; font-weight: 800; font-size: 13px; pointer-events: auto; }

/* ---------- controls ---------- */
#stage .controls { position: absolute; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); height: 124px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; pointer-events: none; }
#stage .controls.lefty { flex-direction: row-reverse; }
#stage .pad { position: relative; width: min(52%, 190px); height: 92px; border-radius: 46px; background: rgba(8,36,64,.5); box-shadow: inset 0 0 0 3px rgba(255,255,255,.4); touch-action: none; display: flex; align-items: center; justify-content: center; }
#stage .pad .arr { position: absolute; top: 50%; transform: translateY(-50%); font-size: 22px; opacity: .6; pointer-events: none; }
#stage .pad .arr.l { left: 16px; } #stage .pad .arr.r { right: 16px; }
#stage .pad i { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 3px 0 rgba(0,0,0,.25); pointer-events: none; }
#stage .cbtn { position: relative; border: 0; border-radius: 50%; font-weight: 800; letter-spacing: .5px; pointer-events: auto; touch-action: none; box-shadow: 0 5px 0 rgba(0,0,0,.28); }
#stage .cbtn.pump { width: 96px; height: 96px; background: linear-gradient(#35e0d0, var(--teal-d)); font-size: 17px; }
#stage .cbtn.jump { width: 72px; height: 72px; margin-bottom: 4px; background: linear-gradient(#ffd56b, #ff9f1c); color: #4a2d00; font-size: 14px; }
#stage .cbtn.flip { background: linear-gradient(#c9a8ff, #7a4de0); }
#stage .cbtn.down { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.28); }
#stage .cbtn span { position: relative; z-index: 1; pointer-events: none; }
#stage .ring { position: absolute; inset: -2px; border-radius: 50%; border: 4px solid rgba(255,255,255,.85); pointer-events: none; will-change: transform; }
#stage .ring.good { border-color: var(--good); box-shadow: 0 0 12px var(--good); }

/* ---------- results ---------- */
#stage .results { text-align: center; }
#stage .bigscore { display: flex; flex-direction: column; align-items: center; margin: 2px 0 4px; }
#stage .bigscore b { font-size: 40px; font-variant-numeric: tabular-nums; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
#stage .bigscore em { font-style: normal; background: var(--sun); color: #4a3200; padding: 1px 10px; border-radius: 10px; font-weight: 800; font-size: 13px; }
#stage .rows { margin: 6px 0; }
#stage .row { display: flex; justify-content: space-between; padding: 3px 4px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
#stage .xp { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; margin: 8px 0; }
#stage .note { font-size: 13px; margin: 3px 0; }
#stage .note.good { color: var(--good); font-weight: 800; }
#stage .next { font-size: 13px; margin-top: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.1); }

@media (max-height: 560px) {
  #stage .panel.dock { max-height: 74%; }
  #stage .cbtn.pump { width: 84px; height: 84px; } #stage .cbtn.jump { width: 64px; height: 64px; }
  #stage .pad { height: 80px; }
  #stage .controls { height: 108px; }
}
@media (prefers-reduced-motion: reduce) { #stage .pop, #stage .banner { animation-duration: .01s; } }

#stage .bestchip { display: block; font-size: 11px; font-weight: 800; letter-spacing: .04em; opacity: .85; margin-top: 2px; text-shadow: 0 1px 0 rgba(0,0,0,.35); font-variant-numeric: tabular-nums; }
#stage .bestchip:empty { display: none; }
#stage .bestchip.beat { color: var(--sun); opacity: 1; animation: bestpulse .9s ease-in-out infinite alternate; }
@keyframes bestpulse { from { transform: scale(1); } to { transform: scale(1.12); } }
#stage .bestline { font-size: 13px; font-weight: 700; opacity: .9; margin: 2px 0 6px; text-align: center; }
@media (prefers-reduced-motion: reduce) { #stage .bestchip.beat { animation: none; } }
#stage .stat.score { flex-wrap: wrap; row-gap: 0; }
#stage .stat.score .bestchip { flex-basis: 100%; margin-top: 0; }

/* ---------- full screen on phones (shell immersive or native) ---------- */
html.pip-immersive .sr-bar, html.pip-immersive .sr-keys, html.pip-immersive .sr-guide,
html.pip-native .sr-bar, html.pip-native .sr-keys, html.pip-native .sr-guide,
#stage:fullscreen ~ .sr-bar { display: none; }
html.pip-immersive #stage .exitbig, html.pip-native #stage .exitbig { display: none; }
html.pip-immersive #stage, html.pip-native #stage { touch-action: none; }
html.pip-immersive #stage .controls, html.pip-native #stage .controls { bottom: max(14px, env(safe-area-inset-bottom)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
html.pip-immersive #stage .pausebtn, html.pip-native #stage .pausebtn { right: max(8px, env(safe-area-inset-right)); }
/* depth: soft vignette and a shade under the thumbs, drawn once by the compositor */
#stage #app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 58%, rgba(4,28,52,.28) 100%), linear-gradient(rgba(0,0,0,0) 72%, rgba(4,28,52,.22)); }
@media (orientation: landscape) and (max-height: 500px) {
  #stage .controls { height: 96px; }
  #stage .pad { width: min(34%, 220px); height: 76px; }
  #stage .cbtn.pump { width: 76px; height: 76px; } #stage .cbtn.jump { width: 60px; height: 60px; }
  #stage .panel.dock { max-height: 82%; }
  #stage .screen.center .panel { max-width: 420px; }
  #stage .home { padding-top: max(6px, env(safe-area-inset-top)); }
  #stage .logo b { font-size: 22px; }
}
