:root {
  --bg: #081529;
  --panel: rgba(12, 28, 54, 0.88);
  --border: rgba(255, 255, 255, 0.16);
  --text: #f3f7ff;
  --muted: #a9c0de;
  --red: #d9383a;
  --green: #2e8b57;
  --gold: #ffd54f;
  --accent: #4fc3f7;
  --target-size: 24px;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

h1, h2, h3 {
  text-wrap: balance;
  margin: 0;
}

p {
  text-wrap: pretty;
  margin: 0;
}

:where(button, select, input) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
  font: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Floating Top HUD overlay (leaves 100% full-screen height for 3D play!) */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding: max(0.45rem, env(safe-area-inset-top, 0px)) max(0.6rem, env(safe-area-inset-right, 0px)) 0.25rem max(0.6rem, env(safe-area-inset-left, 0px));
  background: transparent;
  border-bottom: none;
  pointer-events: none;
  z-index: 5;
}

.hud > :not(button, input, select) {
  min-inline-size: 0;
}

.scoreboard {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.32rem;
  font-weight: 800;
  font-size: 0.84rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.56rem;
  border-radius: 999px;
  background: rgba(8, 21, 41, 0.66);
  border: 1.5px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(5px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.36);
  white-space: nowrap;
}

.pill.timer {
  color: var(--gold);
  border-color: rgba(255, 213, 79, 0.65);
}

.hud-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.3rem;
  pointer-events: auto;
}
.hud-actions .btn.small {
  background: rgba(8, 21, 41, 0.64);
  backdrop-filter: blur(5px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.34);
}

/* Circular TPS Radar Minimap (top-left under HUD pills) */
.minimap {
  position: absolute;
  top: calc(max(0.45rem, env(safe-area-inset-top, 0px)) + 2.55rem);
  left: max(0.6rem, env(safe-area-inset-left, 0px));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2.5px solid rgba(179, 229, 252, 0.72);
  background: rgba(8, 21, 41, 0.62);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 0 12px rgba(79, 195, 247, 0.22);
  pointer-events: none;
  z-index: 5;
}
@media (min-width: 720px) {
  .minimap {
    width: 112px;
    height: 112px;
  }
}

.status-badge {
  font-size: 0.74rem;
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-badge.open { background: rgba(46, 139, 87, 0.28); color: #a5f3c5; border-color: rgba(46, 139, 87, 0.65); }
.status-badge.warn { background: rgba(255, 213, 79, 0.22); color: #ffe082; border-color: rgba(255, 213, 79, 0.6); }
.status-badge.err  { background: rgba(217, 56, 58, 0.28); color: #ffb4b4; border-color: rgba(217, 56, 58, 0.65); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.18); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--red); border-color: rgba(255, 255, 255, 0.25); }
.btn.primary:hover { background: #e84547; }
.btn.green { background: var(--green); border-color: rgba(255, 255, 255, 0.25); }
.btn.green:hover { background: #369e63; }
.btn.small { padding: 0.18rem 0.5rem; font-size: 0.76rem; border-radius: 8px; }

/* 3D Stage */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #0c1f3d;
}

canvas#arena {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Roster & invite strip */
.roster-bar {
  position: absolute;
  top: 0.45rem;
  left: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
  pointer-events: none;
  z-index: 4;
}

.roster-chip, .invite-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(8, 21, 41, 0.78);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  backdrop-filter: blur(6px);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #888;
}
.dot.on { background: #69f0ae; }

/* Touch / On-screen Controls Overlay */
.touch-ui {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 max(0.85rem, env(safe-area-inset-right, 0px)) max(0.85rem, env(safe-area-inset-bottom, 0px)) max(0.85rem, env(safe-area-inset-left, 0px));
  pointer-events: none;
  z-index: 4;
}
.touch-ui[hidden] { display: none; }

.joy-pad {
  pointer-events: auto;
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(8, 21, 41, 0.46);
  border: 2px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
  touch-action: none;
}

.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #90caf9);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translate(0px, 0px);
}

.action-col {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.42rem;
  pointer-events: none;
}
.joy-pad[hidden],
.action-col[hidden],
.escape-btn[hidden] {
  display: none;
}
.escape-btn {
  pointer-events: auto;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid #fff59d;
  background: radial-gradient(circle at 35% 30%, #ff7043, #c62828);
  color: #ffffff;
  font-weight: 900;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  box-shadow: 0 0 26px rgba(255, 112, 67, 0.95), 0 8px 22px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.05s ease, box-shadow 0.08s ease;
  animation: escapePulse 0.55s infinite alternate;
}
.escape-btn:active {
  transform: scale(0.88);
  box-shadow: 0 0 36px rgba(255, 245, 157, 1), 0 4px 12px rgba(0, 0, 0, 0.5);
}
.escape-btn.locked {
  border-color: rgba(179, 229, 252, 0.7);
  background: radial-gradient(circle at 35% 30%, #78909c, #37474f);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  opacity: 0.78;
  animation: none;
  cursor: default;
}
.escape-btn.locked:active {
  transform: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
@keyframes escapePulse {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}
.escape-banner {
  position: fixed;
  top: 41%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 44;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.escape-banner[hidden] { display: none; }
.escape-banner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transform-origin: 50% 60%;
  will-change: transform, opacity;
}
.escape-banner-img {
  display: block;
  height: auto;
  width: min(86vw, 470px);
  max-height: 36vh;
  object-fit: contain;
  filter: drop-shadow(0 12px 22px rgba(8, 24, 16, 0.5))
          drop-shadow(0 2px 6px rgba(255, 255, 255, 0.24));
}
.escape-banner-sub {
  margin-top: -0.1rem;
  text-align: center;
  font-size: clamp(1.25rem, 4.8vw, 1.85rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.15;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: #fff176;
  -webkit-text-stroke: 4px rgba(10, 32, 18, 0.96);
  paint-order: stroke fill;
  text-shadow: 0 5px 14px rgba(6, 20, 12, 0.85), 0 0 16px rgba(0, 0, 0, 0.45);
}
.escape-banner.locked .escape-banner-sub {
  color: #b3e5fc;
}
.escape-banner.is-in .escape-banner-inner {
  animation: poyoyonIn 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.escape-banner.is-idle .escape-banner-inner {
  animation: poyoyonIdle 1.05s ease-in-out infinite;
}
.escape-banner.is-boing .escape-banner-inner {
  animation: boingMash 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.escape-banner.is-out .escape-banner-inner {
  animation: boingEscapeOut 0.48s cubic-bezier(0.32, 0, 0.22, 1) forwards;
}

@keyframes boingMash {
  0% {
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
  26% {
    transform: translateY(10px) scale(1.26, 0.74) rotate(var(--boing-tilt, -4deg));
  }
  58% {
    transform: translateY(-14px) scale(0.84, 1.24) rotate(calc(var(--boing-tilt, -4deg) * -0.75));
  }
  80% {
    transform: translateY(3px) scale(1.08, 0.93) rotate(calc(var(--boing-tilt, -4deg) * 0.3));
  }
  100% {
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
}

@keyframes boingEscapeOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
  24% {
    opacity: 1;
    transform: translateY(15px) scale(1.36, 0.65) rotate(4deg);
  }
  54% {
    opacity: 1;
    transform: translateY(-30px) scale(0.75, 1.48) rotate(-5deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-96px) scale(1.52, 0.24) rotate(8deg);
  }
}

.angle-gauge {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.3rem 0.65rem;
  border-radius: 12px;
  background: rgba(8, 21, 41, 0.88);
  border: 2px solid var(--gold);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  min-width: 82px;
}
.angle-gauge[hidden] { display: none; }
.angle-val {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--gold);
  line-height: 1.1;
}
.angle-bar {
  width: 68px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.angle-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #4fc3f7, #ffca28, #ef5350);
  border-radius: 999px;
}

.action-btns {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
}
.shoot-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.42rem;
  pointer-events: none;
}

/* Unified Snowball Stock + Reload Pill Button */
.gather-btn {
  pointer-events: auto;
  min-width: 96px;
  height: auto;
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  border: 2px solid #9be2ff;
  background: linear-gradient(180deg, rgba(16, 78, 108, 0.92), rgba(10, 48, 72, 0.95));
  color: #ffffff;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, opacity 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.gather-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
}
.gather-reload-ico {
  font-size: 0.96rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}
.gather-btn.active .gather-reload-ico {
  animation: reloadSpin 0.85s linear infinite;
}
@keyframes reloadSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.gather-btn:active { transform: scale(0.94); }
.gather-btn.full {
  opacity: 0.88;
  border-color: rgba(162, 196, 173, 0.72);
  background: linear-gradient(180deg, rgba(18, 58, 48, 0.9), rgba(12, 40, 34, 0.94));
}
.gather-btn.is-low {
  border-color: rgba(255, 213, 79, 0.95);
}
.gather-btn.is-low .ammo-cur { color: #ffe082; }
.gather-btn.needed {
  border-color: #ff8a80;
  background: linear-gradient(180deg, rgba(128, 28, 42, 0.94), rgba(84, 16, 26, 0.96));
  box-shadow: 0 0 18px rgba(255, 110, 110, 0.85), 0 6px 16px rgba(0, 0, 0, 0.45);
  animation: gatherPulse 0.9s infinite alternate;
}
.gather-btn.needed .ammo-cur { color: #ff8a80; }
.gather-btn.active {
  border-color: #ffffff;
  background: linear-gradient(180deg, #29b6f6, #0277bd);
  box-shadow: 0 0 22px rgba(129, 212, 250, 0.95);
}
.cam-mode-btn {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding: 0 0.58rem;
  white-space: nowrap;
}
@keyframes gatherPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}

.jump-btn {
  pointer-events: auto;
  width: 60px;
  height: 60px;
  position: relative;
  z-index: 2;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: radial-gradient(circle at 35% 30%, #42a5f5, #1565c0);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.68rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease;
}
.jump-btn:active { transform: scale(0.92); }

.throw-btn {
  pointer-events: auto;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #ef5350, #b71c1c);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.06s ease, opacity 0.15s ease, box-shadow 0.12s ease;
}
.throw-btn:active { transform: scale(0.92); }
.throw-btn.aiming {
  border-color: #ffffff;
  box-shadow: 0 0 24px rgba(79, 195, 247, 0.9), 0 8px 20px rgba(0, 0, 0, 0.45);
}
.throw-btn.reloading {
  opacity: 0.55;
  border-color: rgba(255, 255, 255, 0.35);
}
.throw-btn.mode-pickup {
  background: radial-gradient(circle at 35% 30%, #66bb6a, #1b5e20);
  border-color: #ffe082;
  box-shadow: 0 0 18px rgba(102, 187, 106, 0.75);
}
.throw-btn.mode-throw {
  background: radial-gradient(circle at 35% 30%, #26c6da, #006064);
  border-color: #ffd54f;
  box-shadow: 0 0 18px rgba(38, 198, 218, 0.75);
}
.throw-btn.mode-stunned {
  background: radial-gradient(circle at 35% 30%, #78909c, #37474f);
  border-color: rgba(255, 255, 255, 0.3);
  opacity: 0.65;
}
.throw-btn.mode-gather {
  background: radial-gradient(circle at 35% 30%, #42a5f5, #1565c0);
  border-color: #e1f5fe;
  box-shadow: 0 0 18px rgba(66, 165, 245, 0.8);
}
.throw-btn.mode-gathering {
  background: radial-gradient(circle at 35% 30%, #81d4fa, #0277bd);
  border-color: #ffffff;
  box-shadow: 0 0 22px rgba(129, 212, 250, 0.95);
}

/* Constant-size 2D screen-space aiming reticle (works even when aiming into open sky!) */
.aim-reticle-2d {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
  color: #4fc3f7;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 8px rgba(79, 195, 247, 0.7));
}
.aim-reticle-2d.mode-throw {
  color: #ffea00;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 8px rgba(255, 234, 0, 0.75));
}
.aim-reticle-2d svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Toast notice (no zabuton backdrop) */
.toast {
  position: absolute;
  top: 2.6rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.65);
  z-index: 8;
  max-width: 92%;
  text-align: center;
}
.toast[hidden] { display: none; }

/* Slim Non-Blocking Result Top Chip & Bottom Action Dock (keeps cozy hearth scene >85% visible!) */
.title-primary-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
}
.title-primary-row .play-btn {
  flex: 1 1 auto;
}
.title-primary-row .home-btn {
  flex: 0 0 auto;
  padding: 0.55rem 0.95rem;
  background: linear-gradient(180deg, #e5a93c, #b87614);
  color: #1e1204;
  border: 2px solid #ffe39b;
  font-weight: 900;
  white-space: nowrap;
}

.result-top-chip {
  position: fixed;
  top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.34rem 1.05rem;
  border-radius: 999px;
  background: rgba(12, 34, 30, 0.78);
  border: 1.5px solid rgba(244, 206, 118, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  pointer-events: none;
}
.result-top-chip[hidden] { display: none; }
.result-top-title {
  font-weight: 900;
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  color: #ffe69a;
}
.result-top-chip[data-outcome="lose"] .result-top-title { color: #ffb8bc; }
.result-top-chip[data-outcome="draw"] .result-top-title { color: #d8f0ff; }
.result-top-score {
  font-weight: 900;
  font-size: 0.9rem;
  color: #fff6df;
}
.result-dock {
  position: fixed;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  width: min(calc(100% - 1rem), 460px);
  padding: 0.36rem 0.48rem;
  border-radius: 999px;
  background: rgba(10, 26, 24, 0.72);
  border: 1.5px solid rgba(244, 206, 118, 0.72);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
}
.result-dock[hidden] { display: none; }
.result-dock .btn {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0.36rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}
.result-dock .result-board-btn {
  background: linear-gradient(180deg, #e5a93c, #c4841c);
  color: #1e1204;
  border-color: #ffe39b;
}

/* Broadcast-style Goal Replay & Scoreboard Cinematic Overlay (no zabuton backdrop) */
.cine-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.replay-pill {
  position: fixed;
  top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 88px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.26rem 0.85rem;
  border-radius: 999px;
  background: rgba(12, 24, 38, 0.78);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(5px);
  color: #fff;
  font-weight: 900;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 10px #ff3b30;
  animation: recBlink 0.7s infinite alternate;
}
@keyframes recBlink {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0.35; transform: scale(0.8); }
}
.goal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin-top: 15.5rem;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  animation: goalPopIn 0.36s cubic-bezier(0.2, 1.35, 0.4, 1) both;
}
@keyframes goalPopIn {
  from { opacity: 0; transform: scale(0.72) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.goal-title {
  font-size: 1.95rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.92), 0 0 20px rgba(0, 0, 0, 0.7);
}
.goal-title.red   { color: #ff6e66; }
.goal-title.green { color: #7ef7a8; }
.goal-scores {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}
.goal-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 0.2rem 0.45rem;
  background: transparent;
  border: none;
}
.goal-team.red   .goal-team-lbl { color: #ff8a80; }
.goal-team.green .goal-team-lbl { color: #a5f3c5; }
.goal-team-lbl {
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #e6f2ff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}
.goal-team-num {
  font-size: 2.85rem;
  font-weight: 900;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.92), 0 0 18px rgba(0, 0, 0, 0.65);
}
.goal-team.scored .goal-team-num {
  color: var(--gold);
  animation: scoreBump 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
@keyframes scoreBump {
  0%   { transform: scale(0.7); }
  50%  { transform: scale(1.42); }
  100% { transform: scale(1); }
}
.goal-dash {
  font-size: 2.1rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.92);
}

/* Title / Lobby overlay — frameless character-centered showcase (no bulky window/card!) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(2.8rem, env(safe-area-inset-top, 1.4rem) + 1.4rem) 1rem max(1.1rem, env(safe-area-inset-bottom, 0.8rem) + 0.5rem);
  background: linear-gradient(
    to bottom,
    rgba(6, 16, 33, 0.34) 0%,
    rgba(6, 16, 33, 0.0) 24%,
    rgba(6, 16, 33, 0.0) 62%,
    rgba(6, 16, 33, 0.58) 100%
  );
  z-index: 6;
  pointer-events: none;
}
.overlay[hidden] { display: none; }
body:has(#title-overlay:not([hidden])) .scoreboard {
  opacity: 0;
  pointer-events: none;
}

.title-stage {
  width: min(100%, 440px);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  pointer-events: none;
}

.title-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

/* English logo lockup: bold italic display type with candy-red, ice-blue and gold treatments */
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.04em;
  font-family: "Avenir Next Condensed", "Arial Narrow Bold", "Impact", "Haettenschweiler", "Arial Black", system-ui, sans-serif;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  line-height: 0.92;
  transform: rotate(-2.5deg);
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  font-size: clamp(1.6rem, 6.2vw, 3rem);
}
.logo-row {
  display: flex;
  align-items: center;
  gap: 0.28em;
  margin-top: -0.04em;
}
.logo-3d {
  font-size: 1.12em;
  padding: 0.02em 0.28em 0.04em;
  border-radius: 0.28em;
  background: linear-gradient(180deg, #fff3a8 0%, #ffca28 55%, #f08a00 100%);
  color: #6a2300;
  -webkit-text-stroke: 0.02em #6a2300;
  box-shadow: 0 0.06em 0 #8a4a00, 0 0 0.5em rgba(255, 213, 79, 0.6);
  transform: skewX(-6deg);
}

.title-dock {
  width: min(100%, 540px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  pointer-events: auto;
}

.char-picker {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.char-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.34);
  background: rgba(8, 22, 44, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.char-btn:active { transform: scale(0.97); }
.char-stat {
  font-size: 0.66rem;
  font-weight: 700;
  color: #dff2ff;
  opacity: 0.92;
}

/* Snowball Stock HUD above action buttons (crisp numeric readout) */
.ammo-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  padding: 0.24rem 0.68rem;
  border-radius: 999px;
  background: rgba(12, 42, 36, 0.88);
  border: 1.5px solid rgba(182, 232, 255, 0.58);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(5px);
}
.ammo-hud.is-low {
  border-color: rgba(255, 213, 79, 0.9);
}
.ammo-hud.is-empty {
  border-color: rgba(255, 107, 107, 0.95);
  background: rgba(74, 18, 28, 0.9);
}
.ammo-dots {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.18rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}
.ammo-ico {
  font-size: 0.92rem;
  margin-right: 0.12rem;
}
.ammo-cur {
  font-size: 1.12rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.ammo-hud.is-low .ammo-cur { color: #ffe082; }
.ammo-hud.is-empty .ammo-cur { color: #ff8a80; }
.ammo-sep {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(206, 236, 255, 0.72);
}
.ammo-max {
  font-size: 0.86rem;
  font-weight: 800;
  color: rgba(206, 236, 255, 0.88);
}
.ammo-bar {
  width: 78px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.ammo-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4fc3f7, #ffffff);
  transition: width 0.1s linear;
}
.char-btn.active {
  border-color: var(--gold);
  background: rgba(217, 56, 58, 0.62);
  box-shadow: 0 0 14px rgba(255, 213, 79, 0.35);
}

.title-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.play-btn {
  width: 100%;
  padding: 0.72rem 1.2rem;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 22px rgba(217, 56, 58, 0.45);
}

.online-dock {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.online-dock[hidden] { display: none; }

.online-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.sub-inline {
  font-size: 0.76rem;
  color: #e6f2ff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

.btn-stack { display: flex; flex-direction: column; gap: 0.45rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; }

.join-row { display: flex; gap: 0.4rem; }
.join-row input {
  flex: 1 1 auto;
  min-inline-size: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  text-transform: uppercase;
}

.err-box {
  font-size: 0.78rem;
  color: #ffb4b4;
  background: rgba(217, 56, 58, 0.22);
  border: 1px solid rgba(217, 56, 58, 0.55);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}
.err-box[hidden] { display: none; }

/* Native <dialog> modal rules (per modern-web-guidance/dialog) */
dialog.modal {
  padding: 0;
  border: 1px solid rgba(255, 213, 79, 0.45);
  border-radius: 16px;
  background: #0d203d;
  color: var(--text);
  width: min(92vw, 360px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
dialog.modal:modal { overscroll-behavior: contain; }
dialog.modal::backdrop {
  background: rgba(4, 10, 22, 0.72);
  overflow: hidden;
  overscroll-behavior: contain;
}
dialog.modal .modal-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}
dialog.modal h1 { font-size: 1.25rem; }
.result-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.result-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Logo words: ::before = dark outline + extrusion, ::after = gradient fill on top */
.logo-xmas, .logo-snow { position: relative; display: inline-block; color: transparent; }
.logo-xmas { font-size: 1.5em; letter-spacing: 0.06em; --logo-edge: #6d0b12;
  --logo-fill: linear-gradient(180deg, #ffffff 0%, #ffe3e1 30%, #ff5a52 64%, #d01a22 100%); }
.logo-snow { font-size: 1.12em; letter-spacing: 0.1em; --logo-edge: #0b3f66;
  --logo-fill: linear-gradient(180deg, #ffffff 0%, #d9f3ff 45%, #4fb8f2 100%); }
.logo-xmas::before, .logo-snow::before,
.logo-xmas::after, .logo-snow::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  pointer-events: none;
}
.logo-xmas::before, .logo-snow::before {
  z-index: 0;
  color: var(--logo-edge);
  -webkit-text-stroke: 0.13em var(--logo-edge);
  text-shadow: 0 0.09em 0 var(--logo-edge), 0 0.16em 0.1em rgba(0, 0, 0, 0.35);
}
.logo-xmas::after, .logo-snow::after {
  z-index: 1;
  background: var(--logo-fill);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Character select buttons with cropped face portraits */
.char-btn {
  flex-direction: row;
  justify-content: flex-start;
  gap: 0.55rem;
  padding: 0.3rem 0.8rem 0.3rem 0.3rem;
  text-align: left;
}
.char-face {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: #dbe8f8;
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.char-btn.active .char-face {
  border-color: var(--gold);
  transform: scale(1.08);
}
.char-text {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}
.char-name { font-size: 0.86rem; font-weight: 800; white-space: nowrap; }
@media (max-width: 480px) {
  .char-btn {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.18rem;
    padding: 0.34rem 0.25rem;
    border-radius: 16px;
  }
  .char-face { width: 42px; height: 42px; }
  .char-name { font-size: 0.74rem; }
  .char-stat { font-size: 0.6rem; }
}

/* Christmas village UI: painted signs, warm gilt rims, and snowy enamel. */
.app, .modal {
  --festive-pine: #174b3e;
  --festive-pine-dark: #12382e;
  --festive-berry: #a61f36;
  --festive-gold: #f1cb77;
  --festive-cream: #fff7e6;
}

.title-dock {
  background: linear-gradient(180deg, #214e43f5, #102f29fa);
  border: 2px solid var(--festive-gold);
  border-top: 4px solid #fff7e6;
  border-radius: 18px;
  box-shadow: 0 4px 0 #0a2822, 0 10px 24px #0a28224d;
}
.char-btn {
  background: var(--festive-pine-dark);
  border: 2px solid #82b3a3;
  color: var(--festive-cream);
}
.char-btn.active {
  background: #fff2d8;
  border-color: var(--festive-gold);
  color: #203d33;
  box-shadow: 0 2px 0 #bd8342;
}
.char-btn.active .char-stat { color: #4c5b47; }
.char-face { background: #d9eff9; box-shadow: 0 2px 4px #173a3260; }

.app .btn, .modal .btn {
  background: var(--festive-pine);
  border-color: #94bbaa;
  color: var(--festive-cream);
  box-shadow: 0 2px 0 #10332b;
}
.app .btn:hover, .modal .btn:hover { background: #246853; }
.app .btn.primary {
  background: var(--festive-berry);
  border-color: var(--festive-gold);
  box-shadow: inset 0 2px 0 #ffb3aa75, 0 3px 0 #691527;
}
.app .btn.primary:hover { background: #bb2940; }
.app .btn.green, .modal .btn.green { border-color: var(--festive-gold); }

.pill.timer, .roster-chip, .invite-chip, .toast {
  background: var(--festive-pine-dark);
  border: 1px solid var(--festive-gold);
  color: var(--festive-cream);
}
.pill.timer { font-variant-numeric: tabular-nums; }
.minimap { border-color: var(--festive-gold); }

.joy-pad {
  background: #163f36b8;
  border-color: #d7f5e9c9;
}
.joy-knob {
  background: linear-gradient(150deg, #fff 12%, #c3eafa 68%, #77b5cf);
  border-color: #fff7e6;
  box-shadow: 0 3px 0 #46768a, 0 5px 10px #163f3670;
}
.jump-btn {
  background: linear-gradient(160deg, #387287, #20576d);
  border-color: #dbf5ff;
}
.throw-btn:not(.mode-pickup, .mode-throw, .mode-stunned, .mode-gather, .mode-gathering, .aiming, .reloading) {
  background: linear-gradient(155deg, #c13546, #92192d);
  border-color: var(--festive-gold);
  box-shadow: inset 0 2px 0 #ffd0bd9c, 0 4px 0 #731628, 0 7px 12px #14382b52;
}
.ammo-hud { background: #12382ee8; border-color: #a2c4ad; }
.ammo-dot.filled { background: #f7fcff; border-color: #b7e3ee; }

.goal-card, .modal {
  background: linear-gradient(165deg, #235546, #112f2a);
  border: 2px solid var(--festive-gold);
  border-top: 4px solid #fff7e6;
  color: var(--festive-cream);
}
.app button:focus-visible, .app a:focus-visible, .modal button:focus-visible {
  outline: 3px solid #fff2b0;
  outline-offset: 3px;
}

/* A single snowy timber scoreboard with a separate utility row. */
.app {
  --hud-top: max(.6rem, env(safe-area-inset-top, 0px));
  --hud-row: 3.45rem;
  --snow-cap: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20' preserveAspectRatio='none'%3E%3Cpath fill='%23cce7f4' d='M0 13Q6 2 21 4Q33 0 47 5Q59 9 71 4Q90 0 105 5Q118 6 120 14Q117 19 108 17Q100 20 89 15Q80 12 72 17Q62 20 54 15Q44 11 33 16Q23 20 15 15Q4 20 0 13Z'/%3E%3Cpath fill='%23fffaf0' d='M1 12Q6 2 21 3Q33 0 47 4Q59 8 71 3Q90 0 105 4Q116 5 119 12Q109 14 101 10Q87 8 75 13Q62 16 54 11Q44 8 33 13Q23 16 15 11Q6 16 1 12Z'/%3E%3C/svg%3E");
}
.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: start;
  row-gap: .45rem;
  padding-top: var(--hud-top);
}
.scoreboard {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0;
  width: min(100%, 27rem);
  min-height: 2.5rem;
  padding: 0;
  border: 2px solid #f1cb77;
  border-radius: 14px;
  background: #624434;
  box-shadow: 0 3px 0 #69492d, 0 5px 10px #142c4755;
}
.scoreboard::before,
.hud-actions .btn.small::before,
.throw-btn::before,
.jump-btn::before {
  content: "";
  position: absolute;
  pointer-events: none;
  background: var(--snow-cap) center / 100% 100% no-repeat;
}
.scoreboard::before { inset: -8px 0 auto; height: 15px; z-index: 1; }
.scoreboard .pill {
  min-width: 0;
  justify-content: center;
  min-height: 2.5rem;
  border: 0;
  border-radius: 0;
  padding: .15rem .3rem;
  box-shadow: none;
  backdrop-filter: none;
  font-variant-numeric: tabular-nums;
}
.scoreboard .team-score--red { grid-column: 1; grid-row: 1; background: #9e2438; border-radius: 11px 0 0 11px; }
.scoreboard .team-score--green { grid-column: 3; grid-row: 1; background: #21563f; border-radius: 0 11px 11px 0; }
.scoreboard .team-score span { overflow: hidden; text-overflow: ellipsis; font-size: clamp(.65rem, 2.6vw, .85rem); }
.scoreboard .team-score strong { font-size: 1.16rem; }
.scoreboard .timer {
  grid-column: 2; grid-row: 1; min-width: 3.5rem; margin: -.16rem 0;
  z-index: 2; border: 2px solid #d7a75b; border-radius: .82rem;
  background: #fff0cd; color: #214737; font-size: 1rem;
}
.hud-actions {
  justify-self: end;
  max-width: 100%;
  justify-content: end;
  flex-wrap: wrap;
  pointer-events: none;
}
.hud-actions > .btn { pointer-events: auto; }
.hud-actions .btn.small {
  position: relative;
  background: #195143;
  border: 1.5px solid #f1cb77;
  min-height: var(--target-size);
  min-width: var(--target-size);
}
.hud-actions .btn.small::before { inset: -5px 1px auto; height: 10px; }
.hud-actions #leave-btn { background: #9e2438; }
/* Upper-center floating status & toast messages (zero overlap with scoreboard, cookie bar, minimap, or buttons!) */
.hud-actions .status-badge {
  position: fixed;
  top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 88px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  max-width: calc(100vw - 24px);
  padding: 0.24rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(12, 36, 32, 0.88);
  color: #eef8ff;
  border: 1.5px solid rgba(241, 203, 119, 0.72);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(5px);
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast {
  position: fixed;
  top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 88px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 27;
  max-width: calc(100vw - 24px);
}

@media (max-width: 760px) {
  .hud-actions .status-badge,
  .toast,
  .replay-pill {
    top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 138px);
  }
}
.minimap { top: calc(var(--hud-top) + var(--hud-row)); }
.roster-bar { top: calc(var(--hud-top) + var(--hud-row) + 3.1rem); left: max(7rem, env(safe-area-inset-left, 0px)); }
.throw-btn, .jump-btn { position: relative; }
.throw-btn::before, .jump-btn::before { inset: -7px 15% auto; height: 16px; }
.joy-knob { box-shadow: inset -4px -5px 0 #83b8d063, 0 3px 6px #102d4e66; }

/* Give the title logo, character and launch controls their own clear areas. */
body:has(#title-overlay:not([hidden])) .hud { display: none; }
#title-overlay {
  padding-top: max(1rem, env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, #0b2a462e, transparent 27%, transparent 68%, #12382e52);
}
.title-logo { width: min(68vw, 22rem, 51vh); }
.title-dock {
  padding: .4rem;
  background: #143d35ed;
  border: 1px solid #f1cb77;
  border-radius: 16px;
  box-shadow: 0 4px 16px #0a282246;
  gap: .4rem;
}
.title-dock .char-btn {
  min-width: 0;
  min-height: 44px;
  padding: .22rem .36rem;
  border: 1px solid #82b3a3;
  border-radius: 10px;
  gap: .35rem;
  text-shadow: none;
}
.title-dock .char-btn.active { border-color: #f1cb77; box-shadow: none; }
.title-dock .char-face { width: clamp(29px, 9vw, 42px); height: clamp(29px, 9vw, 42px); }
.title-dock .char-name { white-space: normal; line-height: 1.15; }
.title-dock .play-btn { border-radius: 10px; min-height: 44px; box-shadow: none; }

.match-banner {
  position: absolute;
  z-index: 7;
  top: 27%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: .38em .95em;
  border: 2px solid #f1cb77;
  border-radius: 18px;
  background: #8f2340;
  color: #fff7e6;
  box-shadow: 0 4px 0 #572737, 0 8px 20px #142c4740;
  text-align: center;
  font-size: clamp(1.2rem, 5vw, 2.15rem);
  font-weight: 900;
  pointer-events: none;
}
.match-banner::before {
  content: "";
  position: absolute;
  inset: -9px 1px auto;
  height: 17px;
  background: var(--snow-cap) center / 100% 100% no-repeat;
}
.match-banner[data-kind="time"] { background: #214d61; box-shadow: 0 4px 0 #133749; }
.match-banner[data-kind="win"] { background: #23604e; box-shadow: 0 4px 0 #173e34; }
@media (prefers-reduced-motion: no-preference) {
  .match-banner:not([hidden]) { animation: match-banner-pop .22s ease-out; }
  @keyframes match-banner-pop {
    from { opacity: 0; transform: translateX(-50%) scale(.76); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
  }
}

.title-logo { margin: 0; }
.title-logo img { display: block; width: 100%; height: auto; }
.title-dock .char-btn { flex-direction: column; text-align: center; padding: .28rem .18rem; }
.title-dock .char-name { font-size: clamp(.62rem, 2.8vw, .85rem); }
#result-dialog {
  inset: auto 0 max(0.55rem, env(safe-area-inset-bottom));
  margin: 0 auto;
  width: min(calc(100% - 1.2rem), 520px);
  max-height: 88vh;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
#result-dialog[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
#result-dialog::backdrop {
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.0) 0%, rgba(6, 12, 22, 0.06) 52%, rgba(6, 12, 22, 0.42) 100%);
}
#result-dialog .result-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(16, 48, 42, 0.76) 0%, rgba(10, 30, 26, 0.82) 100%);
  border: 1.5px solid rgba(244, 206, 118, 0.82);
  border-top: 3px solid rgba(255, 245, 220, 0.92);
  border-radius: 15px;
  padding: 0.5rem 0.78rem 0.58rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(7px);
  display: flex;
  flex-direction: column;
  gap: 0.36rem;
}
#result-dialog .result-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
}
#result-dialog h1 {
  margin: 0;
  font-size: clamp(1.08rem, 2.5vw, 1.38rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
#result-dialog[data-outcome="win"] h1 { color: #ffe69a; }
#result-dialog[data-outcome="lose"] h1 { color: #ffb8bc; }
#result-dialog[data-outcome="draw"] h1 { color: #d8f0ff; }
.result-teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
}
.result-team-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  background: rgba(6, 22, 20, 0.62);
  border: 1.5px solid color-mix(in srgb, var(--team-col, #fff) 65%, transparent);
  color: var(--team-col, #fff);
  font-weight: 900;
  font-size: 0.78rem;
}
.result-team-chip.is-winner {
  background: linear-gradient(90deg, rgba(255, 213, 79, 0.2), rgba(6, 22, 20, 0.7));
  box-shadow: 0 0 10px rgba(255, 213, 79, 0.24);
}
.result-team-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-team-score {
  flex: none;
  font-size: 0.86rem;
}
#result-dialog .result-list {
  background: transparent;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}
.rank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.24rem 0.36rem;
}
#result-dialog .result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
}
#result-dialog .result-actions .btn {
  min-height: 38px;
  min-width: 132px;
  padding: 0.4rem 1.05rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.42);
}
#result-dialog .result-actions .result-title-btn {
  background: rgba(14, 34, 46, 0.88);
  border: 2px solid rgba(255, 232, 168, 0.78);
  color: #fff8e7;
  backdrop-filter: blur(8px);
}
#result-dialog .result-actions .result-title-btn:hover {
  background: rgba(24, 52, 68, 0.94);
}
.match-banner[data-kind="win"], .match-banner[data-kind="lose"], .match-banner[data-kind="draw"] { top: 18%; }

/* Player HP bar above snowball stock HUD */
.hp-hud {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  background: rgba(8, 21, 41, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(4px);
}
.hp-hud[hidden] { display: none; }
.hp-lbl {
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #e2f5ff;
}
.hp-bar {
  width: 28px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #43e97b, #38f9d7);
  transition: width 0.14s ease, background 0.18s ease;
}
.hp-fill.mid { background: linear-gradient(90deg, #ffca28, #ff9800); }
.hp-fill.low { background: linear-gradient(90deg, #ff5252, #d50000); }

/* Stationary Kick mode accent on the Slide/Kick button */
.jump-btn.mode-kick {
  border-color: rgba(255, 213, 79, 0.85);
  background: linear-gradient(160deg, rgba(255, 167, 38, 0.88), rgba(230, 81, 0, 0.88));
}

/* Fit doubled 10-snowball stock dots cleanly inside the pill */
.ammo-dots {
  flex-wrap: wrap;
  justify-content: center;
  max-width: 108px;
  gap: 0.22rem;
}
.ammo-dot {
  width: 9px;
  height: 9px;
}

/* Festive startup loading screen (visible from t=0ms until first 3D frame paints!) */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 38%, #1d4e78 0%, #0d2542 62%, #071528 100%);
  transition: opacity 0.28s ease;
}
.loading-overlay.done {
  opacity: 0;
  pointer-events: none;
}
.loading-overlay[hidden] { display: none; }
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 2rem;
  text-align: center;
}
.loading-flake {
  font-size: 2.6rem;
  animation: loadSpin 2.4s linear infinite;
  filter: drop-shadow(0 0 14px rgba(130, 220, 255, 0.75));
}
@keyframes loadSpin {
  from { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.1); }
  to   { transform: rotate(360deg) scale(1); }
}
.loading-logo {
  width: min(360px, 78vw);
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.5));
  animation: logoFloat 2.8s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Landing Title Screen (shown before Character Select, over live attract-mode battle!) */
.landing-overlay {
  background: radial-gradient(circle at 50% 44%, rgba(8, 22, 44, 0.04) 0%, rgba(7, 18, 36, 0.34) 100%);
}
.landing-stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(2.6rem, 8vh, 5.2rem) 1.2rem clamp(2.4rem, 7vh, 4.4rem);
  pointer-events: none;
}
.landing-logo-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}
.landing-logo {
  width: min(560px, 88vw);
  max-height: 36vh;
  object-fit: contain;
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
  animation: logoFloat 3.2s ease-in-out infinite;
}
.landing-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
}
.start-btn {
  min-width: min(260px, 72vw);
  padding: 0.95rem 2.4rem;
  font-size: clamp(1.15rem, 3.2vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0.10em;
  border-radius: 999px;
  border: 2.5px solid rgba(255, 224, 130, 0.92);
  background: linear-gradient(180deg, #ff5252 0%, #d50000 100%);
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  box-shadow: 0 10px 28px rgba(213, 0, 0, 0.50), 0 0 22px rgba(255, 213, 79, 0.38);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  animation: startPulse 2.1s ease-in-out infinite;
}
.start-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 34px rgba(213, 0, 0, 0.62), 0 0 28px rgba(255, 213, 79, 0.55);
}
.start-btn:active {
  transform: scale(0.97);
}
@keyframes startPulse {
  0%, 100% { box-shadow: 0 10px 28px rgba(213, 0, 0, 0.48), 0 0 18px rgba(255, 213, 79, 0.32); }
  50%      { box-shadow: 0 12px 34px rgba(213, 0, 0, 0.62), 0 0 32px rgba(255, 213, 79, 0.62); }
}

.pill.timer.overtime {
  background: linear-gradient(135deg, rgba(16, 33, 72, 0.92), rgba(40, 62, 128, 0.92));
  border-color: rgba(255, 220, 110, 0.92);
  color: #ffe88a;
  box-shadow: 0 0 14px rgba(255, 210, 90, 0.45);
}

/* Contribution Ranking rows inside Result Card */
.rank-heading {
  margin: 0.08rem 0 0.14rem;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffe082;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.18rem 0.42rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.72rem;
}
.rank-row.is-mvp {
  background: linear-gradient(90deg, rgba(255, 202, 40, 0.22), rgba(255, 167, 38, 0.12));
  border-color: rgba(255, 213, 79, 0.65);
}
.rank-row.is-me {
  box-shadow: inset 0 0 0 1.5px rgba(128, 229, 255, 0.85);
}
.rank-pos {
  width: 1.55rem;
  text-align: center;
  font-weight: 900;
  color: #ffffff;
}
.rank-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
}
.rank-face {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 2px solid #ffffff;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Gingerbread Cookie Collector Bar right below the top scoreboard */
.cookie-bar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 54px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(16, 30, 54, 0.72);
  border: 1.5px solid rgba(255, 213, 128, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.cookie-bar[hidden] { display: none; }
.cookie-slots {
  display: flex;
  align-items: center;
  gap: 0.18rem;
}
.cookie-slot {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.10);
  border: 1px dashed rgba(255, 224, 150, 0.35);
  opacity: 0.45;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.cookie-slot.filled {
  opacity: 1;
  background: rgba(255, 196, 86, 0.26);
  border: 1px solid rgba(255, 218, 120, 0.9);
  transform: scale(1.1);
  filter: drop-shadow(0 0 5px rgba(255, 200, 80, 0.65));
}
.cookie-count {
  font-size: 0.74rem;
  font-weight: 900;
  color: #ffe4a0;
  min-width: 2.3rem;
  text-align: right;
}

/* Mobile Portrait / Narrow Viewport: stack Scoreboard -> Cookie Bar -> Minimap & HUD buttons with ZERO overlap! */
@media (max-width: 760px) {
  .cookie-bar {
    top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + 46px);
    padding: 0.16rem 0.48rem;
    gap: 0.28rem;
    max-width: calc(100vw - 16px);
  }
  .cookie-slots {
    gap: 0.12rem;
  }
  .cookie-slot {
    width: 16px;
    height: 16px;
    font-size: 0.72rem;
  }
  .cookie-count {
    font-size: 0.70rem;
    min-width: 2.0rem;
  }
  .hud-actions {
    margin-top: 28px;
  }
  .minimap {
    top: calc(var(--hud-top, max(8px, env(safe-area-inset-top, 0px))) + var(--hud-row, 54px) + 28px);
    width: 82px;
    height: 82px;
  }
}
.rank-info {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.rank-name {
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-stats {
  font-size: 0.70rem;
  color: rgba(226, 244, 255, 0.82);
  letter-spacing: 0.02em;
}
.rank-pts {
  font-weight: 900;
  color: #ffe082;
  white-space: nowrap;
}

.loading-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}
.loading-bar {
  width: min(240px, 68vw);
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(180, 232, 255, 0.38);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.loading-fill {
  height: 100%;
  width: 24%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4fc3f7, #ffffff, #ffd54f);
  transition: width 0.22s ease;
}
.loading-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #cdeaff;
  letter-spacing: 0.04em;
}

/* FPS Center Crosshair Dot & Sniper Scope Overlay */
.fps-dot {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid rgba(10, 24, 42, 0.92);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.65), 0 0 8px rgba(0, 190, 255, 0.85);
  pointer-events: none;
  z-index: 30;
}
.fps-dot[hidden] { display: none; }

.fps-scope {
  position: fixed;
  inset: 0;
  z-index: 17;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, transparent 32vmin, rgba(5, 12, 24, 0.72) 41vmin, rgba(3, 8, 16, 0.95) 54vmin);
}
.fps-scope[hidden] { display: none; }
.fps-scope-svg {
  width: min(86vmin, 520px);
  height: min(86vmin, 520px);
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.85));
}

/* Playgama Platform Pause Veil (visible on every screen when platform pauses or shows ad) */
.platform-pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 16, 36, 0.76);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.platform-pause-overlay[hidden] { display: none; }
.platform-pause-box {
  text-align: center;
  padding: 1.4rem 2.4rem;
  border-radius: 18px;
  background: rgba(14, 42, 38, 0.92);
  border: 2px solid rgba(244, 206, 118, 0.88);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}
.platform-pause-title {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #ffe69a;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.platform-pause-hint {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #d8f0ff;
}

/* Cute Bouncy "Poyoyon" Event Banners (GOAL!, REINDEER!, MATCH COMPLETE!) */
.event-banner {
  position: fixed;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  z-index: 46;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.event-banner[hidden] { display: none; }
.event-banner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transform-origin: 50% 60%;
  will-change: transform, opacity;
}
.event-banner-img {
  display: block;
  height: auto;
  width: min(86vw, 480px);
  max-height: 34vh;
  object-fit: contain;
  filter: drop-shadow(0 12px 22px rgba(8, 24, 16, 0.5))
          drop-shadow(0 2px 6px rgba(255, 255, 255, 0.24));
}
.event-banner[data-kind="reindeer"] {
  top: 45%;
}
.event-banner[data-kind="reindeer"] .event-banner-img {
  width: min(88vw, 500px);
  max-height: 40vh;
}
.event-banner[data-kind="match_complete"] {
  top: 46%;
}
.event-banner[data-kind="match_complete"] .event-banner-img {
  width: min(94vw, 600px);
  max-height: 32vh;
}
.event-banner-sub {
  margin-top: -0.15rem;
  font-size: clamp(1.35rem, 5.2vw, 2.05rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: #fff7d6;
  -webkit-text-stroke: 4px rgba(10, 32, 18, 0.96);
  paint-order: stroke fill;
  text-shadow: 0 5px 14px rgba(6, 20, 12, 0.85), 0 0 18px rgba(0, 0, 0, 0.45);
}
.event-banner-sub[hidden] { display: none; }
.event-banner-sub.red { color: #ff6e66; }
.event-banner-sub.green { color: #7ef7a8; }

.event-banner.is-in .event-banner-inner {
  animation: poyoyonIn 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.event-banner.is-idle .event-banner-inner {
  animation: poyoyonIdle 1.05s ease-in-out infinite;
}
.event-banner.is-out .event-banner-inner {
  animation: poyoyonOut 0.38s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

@keyframes poyoyonIn {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.22, 0.22) rotate(-5deg);
  }
  12% {
    opacity: 1;
  }
  30% {
    opacity: 1;
    transform: translateY(-12px) scale(1.24, 0.76) rotate(2.6deg);
  }
  52% {
    opacity: 1;
    transform: translateY(5px) scale(0.84, 1.18) rotate(-2deg);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.09, 0.92) rotate(1.1deg);
  }
  85% {
    opacity: 1;
    transform: translateY(1px) scale(0.96, 1.04) rotate(-0.5deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
}

@keyframes poyoyonIdle {
  0%, 100% {
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
  25% {
    transform: translateY(-4px) scale(1.04, 0.96) rotate(-1.2deg);
  }
  50% {
    transform: translateY(1px) scale(0.97, 1.035) rotate(0deg);
  }
  75% {
    transform: translateY(-3px) scale(1.035, 0.965) rotate(1.2deg);
  }
}

@keyframes poyoyonOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1, 1) rotate(0deg);
  }
  34% {
    opacity: 1;
    transform: translateY(8px) scale(1.18, 0.8) rotate(2.4deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-38px) scale(0.2, 1.38) rotate(-6deg);
  }
}
