/* pw/pw.css
   Cocks & Rubbers arena -- navy / red / blue police theme.
   bg #070e2a  |  blue #2f6bff  |  red #ff2f45  |  light text #eaf1ff
   Scopes everything under #arena so it never leaks into the host page. */

#arena {
  --pw-bg:    #070e2a;
  --pw-bg2:   #0b1636;
  --pw-blue:  #2f6bff;
  --pw-red:   #ff2f45;
  --pw-text:  #eaf1ff;
  --pw-dim:   rgba(234, 241, 255, 0.6);
  --pw-edge:  rgba(234, 241, 255, 0.14);
  --pw-panel: rgba(7, 14, 42, 0.82);

  position: relative;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  aspect-ratio: 16 / 10;
  max-height: 82vh;
  border-radius: 16px;
  overflow: hidden;
  background: var(--pw-bg);
  background-image:
    radial-gradient(120% 90% at 50% -10%, rgba(47, 107, 255, 0.18), transparent 60%),
    radial-gradient(90% 80% at 50% 115%, rgba(255, 47, 69, 0.12), transparent 60%);
  box-shadow:
    0 0 0 1px var(--pw-edge),
    0 24px 70px rgba(0, 0, 0, 0.55);
  color: var(--pw-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}

/* Fullscreen: fill the screen, drop the rounded frame. 100dvh survives the iOS
   toolbar resize; 100vh is the desktop fallback. */
#arena:fullscreen,
#arena:-webkit-full-screen {
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
  border-radius: 0;
}

/* CSS pseudo-fullscreen fallback (iPhone Safari has no <div> fullscreen). main.js
   toggles .pw-pseudo-fs on <body>; pin #arena to the whole viewport with 100dvh. */
body.pw-pseudo-fs #arena {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  margin: 0;
}
body.pw-pseudo-fs {
  overflow: hidden;
}

/* ---- the canvas ---- */
#arena #pwCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--pw-bg);
  touch-action: pan-y;
  cursor: crosshair;
}

/* ================= top control bar ================= */
/* Safe-area aware: on notched phones (and pseudo/real fullscreen) keep the chips out
   from under the status bar / camera notch. Needs viewport-fit=cover (set by main.js). */
#arena .pw-topbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
#arena .pw-topbar .pw-chip {
  pointer-events: auto;
}

/* small ghost buttons (fullscreen / mute) */
#arena .pw-chip {
  appearance: none;
  border: 1px solid var(--pw-edge);
  background: var(--pw-panel);
  color: var(--pw-text);
  font: 600 12px/1 system-ui, sans-serif;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
#arena .pw-chip:hover { border-color: var(--pw-blue); }
#arena .pw-chip:active { transform: translateY(1px); }

/* ================= start / round-over overlay ================= */
#arena #pwOverlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(90% 70% at 50% 40%, rgba(11, 22, 54, 0.72), rgba(7, 14, 42, 0.92));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 1;
  transition: opacity 0.22s ease;
}
#arena #pwOverlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}
#arena #pwOverlay[hidden] { display: none; }

#arena .pw-card {
  width: min(520px, 100%);
  text-align: center;
  background: var(--pw-panel);
  border: 1px solid var(--pw-edge);
  border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

#arena .pw-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 700 12px/1 system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pw-dim);
  margin-bottom: 12px;
}
#arena .pw-badge .pw-dot-blue,
#arena .pw-badge .pw-dot-red {
  width: 9px; height: 9px; border-radius: 50%;
}
#arena .pw-badge .pw-dot-blue { background: var(--pw-blue); box-shadow: 0 0 10px var(--pw-blue); }
#arena .pw-badge .pw-dot-red  { background: var(--pw-red);  box-shadow: 0 0 10px var(--pw-red); }

#arena #pwOverlayTitle {
  margin: 0 0 10px;
  font: 800 clamp(30px, 5.4vw, 52px)/1.02 system-ui, sans-serif;
  letter-spacing: 0.01em;
  background: linear-gradient(92deg, var(--pw-blue), #eaf1ff 55%, var(--pw-red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#arena #pwOverlaySub {
  margin: 0 auto 20px;
  max-width: 42ch;
  color: var(--pw-dim);
  font: 500 14px/1.5 system-ui, sans-serif;
}

/* team select */
#arena .pw-teams {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 0 0 18px;
}
#arena .pw-team {
  appearance: none;
  cursor: pointer;
  flex: 1 1 0;
  max-width: 180px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(7, 14, 42, 0.6);
  border: 1.5px solid var(--pw-edge);
  color: var(--pw-text);
  font: 700 14px/1 system-ui, sans-serif;
  letter-spacing: 0.03em;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
#arena .pw-team small {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  font-size: 11px;
  color: var(--pw-dim);
}
#arena .pw-team[data-pw-team="cocks"].is-active {
  border-color: var(--pw-blue);
  background: rgba(47, 107, 255, 0.16);
  box-shadow: 0 0 0 1px var(--pw-blue) inset;
}
#arena .pw-team[data-pw-team="rubbers"].is-active {
  border-color: var(--pw-red);
  background: rgba(255, 47, 69, 0.16);
  box-shadow: 0 0 0 1px var(--pw-red) inset;
}
#arena .pw-team:active { transform: translateY(1px); }

/* primary start button */
#arena #pwStart {
  appearance: none;
  cursor: pointer;
  display: inline-block;
  min-width: 220px;
  padding: 15px 30px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font: 800 17px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(92deg, var(--pw-blue), var(--pw-red));
  box-shadow: 0 10px 28px rgba(47, 107, 255, 0.35), 0 6px 20px rgba(255, 47, 69, 0.28);
  transition: transform 0.06s ease, filter 0.15s ease;
}
#arena #pwStart:hover { filter: brightness(1.08); }
#arena #pwStart:active { transform: translateY(2px) scale(0.99); }
#arena #pwStart:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

#arena .pw-hint {
  margin: 16px 0 0;
  color: var(--pw-dim);
  font: 500 12px/1.4 system-ui, sans-serif;
}

/* ================= mobile twin virtual joysticks ================= */
/* SINGLE renderer: the floating sticks + action button are drawn entirely on-canvas by
   input.renderTouchUI so they can follow the thumb and reflect real state. The old DOM
   guide rings (.pw-sticks) are intentionally NOT styled here -- rendering them too gave
   two overlapping rings per control, and once the sticks became floating the fixed DOM
   rings disagreed with the live canvas sticks. Any stray .pw-sticks node in the markup
   stays fully hidden. */
#arena .pw-sticks { display: none !important; }

/* Respect small screens: let the arena go taller so controls have room. */
@media (max-width: 640px) {
  #arena {
    aspect-ratio: 3 / 4;
    max-height: 88vh;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #arena #pwOverlay,
  #arena #pwStart,
  #arena .pw-chip,
  #arena .pw-team { transition: none; }
}

/* Round-over: winning team's character */
#pwWinnerImg{
  display:block;width:132px;height:132px;object-fit:contain;margin:0 auto .4rem;
  filter:drop-shadow(0 12px 20px rgba(0,0,0,.55));
  animation:pwWinPop .4s cubic-bezier(.2,.9,.3,1.3) both;
}
@keyframes pwWinPop{from{transform:scale(.4);opacity:0}to{transform:scale(1);opacity:1}}
@media(max-width:560px){#pwWinnerImg{width:104px;height:104px}}

/* While a round is live, the canvas fully owns touch (twin-stick). Otherwise the
   page scrolls normally so the game never "sticks" when swiping past it. */
#arena.pw-live #pwCanvas { touch-action: none; }
