html {
  background: #020617;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  --ambient-edge: #0c4a6e;
  --ambient-mid: #111827;
  --ambient-glow: rgba(14,165,233,0.46);
  --ambient-stripe: rgba(255,255,255,0.08);
  background-color: #020617;
  background-image:
    repeating-linear-gradient(135deg, var(--ambient-stripe) 0 10px, transparent 10px 30px),
    radial-gradient(circle at 0% 50%, var(--ambient-glow), transparent 34%),
    radial-gradient(circle at 100% 50%, var(--ambient-glow), transparent 34%),
    linear-gradient(90deg, var(--ambient-edge) 0%, var(--ambient-mid) 23%, var(--ambient-mid) 77%, var(--ambient-edge) 100%);
  background-attachment: fixed;
  background-size: 72px 72px, 100% 100%, 100% 100%, 100% 100%;
  color: white;
  font-family: Arial, sans-serif;
  user-select: none;
}

body.ambient-dodge {
  --ambient-edge: #0c4a6e;
  --ambient-mid: #111827;
  --ambient-glow: rgba(14,165,233,0.5);
  --ambient-stripe: rgba(244,63,94,0.14);
}

body.ambient-tower {
  --ambient-edge: #7f1d1d;
  --ambient-mid: #101820;
  --ambient-glow: rgba(239,68,68,0.5);
  --ambient-stripe: rgba(125,211,252,0.14);
}

body.ambient-pingpong {
  --ambient-edge: #0f766e;
  --ambient-mid: #141719;
  --ambient-glow: rgba(45,212,191,0.5);
  --ambient-stripe: rgba(250,204,21,0.15);
}

body.ambient-snake {
  --ambient-edge: #14532d;
  --ambient-mid: #131811;
  --ambient-glow: rgba(34,197,94,0.46);
  --ambient-stripe: rgba(244,63,94,0.14);
}

body.ambient-crumble {
  --ambient-edge: #78350f;
  --ambient-mid: #181512;
  --ambient-glow: rgba(217,119,6,0.54);
  --ambient-stripe: rgba(251,191,36,0.18);
}

body.ambient-bumper {
  --ambient-edge: #075985;
  --ambient-mid: #082f49;
  --ambient-glow: rgba(125,211,252,0.48);
  --ambient-stripe: rgba(132,204,22,0.16);
}

body.ambient-space {
  --ambient-edge: #1e1b4b;
  --ambient-mid: #050816;
  --ambient-glow: rgba(79,70,229,0.5);
  --ambient-stripe: rgba(125,211,252,0.16);
}

body.ambient-flappy,
body.ambient-side {
  --ambient-edge: #0369a1;
  --ambient-mid: #0f3150;
  --ambient-glow: rgba(56,189,248,0.5);
  --ambient-stripe: rgba(34,197,94,0.16);
}

body.ambient-bomber {
  --ambient-edge: #334155;
  --ambient-mid: #111827;
  --ambient-glow: rgba(100,116,139,0.48);
  --ambient-stripe: rgba(249,115,22,0.17);
}

body.ambient-canons {
  --ambient-edge: #334155;
  --ambient-mid: #18212b;
  --ambient-glow: rgba(100,116,139,0.5);
  --ambient-stripe: rgba(245,158,11,0.18);
}

body.ambient-maze {
  --ambient-edge: #042f2e;
  --ambient-mid: #01030a;
  --ambient-glow: rgba(20,184,166,0.46);
  --ambient-stripe: rgba(167,139,250,0.16);
}

body.ambient-battletris {
  --ambient-edge: #0f172a;
  --ambient-mid: #111827;
  --ambient-glow: rgba(34,197,94,0.34);
  --ambient-stripe: rgba(56,189,248,0.14);
}

body.ambient-miner {
  --ambient-edge: #451a03;
  --ambient-mid: #111827;
  --ambient-glow: rgba(146,64,14,0.52);
  --ambient-stripe: rgba(250,204,21,0.18);
}

body.ambient-remember {
  --ambient-edge: #1e293b;
  --ambient-mid: #0f172a;
  --ambient-glow: rgba(250,204,21,0.32);
  --ambient-stripe: rgba(56,189,248,0.12);
}

#viewport {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 900px;
  overflow: hidden;
  background-color: #171717;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
  border: 2px solid rgba(255,255,255,0.25);
  box-sizing: border-box;
  transform-origin: 0 0;
  will-change: transform;
}

#viewport.tower {
  background-color: #101820;
  background-image:
    linear-gradient(rgba(125,211,252,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,211,252,0.08) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
}

#viewport.tower::before,
#viewport.tower::after {
  content: '';
  position: absolute;
  top: 0;
  width: 28px;
  height: 100%;
  background: linear-gradient(90deg, #7f1d1d, #ef4444 45%, rgba(239,68,68,0.26));
  box-shadow: 0 0 18px rgba(239,68,68,0.55);
  pointer-events: none;
  z-index: 30;
}

#viewport.tower::before {
  left: 0;
}

#viewport.tower::after {
  right: 0;
  transform: scaleX(-1);
}

#viewport.pingpong {
  background-color: #141719;
  background-image:
    linear-gradient(rgba(45,212,191,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45,212,191,0.07) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
}

#viewport.snake {
  background-color: #131811;
  background-image:
    linear-gradient(rgba(74,222,128,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,222,128,0.07) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  background-position: 8px 6px, 8px 6px, 8px 6px, 8px 6px;
}

#viewport.crumble {
  background-color: #181512;
  background-image:
    linear-gradient(rgba(251,191,36,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(251,191,36,0.06) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
}

#viewport.bumper {
  background-color: #082f49;
  background-image:
    radial-gradient(circle at 42% 38%, rgba(125,211,252,0.18), transparent 0 28%, rgba(14,116,144,0.18) 29%, transparent 56%),
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 900px 900px, 80px 80px, 80px 80px;
}

#viewport.space {
  background-color: #050816;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 62% 40%, rgba(125,211,252,0.6) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 74%, rgba(255,255,255,0.5) 0 1px, transparent 2px),
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 260px 260px, 330px 330px, 410px 410px, 80px 80px, 80px 80px;
}

#viewport.flappy {
  background-color: #7dd3fc;
  background-image:
    linear-gradient(rgba(255,255,255,0.22) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,0.12) 2px, transparent 2px),
    linear-gradient(#38bdf8, #bae6fd 64%, #86efac 65%, #22c55e);
  background-size: 120px 120px, 120px 120px, 100% 100%;
}

#viewport.side {
  background-color: #67e8f9;
  background-image:
    linear-gradient(rgba(255,255,255,0.22) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 2px, transparent 2px),
    linear-gradient(#38bdf8, #a5f3fc 58%, #86efac 59%, #22c55e 75%, #15803d);
  background-size: 120px 120px, 120px 120px, 100% 100%;
}

#viewport.bomber {
  background-color: #172033;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 2px, transparent 2px),
    linear-gradient(#1f2937, #111827);
  background-size: 56px 56px, 56px 56px, 100% 100%;
}

#viewport.canons {
  background-color: #18212b;
  background-image:
    linear-gradient(rgba(255,255,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(#1e293b 0 58%, #475569 59% 72%, #334155 73% 100%);
  background-size: 80px 80px, 80px 80px, 100% 100%;
}

#viewport.maze {
  background-color: #01030a;
  background-image: none;
}

#viewport.battletris {
  background:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(180deg, #0f172a, #111827 45%, #0b1120);
  background-size: 32px 32px, 32px 32px, 100% 100%;
}

.mazeDarkness {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 24;
}

#viewport.miner {
  background-color: #111827;
  background-image:
    linear-gradient(rgba(251,191,36,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(251,191,36,0.05) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px, 230px 230px, 230px 230px;
  background-position:
    var(--miner-grid-x, 0px) var(--miner-grid-y, 0px),
    var(--miner-grid-x, 0px) var(--miner-grid-y, 0px),
    var(--miner-grid-x, 0px) var(--miner-grid-y, 0px),
    var(--miner-grid-x, 0px) var(--miner-grid-y, 0px);
}

#viewport.remember {
  background:
    radial-gradient(circle at 50% 50%, rgba(15,23,42,0.62), rgba(2,6,23,0.94)),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 100% 100%, 80px 80px, 80px 80px;
}

.minerCell {
  appearance: none;
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  background: linear-gradient(180deg, #475569, #1e293b);
  color: #e5e7eb;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  box-sizing: border-box;
  cursor: pointer;
  z-index: 10;
}

.minerCell.revealed {
  cursor: default;
  background: linear-gradient(180deg, #d1d5db, #9ca3af);
  color: #111827;
}

.minerCell.minerMine {
  background: #991b1b;
  color: #fff;
  box-shadow: 0 0 14px rgba(220,38,38,0.58);
}

.minerBombIcon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #f8fafc 0 10%, #111827 11% 100%);
  box-shadow: 0 0 10px rgba(15,23,42,0.65);
  box-sizing: border-box;
}

.minerBombIcon::after {
  content: '';
  position: absolute;
  left: 13px;
  top: -5px;
  width: 9px;
  height: 3px;
  border-radius: 999px;
  background: #facc15;
  box-shadow: 0 0 6px rgba(250,204,21,0.75);
  transform: rotate(-34deg);
  transform-origin: left center;
}

.minerCell.disabled {
  cursor: default;
}

.bumperIsland {
  position: absolute;
  border: 8px solid rgba(254,243,199,0.95);
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 36%, rgba(255,255,255,0.22), transparent 0 28%),
    radial-gradient(circle, #65a30d 0 48%, #3f6212 49% 66%, #92400e 67% 100%);
  box-shadow:
    inset 0 -18px 36px rgba(0,0,0,0.24),
    0 0 34px rgba(125,211,252,0.32);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 4;
}

.player.bumperPlayer {
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  border-width: 3px;
  box-shadow:
    inset -6px -7px 0 rgba(0,0,0,0.18),
    0 0 16px rgba(255,255,255,0.32);
}

.player.spacePlayer {
  width: 0;
  height: 0;
  margin-left: -14px;
  margin-top: -14px;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 28px solid #38bdf8;
  border-top: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: 0 0 16px rgba(56,189,248,0.48);
  transform-origin: 14px 14px;
  --player-angle: calc(var(--ship-angle, 0rad) + 1.5708rad);
}

.player.spacePlayer.self {
  border-bottom-color: #facc15;
}

.player.flappyPlayer {
  width: 28px;
  height: 22px;
  margin-left: -14px;
  margin-top: -11px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 60% 45% 55% 45%;
  background: #facc15;
  box-shadow: inset -5px -4px 0 rgba(0,0,0,0.12), 0 0 12px rgba(250,204,21,0.4);
}

.player.flappyPlayer::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 7px;
  border-left: 9px solid #f97316;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.player.flappyPlayer::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 3px 0 0 #111;
}

.player.canonsPlayer {
  width: 34px;
  height: 24px;
  margin-left: -17px;
  margin-top: -15px;
  border: 2px solid rgba(255,255,255,0.92);
  border-radius: 8px 8px 13px 13px;
  background:
    linear-gradient(90deg, rgba(250,204,21,0.92) 0 var(--cannon-charge, 0%), transparent var(--cannon-charge, 0%) 100%),
    linear-gradient(180deg, #94a3b8, #334155 58%, #111827);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.22), 0 0 14px rgba(148,163,184,0.45);
}

.player.canonsPlayer.self {
  background:
    linear-gradient(90deg, rgba(250,204,21,0.95) 0 var(--cannon-charge, 0%), transparent var(--cannon-charge, 0%) 100%),
    linear-gradient(180deg, #bae6fd, #0284c7 58%, #0c4a6e);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2), 0 0 18px rgba(56,189,248,0.62);
}

.player.canonsPlayer.charging {
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2), 0 0 22px rgba(250,204,21,0.72);
}

.player.canonsPlayer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 7px;
  width: 40px;
  height: 8px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 999px;
  background: linear-gradient(180deg, #64748b, #111827);
  box-shadow: 0 0 8px rgba(15,23,42,0.5);
  transform-origin: 0 50%;
  transform: rotate(var(--cannon-angle, -0.785rad));
}

.player.canonsPlayer::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: -6px;
  height: 8px;
  border-radius: 999px;
  background: #0f172a;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18);
}

.spaceAsteroid {
  position: absolute;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.28), transparent 0 18%),
    radial-gradient(circle, #78716c, #44403c 62%, #1c1917);
  border: 2px solid rgba(255,255,255,0.24);
  box-shadow: inset -8px -10px 0 rgba(0,0,0,0.2), 0 0 14px rgba(120,113,108,0.28);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 7;
}

.spaceBullet {
  position: absolute;
  border-radius: 50%;
  background: #fef08a;
  box-shadow: 0 0 14px rgba(250,204,21,0.85);
  pointer-events: none;
  z-index: 18;
}

.pingpongLine {
  position: absolute;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.28);
  box-shadow: 0 0 12px rgba(45,212,191,0.35);
  pointer-events: none;
  transform-origin: 0 50%;
  z-index: 7;
}

.pingpongLine.defended {
  background: rgba(45,212,191,0.5);
}

.pingpongPaddle {
  position: absolute;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2dd4bf, #e0f2fe);
  box-shadow: 0 0 18px rgba(45,212,191,0.62);
  pointer-events: none;
  transform-origin: 0 50%;
  z-index: 18;
}

.pingpongPaddle.dead {
  opacity: 0.28;
  filter: grayscale(1);
}

.pingpongBall {
  position: absolute;
  left: 0;
  top: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #facc15;
  box-shadow: 0 0 16px rgba(250,204,21,0.75);
  box-sizing: border-box;
  pointer-events: none;
  transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0);
  will-change: transform;
  z-index: 19;
}

.snakeSegment {
  position: absolute;
  border: 2px solid rgba(255,255,255,0.36);
  border-radius: 6px;
  background: #22c55e;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.12);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 12;
}

.snakeSegment.head {
  border-color: rgba(255,255,255,0.9);
  box-shadow: 0 0 14px rgba(34,197,94,0.6);
  z-index: 14;
}

.snakeSegment.dead {
  opacity: 0.24;
  filter: grayscale(1);
}

.snakeFood {
  position: absolute;
  border: 2px solid rgba(255,255,255,0.82);
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 16px rgba(244,63,94,0.72);
  box-sizing: border-box;
  pointer-events: none;
  animation: snakeFoodSpawn 520ms cubic-bezier(0.18, 1.55, 0.28, 1) both;
  z-index: 13;
}

.snakeFood::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(244,63,94,0.75);
  border-radius: 50%;
  pointer-events: none;
  animation: spawnRing 520ms ease-out both;
}

@keyframes snakeFoodSpawn {
  0% {
    opacity: 0;
    transform: scale(0.08) rotate(-18deg);
    box-shadow: 0 0 4px rgba(244,63,94,0.2);
  }
  48% {
    opacity: 1;
    transform: scale(1.45) rotate(8deg);
    box-shadow: 0 0 28px rgba(244,63,94,0.95);
  }
  72% {
    transform: scale(0.9) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spawnRing {
  0% {
    opacity: 0.95;
    transform: scale(0.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

.player {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  background: #ef4444;
  border: 2px solid white;
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
  transform: translate3d(var(--player-x, 0px), var(--player-y, 0px), 0) rotate(var(--player-angle, 0rad));
  will-change: transform;
  z-index: 20;
}

.player.self {
  background: #38bdf8;
}

.player.dead {
  opacity: 0.25;
  filter: grayscale(1);
}

.player.battletrisPlayer {
  display: none;
}

.player.rememberPlayer {
  display: none;
}

.deathMarker {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,0.82);
  border-radius: 50%;
  background: rgba(15,23,42,0.86);
  color: #f8fafc;
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 0 14px rgba(248,250,252,0.28);
  pointer-events: none;
  transform: translate3d(var(--death-x, 0px), var(--death-y, 0px), 0);
  z-index: 19;
}

.deathMarker.fading {
  animation: deathMarkerFade 5.5s ease-out forwards;
}

@keyframes deathMarkerFade {
  0% {
    opacity: 1;
    transform: translate3d(var(--death-x, 0px), var(--death-y, 0px), 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--death-x, 0px), var(--death-y, 0px), 0) scale(0.74);
  }
}

.player.shielded {
  box-shadow: 0 0 0 8px rgba(34,211,238,0.24), 0 0 22px rgba(34,211,238,0.85);
}

.player.towerPlayer {
  border-radius: 6px 6px 50% 50%;
  box-shadow: 0 0 18px rgba(56,189,248,0.45);
}

.playerName {
  position: absolute;
  left: 14px;
  top: 12px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.75);
  border-radius: 4px;
  color: white;
  font-size: 12px;
  white-space: nowrap;
}

.obstacle {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 14px rgba(249,115,22,0.45);
  pointer-events: none;
  transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0);
  will-change: transform;
  z-index: 10;
}

.obstacle.sideEnemy {
  border-radius: 45% 45% 38% 38%;
  background: linear-gradient(180deg, #a16207, #7c2d12);
  box-shadow: inset -5px -6px 0 rgba(0,0,0,0.18), 0 0 10px rgba(124,45,18,0.4);
}

.obstacle.sideEnemy::before,
.obstacle.sideEnemy::after {
  content: '';
  position: absolute;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
}

.obstacle.sideEnemy::before {
  left: 8px;
}

.obstacle.sideEnemy::after {
  right: 8px;
}

.obstacle.canonBall {
  border: 2px solid rgba(255,255,255,0.72);
  background: radial-gradient(circle at 32% 28%, #e5e7eb, #334155 48%, #020617);
  box-shadow: 0 0 12px rgba(148,163,184,0.55), inset -3px -4px 0 rgba(0,0,0,0.24);
  box-sizing: border-box;
  z-index: 19;
}

.obstacle.mazeTrap {
  border-radius: 3px 3px 0 0;
  background:
    linear-gradient(135deg, transparent 0 42%, #fecaca 43% 55%, transparent 56%) 0 0 / 18px 100%,
    linear-gradient(180deg, #fb7185, #991b1b);
  box-shadow: 0 0 10px rgba(248,113,113,0.76), 0 0 22px rgba(220,38,38,0.45);
  z-index: 25;
}

.platform {
  position: absolute;
  left: 0;
  top: 0;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.78);
  border-radius: 8px;
  background: linear-gradient(180deg, #e0f2fe, #38bdf8 48%, #0369a1);
  box-shadow: 0 0 16px rgba(56,189,248,0.42);
  box-sizing: border-box;
  pointer-events: none;
  transform: translate3d(var(--smooth-x, 0px), calc(var(--smooth-y, 0px) + var(--platform-offset-y, 0px)), 0);
  will-change: transform;
  z-index: 8;
}

.platform::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 3px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
}

.platform.start {
  background: linear-gradient(180deg, #f0fdfa, #2dd4bf 48%, #0f766e);
  box-shadow: 0 0 18px rgba(45,212,191,0.48);
}

.platform.side {
  background: linear-gradient(180deg, #f8fafc, #93c5fd 48%, #1d4ed8);
  box-shadow: 0 0 14px rgba(147,197,253,0.32);
}

.platform.crumble {
  border-color: rgba(255,255,255,0.62);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24) 0 20%, transparent 21% 100%),
    linear-gradient(180deg, #fde68a 0 18%, #d97706 19% 72%, #78350f 73% 100%);
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.28), 0 0 13px rgba(217,119,6,0.36);
}

.platform.crumble::before {
  left: 7px;
  right: 7px;
  top: 7px;
  height: 3px;
  background: rgba(255,255,255,0.38);
}

.platform.crumble.start {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.32) 0 22%, transparent 23% 100%),
    linear-gradient(180deg, #fef3c7 0 18%, #f59e0b 19% 72%, #92400e 73% 100%);
}

.platform.crumble.warning1 {
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.28), 0 0 14px rgba(250,204,21,0.48);
}

.platform.crumble.warning2 {
  --platform-offset-y: 2px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24) 0 20%, transparent 21% 100%),
    linear-gradient(180deg, #fcd34d 0 18%, #b45309 19% 72%, #78350f 73% 100%);
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.32), 0 0 18px rgba(250,204,21,0.62);
}

.platform.crumble.warning3 {
  --platform-offset-y: 4px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.18) 0 18%, transparent 19% 100%),
    linear-gradient(180deg, #fbbf24 0 18%, #92400e 19% 72%, #451a03 73% 100%);
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.36), 0 0 22px rgba(239,68,68,0.62);
}

.platform.crumble.falling {
  opacity: 0.92;
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.34), 0 0 12px rgba(217,119,6,0.28);
}

.platform.flappy {
  border: 3px solid rgba(255,255,255,0.72);
  border-radius: 8px;
  background: linear-gradient(90deg, #15803d, #22c55e 48%, #166534);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,0.12), 0 0 12px rgba(22,101,52,0.35);
}

.platform.flappy::before {
  left: -5px;
  right: -5px;
  top: auto;
  bottom: -3px;
  height: 18px;
  border-radius: 6px;
  background: #16a34a;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.18);
}

.platform.flappy.top::before {
  top: -3px;
  bottom: auto;
}

.platform.sideGround,
.platform.sideBlock {
  border-color: rgba(255,255,255,0.72);
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(120,53,15,0.22) 1px, transparent 1px),
    linear-gradient(180deg, #facc15 0 25%, #b45309 26% 100%);
  background-size: 34px 100%, 100% 100%;
  box-shadow: inset 0 -5px 0 rgba(69,26,3,0.28), 0 0 12px rgba(180,83,9,0.3);
}

.platform.sideGround::before,
.platform.sideBlock::before {
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #bbf7d0, #22c55e);
}

.platform.sideBlock {
  background:
    linear-gradient(90deg, rgba(69,26,3,0.22) 1px, transparent 1px),
    linear-gradient(180deg, #fed7aa, #f97316 48%, #9a3412);
  background-size: 28px 100%, 100% 100%;
}

.platform.sideBlock::before {
  display: none;
}

.platform.bomberWall,
.platform.bomberBlock {
  border-radius: 4px;
  border-color: rgba(255,255,255,0.18);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.06), 0 0 10px rgba(0,0,0,0.24);
}

.platform.bomberWall {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.12) 0 18%, transparent 19% 100%),
    linear-gradient(180deg, #64748b, #334155);
}

.platform.bomberWall::before {
  display: none;
}

.platform.bomberBlock {
  background:
    linear-gradient(90deg, rgba(69,26,3,0.38) 2px, transparent 2px),
    linear-gradient(180deg, #b45309, #78350f);
  background-size: 18px 100%, 100% 100%;
}

.platform.bomberBlock::before {
  left: 5px;
  right: 5px;
  top: 7px;
  height: 4px;
  background: rgba(255,255,255,0.22);
}

.platform.bomberBlast {
  border: 0;
  border-radius: 8px;
  background:
    radial-gradient(circle, rgba(255,255,255,0.96) 0 16%, rgba(250,204,21,0.88) 17% 42%, rgba(239,68,68,0.72) 43% 100%);
  box-shadow: 0 0 22px rgba(249,115,22,0.78);
  opacity: 0.9;
  z-index: 19;
}

.platform.bomberBlast::before {
  display: none;
}

.platform.canonsGround {
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(15,23,42,0.18) 1px, transparent 1px),
    linear-gradient(180deg, #64748b 0 14%, #334155 15% 100%);
  background-size: 42px 100%, 100% 100%;
  box-shadow: inset 0 8px 0 rgba(255,255,255,0.08);
  clip-path: polygon(0 var(--terrain-y1, 0px), 100% var(--terrain-y2, 0px), 100% 100%, 0 100%);
}

.platform.canonsGround::before {
  left: 0;
  right: 0;
  top: 0;
  height: 10px;
  border-radius: 0;
  background: linear-gradient(180deg, #94a3b8, #475569);
}

.platform.mazeFloor,
.platform.mazeStep,
.platform.mazeGoalBase,
.platform.mazeCeiling,
.platform.mazeWall,
.platform.mazeBlock {
  border-color: rgba(148,163,184,0.52);
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(15,23,42,0.42) 1px, transparent 1px),
    linear-gradient(180deg, #64748b 0 18%, #1f2937 19% 100%);
  background-size: 28px 100%, 100% 100%;
  box-shadow: inset 0 -5px 0 rgba(2,6,23,0.38), 0 0 12px rgba(148,163,184,0.2);
}

.platform.mazeStep {
  background:
    linear-gradient(90deg, rgba(15,23,42,0.32) 1px, transparent 1px),
    linear-gradient(180deg, #94a3b8 0 18%, #334155 19% 100%);
  background-size: 22px 100%, 100% 100%;
}

.platform.mazeWall,
.platform.mazeCeiling {
  background:
    linear-gradient(90deg, rgba(148,163,184,0.13) 1px, transparent 1px),
    linear-gradient(180deg, #334155, #0f172a);
  background-size: 18px 100%, 100% 100%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.04), 0 0 10px rgba(2,6,23,0.42);
}

.platform.mazeBlock {
  border-color: rgba(148,163,184,0.42);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08) 0 18%, transparent 19% 100%),
    linear-gradient(180deg, #475569, #111827);
  box-shadow: inset 0 -5px 0 rgba(2,6,23,0.42);
}

.platform.mazeStart {
  border-color: rgba(250,204,21,0.78);
}

.platform.mazeGoal {
  border: 2px solid rgba(255,255,255,0.92);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 18%, #fef08a 0 12%, transparent 13%),
    linear-gradient(90deg, #22c55e 0 46%, #f8fafc 47% 54%, #ef4444 55% 100%);
  box-shadow: 0 0 28px rgba(34,197,94,0.78);
  z-index: 14;
}

.platform.mazeGoal::before {
  left: 20px;
  right: auto;
  top: -42px;
  width: 4px;
  height: 42px;
  border-radius: 999px;
  background: #f8fafc;
}

.mine {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border: 2px solid #facc15;
  border-radius: 50%;
  background: #422006;
  box-shadow: 0 0 12px rgba(250,204,21,0.45);
  pointer-events: none;
  z-index: 12;
}

.explosion {
  position: absolute;
  border: 2px solid rgba(250,204,21,0.8);
  border-radius: 50%;
  background: rgba(249,115,22,0.22);
  box-shadow: 0 0 24px rgba(249,115,22,0.5);
  pointer-events: none;
  z-index: 18;
  transform-origin: center;
  animation: mineExplosion 650ms ease-out forwards;
}

.explosion::before,
.explosion::after {
  content: '';
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  pointer-events: none;
}

.explosion::before {
  border: 2px solid rgba(255,255,255,0.75);
  animation: mineShockwave 650ms ease-out forwards;
}

.explosion::after {
  background:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 8%, transparent 9%),
    radial-gradient(circle, rgba(253,186,116,0.85) 0 26%, transparent 27%);
  animation: mineFlash 420ms ease-out forwards;
}

@keyframes mineExplosion {
  0% {
    opacity: 0;
    transform: scale(0.2);
    box-shadow: 0 0 10px rgba(250,204,21,0.9);
  }
  28% {
    opacity: 1;
    transform: scale(1.12);
    box-shadow: 0 0 42px rgba(249,115,22,0.85);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
    box-shadow: 0 0 8px rgba(249,115,22,0);
  }
}

@keyframes mineShockwave {
  0% {
    opacity: 0.95;
    transform: scale(0.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.65);
  }
}

@keyframes mineFlash {
  0% {
    opacity: 1;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(1.15);
  }
}

.powerup {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  border-radius: 6px;
  box-sizing: border-box;
  color: white;
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0);
  will-change: transform;
  animation: itemSpawnGlow 520ms ease-out both;
  z-index: 14;
}

.powerup::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(255,255,255,0.72);
  border-radius: 10px;
  pointer-events: none;
  animation: spawnRing 520ms ease-out both;
}

@keyframes itemSpawnGlow {
  0% {
    opacity: 0;
    filter: brightness(2.4) saturate(1.5);
    transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0) scale(0.25) rotate(-10deg);
  }
  52% {
    opacity: 1;
    filter: brightness(1.9) saturate(1.35);
    transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0) scale(1.32) rotate(7deg);
  }
  100% {
    opacity: 1;
    filter: brightness(1) saturate(1);
    transform: translate3d(var(--smooth-x, 0px), var(--smooth-y, 0px), 0) scale(1) rotate(0deg);
  }
}

.slashIcon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 14px;
  vertical-align: -2px;
}

.slashIcon::before,
.slashIcon::after {
  content: '';
  position: absolute;
  left: 2px;
  width: 15px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  transform-origin: 0 50%;
}

.slashIcon::before {
  top: 2px;
  transform: rotate(28deg);
}

.slashIcon::after {
  top: 8px;
  transform: rotate(-28deg);
}

.powerup.cooldown {
  background: #2563eb;
  box-shadow: 0 0 14px rgba(37,99,235,0.5);
}

.powerup.radius {
  background: #9333ea;
  box-shadow: 0 0 14px rgba(147,51,234,0.5);
}

.powerup.capacity {
  background: #ea580c;
  box-shadow: 0 0 14px rgba(249,115,22,0.58);
}

.powerup.slash {
  background: #dc2626;
  box-shadow: 0 0 14px rgba(220,38,38,0.55);
}

.powerup.shield {
  background: #0891b2;
  box-shadow: 0 0 14px rgba(34,211,238,0.55);
}

.powerup.grow {
  background: #16a34a;
  box-shadow: 0 0 14px rgba(34,197,94,0.58);
}

.powerup.shrink {
  background: #7c3aed;
  box-shadow: 0 0 14px rgba(124,58,237,0.58);
}

.powerup.speed {
  background: #f59e0b;
  box-shadow: 0 0 14px rgba(245,158,11,0.62);
}

.powerup.invert {
  background: #dc2626;
  box-shadow: 0 0 14px rgba(220,38,38,0.62);
}

.powerup.weapon,
.powerup.spread {
  background: #4f46e5;
  box-shadow: 0 0 14px rgba(99,102,241,0.62);
}

.powerup.rapid {
  background: #0d9488;
  box-shadow: 0 0 14px rgba(20,184,166,0.62);
}

.powerup.speed {
  background: #f59e0b;
  box-shadow: 0 0 14px rgba(245,158,11,0.62);
}

.powerup.mushroom {
  border-radius: 50% 50% 9px 9px;
  background: radial-gradient(circle at 34% 32%, #fff 0 12%, transparent 13%),
    radial-gradient(circle at 66% 32%, #fff 0 12%, transparent 13%),
    linear-gradient(180deg, #ef4444 0 56%, #fef3c7 57% 100%);
  color: #7f1d1d;
  box-shadow: 0 0 14px rgba(239,68,68,0.58);
}

.powerup.fireflower {
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff7ed 0 24%, #facc15 25% 44%, transparent 45%),
    conic-gradient(#ef4444, #f97316, #ef4444, #f97316, #ef4444);
  color: #7c2d12;
  box-shadow: 0 0 16px rgba(249,115,22,0.68);
}

.shieldIcon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 18px;
  vertical-align: -4px;
}

.shieldIcon::before {
  content: '';
  position: absolute;
  inset: 1px 2px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 10px 10px;
  background: rgba(34,211,238,0.18);
  box-shadow: 0 0 7px currentColor;
  clip-path: polygon(50% 0, 100% 18%, 88% 72%, 50% 100%, 12% 72%, 0 18%);
}

.slash {
  position: absolute;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff, #ef4444, rgba(255,255,255,0));
  box-shadow: 0 0 18px rgba(239,68,68,0.8);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 22;
  opacity: 0.95;
}

.slash.preview {
  opacity: 0.75;
  animation: none;
}

@keyframes slashFade {
  0% {
    opacity: 1;
    transform: var(--slash-transform) scaleX(0.35);
  }
  38% {
    opacity: 1;
    transform: var(--slash-transform) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: var(--slash-transform) scaleX(1.1);
  }
}

#namePanel {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 22%, rgba(56,189,248,0.18), transparent 34%),
    radial-gradient(circle at 82% 78%, rgba(250,204,21,0.1), transparent 32%),
    rgba(2,6,23,0.52);
  backdrop-filter: blur(2px) saturate(0.8);
  box-sizing: border-box;
  z-index: 90;
}

#namePanel.open {
  display: flex;
}

.nameCard {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 52%),
    rgba(0,0,0,0.78);
  box-shadow: 0 0 38px rgba(14,165,233,0.18);
  box-sizing: border-box;
}

.nameTitle {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.1;
}

.nameText {
  margin: 0 0 14px;
  color: #cbd5e1;
  font-size: 13px;
}

.nameForm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#homeScreen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background:
    radial-gradient(circle at 16% 22%, rgba(56,189,248,0.28), transparent 34%),
    radial-gradient(circle at 84% 76%, rgba(250,204,21,0.18), transparent 32%),
    rgba(2,6,23,0.94);
  z-index: 100;
}

body.homeMode #homeScreen {
  display: flex;
}

body.homeMode #viewport,
body.homeMode #namePanel,
body.homeMode #adminPanel,
body.homeMode #roundInfo,
body.homeMode #powerupInfo,
body.homeMode #controlsPanel,
body.homeMode #muteButton,
body.homeMode #statusOverlay {
  display: none;
}

#homePanel {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(0,0,0,0.74);
  box-shadow: 0 0 42px rgba(14,165,233,0.18);
  box-sizing: border-box;
}

.homeHeader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.homeBrand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.appLogo {
  position: relative;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(56,189,248,0.22), transparent 44%),
    radial-gradient(circle at 72% 24%, rgba(250,204,21,0.42), transparent 18%),
    rgba(15,23,42,0.96);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    0 0 24px rgba(14,165,233,0.24);
  overflow: hidden;
}

.appLogo::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 4px solid #38bdf8;
  border-right-color: #facc15;
  border-bottom-color: #22c55e;
  border-radius: 8px;
  transform: rotate(45deg);
  box-shadow: 0 0 14px rgba(56,189,248,0.5);
}

.appLogo::after {
  content: '';
  position: absolute;
  left: 24px;
  top: 24px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow:
    0 0 12px rgba(244,63,94,0.8),
    -15px 0 0 #38bdf8,
    15px 0 0 #facc15,
    0 -15px 0 #22c55e,
    0 15px 0 #a78bfa;
}

.homeTitle {
  margin: 0 0 2px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.homeTitleAccent {
  color: #38bdf8;
  text-shadow: 0 0 16px rgba(56,189,248,0.48);
}

.homeStats {
  display: grid;
  gap: 3px;
  color: #bae6fd;
  font-weight: bold;
  white-space: nowrap;
  text-align: right;
}

.homeActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

#createRoomButton,
#createPrivacyButton {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  color: white;
  cursor: pointer;
  font-weight: bold;
}

#createRoomButton {
  background: #0ea5e9;
}

#createPrivacyButton {
  background: #334155;
}

#createPrivacyButton.private {
  background: #7f1d1d;
}

#homeRooms {
  display: grid;
  gap: 8px;
}

.homeSectionTitle {
  margin: 16px 0 8px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: bold;
}

.homeRoom {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(15,23,42,0.78);
  color: white;
  text-decoration: none;
}

.homeRoomName {
  font-weight: bold;
}

.homeRoomMeta {
  color: #cbd5e1;
  font-size: 12px;
}

.homeEmpty {
  padding: 14px;
  border: 1px dashed rgba(255,255,255,0.22);
  border-radius: 8px;
  color: #cbd5e1;
  text-align: center;
}

#homeLogs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.homeLogToast {
  position: absolute;
  left: var(--toast-left);
  top: var(--toast-top);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  width: var(--toast-width, min(240px, calc(100vw - 32px)));
  padding: 9px 11px;
  border-left: 3px solid rgba(56,189,248,0.72);
  border-radius: 6px;
  background: rgba(15,23,42,0.88);
  color: #e5e7eb;
  font-size: 12px;
  box-shadow: 0 0 28px rgba(14,165,233,0.18);
  animation: homeLogToastLife 5600ms ease both;
}

.homeLogTime {
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
}

@keyframes homeLogToastLife {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  12% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  76% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-18px) scale(0.98);
  }
}

#adminPanel {
  position: fixed;
  top: 10px;
  right: 10px;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.72);
  border-radius: 8px;
  z-index: 50;
  pointer-events: auto;
}

#adminPanel.visible {
  display: flex;
}

#muteButton {
  position: fixed;
  left: 10px;
  top: 10px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(0,0,0,0.72);
  color: white;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  font-weight: bold;
  z-index: 52;
}

#muteButton.muted {
  color: #fca5a5;
}

#adminPanel label {
  color: #d1d5db;
  font-size: 12px;
  font-weight: bold;
}

#roomPrivacyButton {
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: #334155;
  color: white;
  cursor: pointer;
  font-weight: bold;
}

#roomPrivacyButton.private {
  background: #7f1d1d;
}

#targetScoreInput {
  width: 64px;
  padding: 5px 6px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  background: #111827;
  color: white;
  font-weight: bold;
}

#targetScoreInput::-webkit-inner-spin-button,
#targetScoreInput::-webkit-outer-spin-button {
  opacity: 1;
}

#usernameInput {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  background: #111827;
  color: white;
  font-size: 15px;
  font-weight: bold;
  box-sizing: border-box;
  outline: none;
}

#usernameInput:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.16);
}

#saveUsername {
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  background: #0ea5e9;
  color: white;
  cursor: pointer;
  font-weight: bold;
}

#controlsPanel {
  position: fixed;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  background: rgba(0,0,0,0.72);
  border-radius: 8px;
  z-index: 50;
}

#controlsPanel.tower,
#controlsPanel.pingpong,
#controlsPanel.snake,
#controlsPanel.crumble,
#controlsPanel.bumper,
#controlsPanel.space,
#controlsPanel.side,
#controlsPanel.bomber,
#controlsPanel.canons,
#controlsPanel.maze,
#controlsPanel.battletris {
  gap: 10px;
}

#controlsPanel.remember {
  gap: 10px;
}

#controlsPanel.tower #mineButton,
#controlsPanel.tower #slashButton,
#controlsPanel.tower .dodgeHint,
#controlsPanel.pingpong #mineButton,
#controlsPanel.pingpong #slashButton,
#controlsPanel.pingpong .dodgeHint,
#controlsPanel.snake #mineButton,
#controlsPanel.snake #slashButton,
#controlsPanel.snake .dodgeHint,
#controlsPanel.crumble #mineButton,
#controlsPanel.crumble #slashButton,
#controlsPanel.crumble .dodgeHint,
#controlsPanel.bumper #mineButton,
#controlsPanel.bumper #slashButton,
#controlsPanel.bumper .dodgeHint,
#controlsPanel.space #mineButton,
#controlsPanel.space #slashButton,
#controlsPanel.space .dodgeHint,
#controlsPanel.flappy #mineButton,
#controlsPanel.flappy #slashButton,
#controlsPanel.flappy .dodgeHint,
#controlsPanel.miner #mineButton,
#controlsPanel.miner #slashButton,
#controlsPanel.miner .dodgeHint,
#controlsPanel.side #mineButton,
#controlsPanel.side #slashButton,
#controlsPanel.side .dodgeHint,
#controlsPanel.bomber #mineButton,
#controlsPanel.bomber #slashButton,
#controlsPanel.bomber .dodgeHint,
#controlsPanel.canons #mineButton,
#controlsPanel.canons #slashButton,
#controlsPanel.canons .dodgeHint,
#controlsPanel.maze #mineButton,
#controlsPanel.maze #slashButton,
#controlsPanel.maze .dodgeHint,
#controlsPanel.battletris #mineButton,
#controlsPanel.battletris #slashButton,
#controlsPanel.battletris .dodgeHint {
  display: none;
}

#controlsPanel.remember #mineButton,
#controlsPanel.remember #slashButton,
#controlsPanel.remember .dodgeHint {
  display: none;
}

#slashButton,
.slashHint {
  display: none;
}

#towerControls,
#pingpongControls,
#snakeControls,
#crumbleControls,
#bumperControls,
#spaceControls,
#flappyControls,
#minerControls,
#sideControls,
#bomberControls,
#canonsControls,
#mazeControls,
#battletrisControls,
#rememberControls {
  display: none;
  font-size: 12px;
  white-space: nowrap;
}

#towerControls {
  color: #d1f3ff;
}

#pingpongControls {
  color: #ccfbf1;
}

#snakeControls {
  color: #dcfce7;
}

#crumbleControls {
  color: #fef3c7;
}

#bumperControls {
  color: #bae6fd;
}

#spaceControls {
  color: #e0e7ff;
}

#flappyControls {
  color: #fef3c7;
}

#minerControls {
  color: #fde68a;
}

#sideControls {
  color: #dcfce7;
}

#bomberControls {
  color: #fee2e2;
}

#canonsControls {
  color: #e2e8f0;
}

#mazeControls {
  color: #ccfbf1;
}

#battletrisControls {
  color: #bbf7d0;
}

#rememberControls {
  color: #fde68a;
}

#controlsPanel.tower #towerControls {
  display: inline;
}

#controlsPanel.pingpong #pingpongControls {
  display: inline;
}

#controlsPanel.snake #snakeControls {
  display: inline;
}

#controlsPanel.crumble #crumbleControls {
  display: inline;
}

#controlsPanel.bumper #bumperControls {
  display: inline;
}

#controlsPanel.space #spaceControls {
  display: inline;
}

#controlsPanel.flappy #flappyControls {
  display: inline;
}

#controlsPanel.miner #minerControls {
  display: inline;
}

#controlsPanel.side #sideControls {
  display: inline;
}

#controlsPanel.bomber #bomberControls {
  display: inline;
}

#controlsPanel.canons #canonsControls {
  display: inline;
}

#controlsPanel.maze #mazeControls {
  display: inline;
}

#controlsPanel.battletris #battletrisControls {
  display: inline;
}

#controlsPanel.remember #rememberControls {
  display: inline;
}

.rememberHud {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  z-index: 16;
}

.rememberLayout {
  position: absolute;
  inset: 0;
}

.rememberTop {
  position: absolute;
  left: 50%;
  top: 38px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 560px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(2,6,23,0.82);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 28px rgba(15,23,42,0.35);
}

.rememberTitle {
  font-size: 28px;
  font-weight: bold;
}

.rememberSubtitle,
.rememberMeta {
  color: #cbd5e1;
  font-size: 14px;
}

.rememberMeta {
  margin-left: auto;
  display: grid;
  gap: 4px;
  justify-items: end;
}

.rememberPadGrid {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.rememberPad {
  appearance: none;
  position: absolute;
  pointer-events: auto;
  border: 0;
  border-radius: 40px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24), transparent 48%),
    var(--remember-color);
  box-shadow:
    inset 0 -16px 36px rgba(0,0,0,0.22),
    inset 0 0 0 3px rgba(255,255,255,0.18),
    0 0 28px rgba(0,0,0,0.28);
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.rememberPad:hover:not(:disabled) {
  box-shadow:
    inset 0 -14px 32px rgba(0,0,0,0.2),
    inset 0 0 0 3px rgba(255,255,255,0.22),
    0 0 30px rgba(0,0,0,0.24);
}

.rememberPad:disabled {
  cursor: default;
}

.rememberPad.active {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.36), transparent 44%),
    var(--remember-color);
  box-shadow:
    inset 0 -10px 24px rgba(255,255,255,0.08),
    inset 0 0 0 4px rgba(255,255,255,0.34),
    0 0 44px var(--remember-glow),
    0 0 90px rgba(255,255,255,0.14);
}

.rememberPlayers {
  position: absolute;
  right: 40px;
  top: 180px;
  display: grid;
  gap: 10px;
  width: 220px;
}

.rememberPlayerChip {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(2,6,23,0.82);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
  font-size: 13px;
  box-shadow: 0 0 18px rgba(15,23,42,0.24);
}

.rememberPlayerChip.ko {
  opacity: 0.56;
}

.battletrisHud {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 16;
}

.battletrisLayout {
  display: grid;
  grid-template-columns: minmax(0, 480px) 240px;
  gap: 22px;
  align-items: center;
}

.battletrisMain,
.battletrisSidebar {
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  background: rgba(2,6,23,0.84);
  box-shadow: 0 0 28px rgba(15,23,42,0.34);
  backdrop-filter: blur(10px);
}

.battletrisPanelHeader,
.battletrisOpponentHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.battletrisTitle,
.battletrisSidebarTitle {
  font-size: 22px;
  font-weight: bold;
}

.battletrisMeta,
.battletrisStats,
.battletrisOpponentMeta {
  color: #cbd5e1;
  font-size: 13px;
}

.battletrisStats {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.battletrisNextWrap {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.battletrisNextLabel {
  font-size: 12px;
  color: #cbd5e1;
}

.battletrisPreview {
  display: grid;
  grid-template-columns: repeat(var(--bt-preview-cols, 4), 18px);
  grid-template-rows: repeat(var(--bt-preview-rows, 2), 18px);
  gap: 2px;
  min-width: 76px;
  min-height: 40px;
  padding: 8px;
  place-content: center;
  border-radius: 12px;
  background: rgba(15,23,42,0.82);
  border: 1px solid rgba(255,255,255,0.08);
  box-sizing: border-box;
}

.battletrisPreviewCell {
  border-radius: 4px;
  background: transparent;
}

.battletrisPreviewCell.filled {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.32), transparent 46%),
    var(--bt-color);
  box-shadow:
    inset 0 -2px 0 rgba(0,0,0,0.2),
    inset 0 0 0 1px rgba(255,255,255,0.16);
}

.battletrisBoard {
  margin-top: 14px;
  width: 360px;
  height: 720px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(20, 1fr);
  gap: 3px;
  padding: 12px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(15,23,42,0.96), rgba(17,24,39,0.96)),
    rgba(0,0,0,0.9);
  border: 2px solid rgba(148,163,184,0.32);
  box-sizing: border-box;
}

.battletrisCell {
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.battletrisCell.filled {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.32), transparent 46%),
    var(--bt-color);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.2),
    inset 0 0 0 1px rgba(255,255,255,0.18),
    0 0 10px rgba(255,255,255,0.12);
}

.battletrisSidebar {
  display: grid;
  gap: 12px;
  min-height: 420px;
}

.battletrisOpponent {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15,23,42,0.82);
  border: 1px solid rgba(255,255,255,0.08);
}

.battletrisOpponent.ko {
  opacity: 0.56;
}

.battletrisOpponentName,
.battletrisOpponentValue {
  font-size: 13px;
  font-weight: bold;
}

.battletrisOpponentValue {
  color: #fde68a;
}

.battletrisOpponentMeter {
  position: relative;
  height: 124px;
  overflow: hidden;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(239,68,68,0.16), rgba(250,204,21,0.12) 45%, rgba(34,197,94,0.1));
  border: 1px solid rgba(255,255,255,0.08);
}

.battletrisOpponentFill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 6px;
  background: linear-gradient(180deg, #ef4444 0%, #f59e0b 48%, #22c55e 100%);
  box-shadow: 0 0 18px rgba(248,113,113,0.32);
}

.battletrisEmpty {
  color: #94a3b8;
  font-size: 13px;
}

#controlsPanel button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: #333;
  color: white;
  cursor: pointer;
}

#mineButton {
  width: 38px;
  height: 30px;
  min-width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  position: relative;
}

.controlHint {
  color: #d1d5db;
  font-size: 12px;
  white-space: nowrap;
}

#mineButton::before {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    conic-gradient(#facc15 calc(var(--mine-progress, 1) * 1turn), #3f3f46 0),
    #3f3f46;
  box-shadow: 0 0 10px rgba(250,204,21,0.35);
}

#mineButton::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #18181b;
  box-shadow: inset 0 0 0 2px #f97316;
}

#mineButton:disabled {
  cursor: default;
  opacity: 0.75;
}

#mineButton.ready::before {
  box-shadow: 0 0 14px rgba(250,204,21,0.8);
}

#slashButton {
  width: auto;
  min-width: 82px;
  padding: 0 10px;
  background: #7f1d1d;
  color: white;
}

#slashButton.ready {
  background: #dc2626;
  box-shadow: 0 0 12px rgba(220,38,38,0.5);
}

#slashButton.active {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#roundInfo {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: rgba(0,0,0,0.72);
  border-radius: 8px;
  font-weight: bold;
  z-index: 50;
}

#roundInfo.hidden,
#powerupInfo.hidden {
  display: none;
}

#powerupInfo {
  position: fixed;
  left: 50%;
  top: 66px;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: rgba(0,0,0,0.72);
  border-radius: 8px;
  font-size: 13px;
  z-index: 50;
}

#powerupInfo.minerDanger {
  background: rgba(127,29,29,0.92);
  color: #fff7ed;
  border: 2px solid rgba(250,204,21,0.9);
  box-shadow: 0 0 22px rgba(239,68,68,0.78), 0 0 42px rgba(250,204,21,0.35);
  font-size: 18px;
  font-weight: bold;
  animation: minerTimerDanger 420ms ease-in-out infinite alternate;
}

@keyframes minerTimerDanger {
  0% {
    transform: translateX(-50%) scale(1);
  }
  100% {
    transform: translateX(-50%) scale(1.08);
  }
}

#statusOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 40;
}

#connectionOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,0.58);
  z-index: 120;
  pointer-events: none;
}

#connectionOverlay.visible {
  display: flex;
}

.lanDisconnect {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px 26px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(0,0,0,0.82);
  box-shadow: 0 0 34px rgba(248,113,113,0.24);
}

.lanIcon {
  position: relative;
  width: 136px;
  height: 72px;
}

.lanCable {
  position: absolute;
  top: 34px;
  width: 55px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.26);
}

.lanCable.left {
  left: 0;
  animation: cableLeftUnplug 900ms ease-in-out infinite alternate;
}

.lanCable.right {
  right: 0;
  animation: cableRightUnplug 900ms ease-in-out infinite alternate;
}

.lanPlug {
  position: absolute;
  top: 23px;
  width: 32px;
  height: 30px;
  border: 3px solid #e5e7eb;
  border-radius: 5px;
  background: #334155;
  box-sizing: border-box;
}

.lanPlug.left {
  left: 47px;
  animation: plugLeftUnplug 900ms ease-in-out infinite alternate;
}

.lanPlug.right {
  right: 47px;
  animation: plugRightUnplug 900ms ease-in-out infinite alternate;
}

.lanPlug::before {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  top: -10px;
  height: 7px;
  border-radius: 3px 3px 0 0;
  background: #e5e7eb;
}

.lanBreak {
  position: absolute;
  left: 50%;
  top: 22px;
  width: 2px;
  height: 32px;
  background: #f87171;
  box-shadow: 0 0 12px rgba(248,113,113,0.8);
  transform: translateX(-50%) rotate(18deg);
  animation: breakBlink 500ms ease-in-out infinite alternate;
}

.lanText {
  color: #fecaca;
  font-size: 15px;
  font-weight: bold;
}

@keyframes plugLeftUnplug {
  0% {
    transform: translateX(0) rotate(0);
  }
  100% {
    transform: translateX(-12px) rotate(-7deg);
  }
}

@keyframes plugRightUnplug {
  0% {
    transform: translateX(0) rotate(0);
  }
  100% {
    transform: translateX(12px) rotate(7deg);
  }
}

@keyframes cableLeftUnplug {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-10px);
  }
}

@keyframes cableRightUnplug {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(10px);
  }
}

@keyframes breakBlink {
  0% {
    opacity: 0.42;
  }
  100% {
    opacity: 1;
  }
}

#statusText {
  padding: 18px 26px;
  background: rgba(0,0,0,0.86);
  border-radius: 8px;
  font-size: 32px;
  font-weight: bold;
  text-align: center;
}

#statusOverlay.votingMode #statusText {
  padding: 12px 18px;
  font-size: 24px;
}

#statusOverlay.winnerMode #statusText {
  position: relative;
  min-width: min(560px, calc(100vw - 48px));
  padding: 28px 34px;
  overflow: hidden;
  border: 2px solid rgba(250,204,21,0.75);
  background:
    radial-gradient(circle at 50% 0%, rgba(250,204,21,0.32), transparent 44%),
    rgba(0,0,0,0.9);
  box-shadow: 0 0 38px rgba(250,204,21,0.35), 0 0 90px rgba(56,189,248,0.22);
  animation: winnerPop 700ms ease-out both, winnerGlow 900ms ease-in-out infinite alternate;
}

#statusOverlay.matchWinnerMode #statusText {
  position: relative;
  min-width: min(620px, calc(100vw - 48px));
  padding: 34px 38px 42px;
  overflow: hidden;
  border: 2px solid rgba(250,204,21,0.9);
  background:
    radial-gradient(circle at 50% 0%, rgba(250,204,21,0.42), transparent 44%),
    radial-gradient(circle at 50% 100%, rgba(14,165,233,0.22), transparent 48%),
    rgba(0,0,0,0.93);
  box-shadow: 0 0 48px rgba(250,204,21,0.52), 0 0 110px rgba(250,204,21,0.22);
  animation: crownWinnerPop 900ms ease-out both, winnerGlow 900ms ease-in-out infinite alternate;
}

#statusOverlay.matchWinnerMode #statusText::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 8px;
  width: 86px;
  height: 42px;
  transform: translateX(-50%);
  background:
    linear-gradient(135deg, transparent 0 35%, #facc15 36% 100%) 0 12px / 28px 30px,
    linear-gradient(45deg, transparent 0 35%, #fde68a 36% 100%) 29px 0 / 28px 42px,
    linear-gradient(225deg, transparent 0 35%, #facc15 36% 100%) 58px 12px / 28px 30px,
    linear-gradient(#facc15, #d97706) 0 30px / 86px 12px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 12px rgba(250,204,21,0.75));
  animation: crownFloat 1300ms ease-in-out infinite alternate;
}

#statusOverlay.matchWinnerMode #statusText::after {
  content: '';
  position: absolute;
  inset: -18px;
  pointer-events: none;
  background:
    radial-gradient(circle, #facc15 0 3px, transparent 4px) 12% 24% / 92px 92px,
    radial-gradient(circle, #fde68a 0 3px, transparent 4px) 62% 14% / 112px 112px,
    radial-gradient(circle, #38bdf8 0 3px, transparent 4px) 84% 74% / 86px 86px;
  animation: winnerSparkles 1200ms ease-out infinite;
}

@keyframes crownWinnerPop {
  0% {
    opacity: 0;
    transform: scale(0.72) translateY(18px);
  }
  62% {
    opacity: 1;
    transform: scale(1.08) translateY(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes crownFloat {
  0% {
    transform: translateX(-50%) translateY(0) rotate(-2deg);
  }
  100% {
    transform: translateX(-50%) translateY(-5px) rotate(2deg);
  }
}

#statusOverlay.winnerMode #statusText::before,
#statusOverlay.winnerMode #statusText::after {
  content: '';
  position: absolute;
  inset: -24px;
  pointer-events: none;
  background:
    radial-gradient(circle, #facc15 0 3px, transparent 4px) 8% 18% / 90px 90px,
    radial-gradient(circle, #38bdf8 0 3px, transparent 4px) 52% 8% / 112px 112px,
    radial-gradient(circle, #f97316 0 3px, transparent 4px) 84% 28% / 78px 78px,
    radial-gradient(circle, #22c55e 0 3px, transparent 4px) 18% 74% / 104px 104px,
    radial-gradient(circle, #f472b6 0 3px, transparent 4px) 74% 82% / 86px 86px;
  animation: winnerSparkles 900ms ease-out both;
}

#statusOverlay.winnerMode #statusText::after {
  transform: rotate(18deg) scale(1.08);
  animation-delay: 120ms;
}

@keyframes winnerPop {
  0% {
    opacity: 0;
    transform: scale(0.78) rotate(-2deg);
  }
  70% {
    opacity: 1;
    transform: scale(1.08) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes winnerGlow {
  0% {
    box-shadow: 0 0 30px rgba(250,204,21,0.25), 0 0 72px rgba(56,189,248,0.16);
  }
  100% {
    box-shadow: 0 0 46px rgba(250,204,21,0.48), 0 0 104px rgba(56,189,248,0.28);
  }
}

@keyframes winnerSparkles {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.82);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-18px) scale(1.16);
  }
}

#statusPanel {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(1240px, calc(100vw - 24px));
}

#startSoloButton {
  display: none;
  pointer-events: auto;
  padding: 10px 16px;
  border: 0;
  border-radius: 6px;
  background: #0ea5e9;
  color: white;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(14,165,233,0.38);
}

#startSoloButton.visible {
  display: block;
}

#voteGrid {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 8px;
  width: 100%;
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  padding-right: 4px;
  box-sizing: border-box;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(56,189,248,0.72) rgba(255,255,255,0.1);
}

#voteGrid.visible {
  display: grid;
}

.voteCard {
  position: relative;
  min-height: 88px;
  padding: 9px;
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.1), transparent 52%),
    rgba(0,0,0,0.86);
  color: white;
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto 5px;
  align-items: center;
  gap: 5px 8px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.voteCard:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.38);
}

.voteCard.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 18px rgba(56,189,248,0.38);
}

.voteCard.locked {
  border-color: #facc15;
  box-shadow: 0 0 20px rgba(250,204,21,0.42);
}

.voteCard:disabled {
  cursor: default;
}

.voteIcon {
  position: relative;
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
}

.voteIcon.target {
  border: 3px solid #f97316;
  border-radius: 50%;
  box-shadow: 0 0 13px rgba(249,115,22,0.45);
}

.voteIcon.target::before,
.voteIcon.target::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 3px solid #fff;
  border-radius: 50%;
}

.voteIcon.target::after {
  inset: 12px;
  border: 0;
  background: #ef4444;
}

.voteIcon.tower {
  border-left: 5px solid #38bdf8;
  border-right: 5px solid #38bdf8;
  box-shadow: 0 0 13px rgba(56,189,248,0.42);
}

.voteIcon.tower::before,
.voteIcon.tower::after {
  content: '';
  position: absolute;
  left: 3px;
  right: 3px;
  height: 6px;
  border-radius: 4px;
  background: #e0f2fe;
}

.voteIcon.tower::before {
  top: 6px;
}

.voteIcon.tower::after {
  bottom: 6px;
}

.voteIcon.pingpong {
  border: 3px solid rgba(45,212,191,0.85);
  border-radius: 8px;
  box-shadow: 0 0 13px rgba(45,212,191,0.45);
  transform: rotate(45deg);
}

.voteIcon.pingpong::before,
.voteIcon.pingpong::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  transform: rotate(-45deg);
}

.voteIcon.pingpong::before {
  width: 20px;
  height: 5px;
  left: 4px;
  top: 11px;
  background: #2dd4bf;
  box-shadow: 0 0 9px rgba(45,212,191,0.7);
}

.voteIcon.pingpong::after {
  width: 7px;
  height: 7px;
  right: 1px;
  top: 1px;
  background: #facc15;
  box-shadow: 0 0 9px rgba(250,204,21,0.75);
}

.voteIcon.snake {
  border-radius: 8px;
}

.voteIcon.snake::before,
.voteIcon.snake::after {
  content: '';
  position: absolute;
  border-radius: 7px;
  box-sizing: border-box;
}

.voteIcon.snake::before {
  left: 4px;
  top: 7px;
  width: 30px;
  height: 24px;
  border: 6px solid #22c55e;
  border-left-color: transparent;
  box-shadow: 0 0 12px rgba(34,197,94,0.55);
}

.voteIcon.snake::after {
  right: 0;
  top: 4px;
  width: 11px;
  height: 11px;
  background: #f43f5e;
  box-shadow: 0 0 10px rgba(244,63,94,0.7);
}

.voteIcon.crumble {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 2px;
  align-content: center;
  justify-content: center;
}

.voteIcon.crumble::before {
  content: '';
  width: 10px;
  height: 10px;
  background: #f59e0b;
  box-shadow:
    12px 0 #d97706,
    24px 0 #fbbf24,
    0 12px #b45309,
    12px 12px #92400e,
    24px 12px #d97706,
    0 24px #fbbf24,
    12px 24px #d97706;
}

.voteIcon.crumble::after {
  content: '';
  position: absolute;
  right: 2px;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #451a03;
  transform: rotate(18deg);
  box-shadow: 0 0 9px rgba(251,191,36,0.45);
}

.voteIcon.bumper {
  border: 3px solid #7dd3fc;
  border-radius: 50%;
  background: radial-gradient(circle, #65a30d 0 46%, #92400e 47% 64%, transparent 65%);
  box-shadow: 0 0 14px rgba(125,211,252,0.48);
}

.voteIcon.bumper::before,
.voteIcon.bumper::after {
  content: '';
  position: absolute;
  border: 2px solid white;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,0.22);
}

.voteIcon.bumper::before {
  width: 12px;
  height: 12px;
  left: 7px;
  top: 10px;
}

.voteIcon.bumper::after {
  width: 10px;
  height: 10px;
  right: 6px;
  bottom: 8px;
  background: #38bdf8;
}

.voteIcon.space {
  border-radius: 50%;
}

.voteIcon.space::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 4px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 25px solid #38bdf8;
  filter: drop-shadow(0 0 10px rgba(56,189,248,0.7));
}

.voteIcon.space::after {
  content: '';
  position: absolute;
  left: 16px;
  bottom: 2px;
  width: 6px;
  height: 10px;
  border-radius: 999px;
  background: #f97316;
  box-shadow: 0 0 12px rgba(249,115,22,0.8);
}

.voteIcon.flappy {
  border-radius: 50%;
}

.voteIcon.flappy::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 10px;
  width: 22px;
  height: 17px;
  border: 2px solid #fff;
  border-radius: 60% 45% 55% 45%;
  background: #facc15;
  box-shadow: inset -4px -3px 0 rgba(0,0,0,0.13), 0 0 9px rgba(250,204,21,0.55);
}

.voteIcon.flappy::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 16px;
  border-left: 9px solid #f97316;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.voteIcon.miner {
  border-radius: 8px;
}

.voteIcon.miner::before {
  content: '';
  position: absolute;
  inset: 5px;
  background:
    linear-gradient(#64748b 0 0) 0 0 / 12px 12px,
    linear-gradient(#94a3b8 0 0) 14px 0 / 12px 12px,
    linear-gradient(#64748b 0 0) 28px 0 / 12px 12px,
    linear-gradient(#94a3b8 0 0) 0 14px / 12px 12px,
    linear-gradient(#991b1b 0 0) 14px 14px / 12px 12px,
    linear-gradient(#64748b 0 0) 28px 14px / 12px 12px,
    linear-gradient(#64748b 0 0) 0 28px / 12px 12px,
    linear-gradient(#94a3b8 0 0) 14px 28px / 12px 12px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 10px rgba(251,191,36,0.35));
}

.voteIcon.miner::after {
  content: '!';
  position: absolute;
  right: 1px;
  bottom: -3px;
  color: #facc15;
  font-size: 18px;
  font-weight: bold;
}

.voteIcon.side {
  border-radius: 8px;
  background: linear-gradient(#7dd3fc 0 54%, #22c55e 55% 72%, #92400e 73%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18), 0 0 12px rgba(34,197,94,0.4);
}

.voteIcon.side::before {
  content: '';
  position: absolute;
  left: 4px;
  bottom: 7px;
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 5px 5px;
  background: #ef4444;
  box-shadow: 18px -8px 0 -3px #facc15;
}

.voteIcon.side::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 4px;
  width: 20px;
  height: 8px;
  border-radius: 2px;
  background: #b45309;
  box-shadow: inset 0 3px 0 #facc15;
}

.voteIcon.bomber {
  border-radius: 8px;
  background:
    linear-gradient(#334155 0 0) 3px 3px / 10px 10px,
    linear-gradient(#92400e 0 0) 16px 3px / 10px 10px,
    linear-gradient(#334155 0 0) 29px 3px / 10px 10px,
    linear-gradient(#92400e 0 0) 3px 16px / 10px 10px,
    radial-gradient(circle at 50% 50%, #111827 0 28%, #facc15 29% 35%, transparent 36%),
    linear-gradient(#92400e 0 0) 29px 16px / 10px 10px,
    linear-gradient(#334155 0 0) 3px 29px / 10px 10px,
    linear-gradient(#92400e 0 0) 16px 29px / 10px 10px,
    linear-gradient(#334155 0 0) 29px 29px / 10px 10px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 10px rgba(249,115,22,0.42));
}

.voteIcon.bomber::after {
  content: '';
  position: absolute;
  left: 20px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 10px #f97316;
}

.voteIcon.canons {
  border-radius: 8px;
  background:
    linear-gradient(#64748b 0 0) 6px 27px / 30px 8px,
    linear-gradient(#94a3b8 0 0) 13px 19px / 16px 12px,
    linear-gradient(135deg, transparent 0 46%, #334155 47% 67%, transparent 68%) 18px 8px / 24px 16px,
    radial-gradient(circle at 9px 11px, #f97316 0 12%, #facc15 13% 18%, transparent 19%),
    linear-gradient(#1e293b, #0f172a);
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 10px rgba(148,163,184,0.45));
}

.voteIcon.canons::after {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.5);
}

.voteIcon.maze {
  border-radius: 8px;
  background:
    linear-gradient(#5eead4 0 0) 4px 7px / 32px 6px,
    linear-gradient(#5eead4 0 0) 4px 25px / 26px 6px,
    linear-gradient(#5eead4 0 0) 4px 7px / 6px 24px,
    linear-gradient(#a78bfa 0 0) 22px 7px / 6px 24px,
    linear-gradient(#ef4444 0 0) 33px 17px / 6px 14px,
    radial-gradient(circle at 36px 9px, #22c55e 0 12%, transparent 13%),
    linear-gradient(#0f172a, #134e4a);
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 10px rgba(45,212,191,0.45));
}

.voteIcon.maze::after {
  content: '';
  position: absolute;
  left: 11px;
  bottom: 6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #f8fafc;
}

.voteIcon.battletris {
  border-radius: 8px;
  background:
    linear-gradient(#22c55e 0 0) 4px 4px / 10px 10px,
    linear-gradient(#38bdf8 0 0) 15px 4px / 10px 10px,
    linear-gradient(#facc15 0 0) 26px 4px / 10px 10px,
    linear-gradient(#a78bfa 0 0) 15px 15px / 10px 10px,
    linear-gradient(#f97316 0 0) 26px 15px / 10px 10px,
    linear-gradient(#ef4444 0 0) 4px 26px / 10px 10px,
    linear-gradient(#22c55e 0 0) 15px 26px / 10px 10px,
    linear-gradient(#475569 0 0) 26px 26px / 10px 10px,
    linear-gradient(#111827, #0f172a);
  background-repeat: no-repeat;
  box-shadow: 0 0 12px rgba(34,197,94,0.36);
}

.voteIcon.battletris::after {
  content: '';
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #facc15, #22c55e);
}

.voteIcon.remember {
  border-radius: 10px;
  background:
    radial-gradient(circle at 10px 10px, #22c55e 0 34%, transparent 35%),
    radial-gradient(circle at 28px 10px, #ef4444 0 34%, transparent 35%),
    radial-gradient(circle at 10px 28px, #facc15 0 34%, transparent 35%),
    radial-gradient(circle at 28px 28px, #38bdf8 0 34%, transparent 35%),
    linear-gradient(#0f172a, #111827);
  box-shadow: 0 0 12px rgba(250,204,21,0.28);
}

.voteIcon.remember::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
}

.voteName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: bold;
}

.voteCount {
  grid-column: 2 / 3;
  justify-self: start;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: #e5e7eb;
  font-size: 11px;
  font-weight: bold;
}

.voteRank {
  display: none;
  color: #9ca3af;
  font-size: 12px;
}

.voteBar {
  grid-column: 1 / -1;
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}

.voteBarFill {
  display: block;
  height: 100%;
  width: 0;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #facc15);
  box-shadow: 0 0 12px rgba(56,189,248,0.4);
}

#votingContent {
  display: none;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 10px;
  width: min(1220px, calc(100vw - 24px));
  max-height: calc(100vh - 88px);
  align-items: start;
  pointer-events: auto;
}

#votingContent.visible {
  display: grid;
}

#votingContent.noResult {
  grid-template-columns: minmax(0, min(820px, 100%));
  justify-content: center;
}

#votingContent.noResult #voteGrid {
  max-height: calc(100vh - 128px);
}

#roundResult {
  display: none;
  width: 100%;
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.88);
  border: 2px solid rgba(255,255,255,0.22);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(147,197,253,0.7) rgba(255,255,255,0.1);
}

#roundResult.visible {
  display: block;
}

.resultTitle {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 3px;
}

.resultMeta {
  color: #d1d5db;
  font-size: 12px;
  margin-bottom: 6px;
}

.resultRow {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto auto auto;
  gap: 7px;
  align-items: center;
  padding: 5px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}

.resultRow.rankUp {
  animation: rankUpPulse 860ms ease-out both;
}

.resultRow.rankDown {
  animation: rankDownPulse 860ms ease-out both;
}

.resultRank {
  color: #93c5fd;
  font-weight: bold;
}

.resultName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resultStats {
  color: #d1d5db;
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.resultScore {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 54px;
  color: #f8fafc;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.resultScoreTotal {
  animation: scoreTotalPop 760ms ease-out both;
}

.resultScoreAdd {
  color: #facc15;
  text-shadow: 0 0 10px rgba(250,204,21,0.55);
  animation: scoreAddPop 1050ms ease-out both;
}

.resultMove {
  min-width: 32px;
  font-size: 12px;
  font-weight: bold;
  text-align: right;
  white-space: nowrap;
}

.resultMove.up {
  color: #22c55e;
  animation: rankMoveUp 980ms ease-out both;
}

.resultMove.down {
  color: #fb7185;
  animation: rankMoveDown 980ms ease-out both;
}

@keyframes rankUpPulse {
  0% {
    background: rgba(34,197,94,0);
    transform: translateY(8px);
  }
  35% {
    background: rgba(34,197,94,0.18);
    transform: translateY(-3px);
  }
  100% {
    background: rgba(34,197,94,0);
    transform: translateY(0);
  }
}

@keyframes rankDownPulse {
  0% {
    background: rgba(251,113,133,0);
    transform: translateY(-8px);
  }
  35% {
    background: rgba(251,113,133,0.16);
    transform: translateY(3px);
  }
  100% {
    background: rgba(251,113,133,0);
    transform: translateY(0);
  }
}

@keyframes rankMoveUp {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  28% {
    opacity: 1;
    transform: translateY(-4px) scale(1.15);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rankMoveDown {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
  }
  28% {
    opacity: 1;
    transform: translateY(4px) scale(1.15);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scoreAddPop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.88);
  }
  22% {
    opacity: 1;
    transform: translateY(-3px) scale(1.12);
  }
  72% {
    opacity: 1;
    transform: translateY(-3px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}

@keyframes scoreTotalPop {
  0% {
    transform: scale(0.96);
  }
  45% {
    color: #facc15;
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 720px) {
  .homeHeader {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .homeStats {
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
    text-align: left;
  }

  .homeBrand {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .appLogo {
    width: 48px;
    height: 48px;
  }

  .appLogo::before {
    left: 10px;
    top: 10px;
    width: 28px;
    height: 28px;
  }

  .appLogo::after {
    left: 19px;
    top: 19px;
  }

  .homeTitle {
    font-size: 29px;
  }

  #statusPanel {
    width: min(520px, calc(100vw - 18px));
  }

  #statusOverlay.votingMode #statusText {
    width: 100%;
    box-sizing: border-box;
    font-size: 20px;
  }

  #votingContent {
    grid-template-columns: 1fr;
    width: min(520px, calc(100vw - 18px));
    max-height: calc(100vh - 82px);
  }

  #votingContent.noResult {
    grid-template-columns: 1fr;
  }

  #voteGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: calc(100vh - 270px);
  }

  .voteCard {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 104px;
    text-align: center;
  }

  .voteIcon {
    grid-row: auto;
  }

  .voteCount {
    grid-column: auto;
    justify-self: center;
  }

  .voteBar {
    grid-column: auto;
    width: 100%;
  }
}
