html, body {
  margin: 0;
  height: 100%;
  position: fixed;
  inset: 0;
  width: 100%;
  background: #0a0503;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: #fff1d6;
  font-family: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
}
#game { position: fixed; inset: 0; }
canvas { display: block; }

/* Splash: starts pitch black; the art fades + settles in once loaded (with one light sweep).
   Every layer is pinned to the viewport, so a phone that loads already sideways can't push it around. */
#splash {
  position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 20; background: #000; overflow: hidden;
  transition: opacity .45s ease;
}
#splash.out { opacity: 0; pointer-events: none; }
.sp-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) brightness(.45); opacity: 0; transition: opacity 1.6s ease .3s; }
#sp-img { display: none; } /* loads the art; .sp-art shows it */
.sp-art {
  position: absolute; inset: 0; background: center / contain no-repeat; opacity: 0; transform: scale(1.08);
  transition: opacity 1.1s ease, transform 2.6s cubic-bezier(.2,.7,.2,1);
  -webkit-mask: linear-gradient(#000, #000); /* keeps the sweep inside the art box */
}
.sp-art::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,240,210,.32) 50%, transparent 65%);
  transform: translateX(-120%);
}
#splash.shown .sp-art { opacity: 1; transform: none; }
#splash.shown .sp-bg { opacity: 1; }
#splash.shown .sp-art::after { animation: sp-sweep 1.4s ease-in-out 1s 1 forwards; }
@keyframes sp-sweep { to { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .sp-art { transform: none; transition: opacity .6s; } #splash.shown .sp-art::after { animation: none; } }
.sp-fallback {
  display: none; position: absolute; inset: 0; place-content: center; margin: 0 !important; text-align: center; line-height: .95; margin-bottom: 14vh;
  font: clamp(40px, min(12vw, 20vh), 140px) "Bowlby One SC", Impact, sans-serif; color: #f4b52e;
  text-shadow: 0 6px 0 #7a3a10, 0 9px 0 #1c0b05;
}
#splash.no-img #sp-img { display: none; }
#splash.no-img .sp-fallback { display: grid; }
.sp-bottom {
  position: absolute; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom));
  display: grid; justify-items: center; gap: 12px;
}
.sp-bar { width: min(320px, 60vw); height: 8px; border-radius: 4px; background: rgba(255,241,214,.18); overflow: hidden; transition: opacity .3s; }
.sp-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #e8532e, #f4b52e); transition: width .25s; }
#splash.ready .sp-bar { opacity: 0; }
#sp-start {
  font: clamp(22px, 4.5vh, 34px) "Bowlby One SC", Impact, sans-serif; letter-spacing: .04em;
  color: #fff6e6; background: none; border: 0; padding: 10px 28px; cursor: pointer;
  text-shadow: 0 4px 0 #7a3a10, 0 6px 0 #1c0b05;
}
#sp-start:disabled { color: rgba(255,241,214,.55); text-shadow: none; font-size: 16px; cursor: default; }
#splash.ready #sp-start { animation: sp-pulse 1.1s ease-in-out infinite; }
#sp-start:focus-visible { outline: 3px solid #f4b52e; outline-offset: 4px; border-radius: 8px; }
@keyframes sp-pulse { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { #splash.ready #sp-start { animation: none; } }
.sp-tip { margin: 0; font-size: 15px; color: rgba(255,241,214,.7); }

#rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  #rotate {
    position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; gap: 8px; text-align: center;
    background: #120806;
  }
  #rotate b { font: 30px "Bowlby One SC", Impact, sans-serif; color: #f4b52e; }
  #rotate span { font-size: 20px; opacity: .8; }
}

/* ---- touch controls ---- */
#touch { display: none; }
#touch.on { display: block; }
.t-zone { position: absolute; left: 0; top: 18%; width: 46%; bottom: 0; touch-action: none; }
.t-stick {
  position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: 14px;
  width: calc(min(150px, 34vh) * var(--tscale, 1)); height: calc(min(150px, 34vh) * var(--tscale, 1)); pointer-events: none; opacity: calc(var(--top, .8) * .7); transition: opacity .15s;
}
.t-stick.on { opacity: .9; }
.t-base {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,241,214,.18), rgba(255,241,214,.05));
  border: 2px solid rgba(255,241,214,.28);
}
.t-knob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; transform-origin: center;
  margin: -21% 0 0 -21%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f7d08a, #c8693c 60%, #7d3a1d);
  box-shadow: 0 3px 8px rgba(0,0,0,.5);
}
/* Buttons hug the bottom-right corner in an arc around SP: the bottom row (BLOCK, L, SP) sits below
   the fighters' feet, so only H and K reach up into the fight. SUPER only shows when it's ready.
   Positions are button centres, measured in --s from the corner (right, bottom). */
.t-btns {
  --s: calc(min(66px, 14.5vh) * var(--tscale, 1));
  position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: 6px;
  width: calc(var(--s) * 3.8); height: calc(var(--s) * 3.5); pointer-events: none;
}
.t-b {
  --d: 1; --x: 0; --y: 0;
  position: absolute; width: calc(var(--s) * var(--d)); height: calc(var(--s) * var(--d)); border-radius: 50%; border: 0; padding: 0;
  right: calc(var(--s) * (var(--x) - var(--d) / 2)); bottom: calc(var(--s) * (var(--y) - var(--d) / 2));
  font: calc(var(--s) * .3) "Bowlby One SC", Impact, sans-serif; color: #2a1208;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 3px 8px rgba(0,0,0,.35);
  touch-action: none; pointer-events: auto; opacity: var(--top, .55); transition: opacity .12s;
}
.t-b.on { transform: scale(.9); filter: brightness(1.2); opacity: 1; }
.t-S { --x: .62; --y: .62; --d: 1.2; background: radial-gradient(circle at 35% 30%, #ff9f87, #e8532e); }
.t-L { --x: 2.2; --y: .55; background: radial-gradient(circle at 35% 30%, #fff1d6, #e9d2a8); }
.t-H { --x: 1.75; --y: 1.72; background: radial-gradient(circle at 35% 30%, #ffd98a, #f4b52e); }
.t-K { --x: .62; --y: 2.2; background: radial-gradient(circle at 35% 30%, #c5ecd9, #8fcfb4); }
.t-G { --x: 3.3; --y: .55; --d: .95; font-size: calc(var(--s) * .2); color: #eaf4ff; background: radial-gradient(circle at 35% 30%, #8fb4d8, #3c5f86); border-radius: 46% 46% 50% 50% / 38% 38% 62% 62%; }
.t-X { width: calc(var(--s) * 1.3); height: calc(var(--s) * .6); right: calc(var(--s) * 1.3); bottom: calc(var(--s) * 2.55); border-radius: 99px; font-size: calc(var(--s) * .24); background: linear-gradient(#ffd25a, #ff7b2e); opacity: 0; pointer-events: none; transform: scale(.6); transition: opacity .15s, transform .15s; }
.t-X.ready { opacity: 1; pointer-events: auto; transform: none; box-shadow: 0 0 calc(var(--s) * .35) #ffb23a, inset 0 -4px 0 rgba(0,0,0,.25); }
.t-X.ready.on { transform: scale(.9); }
.t-A { width: calc(var(--s) * .8); height: calc(var(--s) * .44); right: calc(var(--s) * .15); bottom: calc(var(--s) * 2.93); border-radius: 99px; font-size: calc(var(--s) * .19); background: linear-gradient(#bfe4ff, #5ab3e8); opacity: calc(var(--top, .55) * .8); }
.t-pause {
  position: absolute; top: max(6px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 38px; height: 30px; border-radius: 9px; border: 1px solid rgba(255,241,214,.3);
  background: rgba(20,8,4,.55); color: #fff1d6; font: 14px "Bowlby One SC", Impact, sans-serif; opacity: .8;
}

/* Left-handed layout: buttons on the left, stick on the right. */
#touch.lefty .t-zone { left: auto; right: 0; }
#touch.lefty .t-stick { left: auto; right: max(18px, env(safe-area-inset-right)); }
#touch.lefty .t-btns { right: auto; left: max(12px, env(safe-area-inset-left)); transform: scaleX(-1); }
#touch.lefty .t-b { transform: scaleX(-1); }
#touch.lefty .t-b.on { transform: scaleX(-1) scale(.9); }
#touch.lefty .t-X:not(.ready) { transform: scaleX(-1) scale(.6); }
#touch.lefty .t-pause { right: auto; left: max(10px, env(safe-area-inset-left)); }
