:root {
  --ink: #ffffff;
  --blue: #1f8bff;
  --blue-dark: #0b5fc4;
  --blue-deep: #0a3f8f;
  --panel: rgba(18, 92, 190, 0.78);
  --panel-gloss: linear-gradient(180deg, rgba(48, 150, 255, 0.92), rgba(16, 88, 196, 0.9));
  --panel-shadow: 0 4px 0 #0b4fa8, 0 8px 18px rgba(0, 40, 100, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  --yellow: #ffd34d;
  --orange: #ff8a3d;
  --red: #ff4d5e;
  --green: #3ddc68;
  --font: 'Fredoka', system-ui, sans-serif;
  --spring: cubic-bezier(0.3, 1.6, 0.5, 1);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fdcff;
  color: var(--ink);
  font: 600 15px/1.3 var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game,
#game canvas,
.labels { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.labels .label { position: absolute; left: 0; top: 0; will-change: transform; }
#stats { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 50; white-space: pre; margin: 0; padding: 6px 9px; border-radius: 8px; background: rgba(0, 0, 0, 0.6); color: #b8ffcf; font: 12px/1.45 ui-monospace, Consolas, monospace; pointer-events: none; }
#game canvas { transition: filter 0.45s ease-out; }
/* While you wait to respawn the world drains of colour. */
body.dead #game canvas { filter: saturate(0.25) brightness(0.92) contrast(1.05); }

/* Outlined cartoon text */
.outline,
.label,
#banner,
h1 { -webkit-text-stroke: 0; text-shadow: 0 2px 0 var(--blue-dark), 2px 0 0 var(--blue-dark), -2px 0 0 var(--blue-dark), 0 -2px 0 var(--blue-dark), 0 4px 6px rgba(0, 0, 0, 0.3); }

.label { font: 700 16px var(--font); white-space: nowrap; }
.label .hp { width: 54px; height: 7px; margin: 3px auto 0; border-radius: 4px; overflow: hidden; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.7); }
.label .hp i { display: block; width: 100%; height: 100%; background: #5dff7a; transition: width 0.15s ease-out; }

kbd { padding: 1px 7px; border-radius: 6px; background: rgba(0, 0, 0, 0.25); border-bottom: 2px solid rgba(0, 0, 0, 0.25); font: 600 13px var(--font); }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
body.playing #hud { display: block; }

#rankbox { position: absolute; top: 10px; left: 10px; width: 210px; }
#rank {
  display: inline-block;
  margin-bottom: 6px;
  padding: 4px 16px;
  border-radius: 999px;
  background: var(--panel-gloss);
  border: 3px solid #fff;
  font: 700 24px var(--font);
  box-shadow: var(--panel-shadow);
  text-shadow: 0 2px 0 var(--blue-deep);
  transform-origin: left center;
}
#rank sup { font-size: 14px; }
#network-ping { display: flex; align-items: center; gap: 6px; width: fit-content; margin-top: 8px; padding: 5px 10px; border-radius: 9px; background: var(--blue-deep); font-size: 12px; font-variant-numeric: tabular-nums; color: #d0dcec; }
#network-ping i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
#network-ping[data-quality="good"] { color: #93dfae; }
#network-ping[data-quality="fair"] { color: #ffcf77; }
#network-ping[data-quality="poor"] { color: #ff8888; }
.rank-delta { position: absolute; top: 8px; right: 0; padding: 2px 9px; border-radius: 999px; font: 700 16px var(--font); border: 2px solid #fff; }
.rank-delta.up { background: var(--green); box-shadow: 0 3px 0 #1f9a42; }
.rank-delta.down { background: var(--red); box-shadow: 0 3px 0 #a3243a; }
#board { list-style: none; margin: 0; padding: 4px; border-radius: 12px; background: var(--panel-gloss); border: 2px solid rgba(255, 255, 255, 0.7); box-shadow: var(--panel-shadow); }
#board li { position: relative; display: flex; align-items: center; gap: 8px; padding: 2px 6px; border-radius: 7px; }
#board li:nth-child(odd) { background: rgba(255, 255, 255, 0.08); }
#board li.me { color: var(--yellow); background: rgba(255, 211, 77, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 211, 77, 0.6); }
#board .pos { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--blue); font-size: 13px; }
#board li:nth-child(1) .pos { background: linear-gradient(#ffe680, #ffc21a); color: #8a5a00; }
#board li:nth-child(2) .pos { background: linear-gradient(#f4f7fb, #c9d3e0); color: #4a5a70; }
#board li:nth-child(3) .pos { background: linear-gradient(#ffc999, #e3884a); color: #6b3510; }
#board .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board .k { display: inline-block; min-width: 18px; text-align: right; font-variant-numeric: tabular-nums; }

#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #e6f1ff);
  color: var(--blue);
  font: 700 22px var(--font);
  box-shadow: 0 3px 0 rgba(10, 60, 140, 0.25), 0 6px 14px rgba(0, 40, 100, 0.18);
  transition: background 0.2s, color 0.2s;
}
.pill .ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5cb2ff, var(--blue) 60%, var(--blue-dark)); color: #fff; font-size: 18px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.bar { position: relative; width: 150px; height: 16px; border-radius: 8px; overflow: hidden; background: #d3e3f5; box-shadow: inset 0 2px 3px rgba(0, 40, 100, 0.25); }
.bar i { position: absolute; inset: 0; display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #2fd35f, #8cff6a); transition: width 0.12s; }
.bar #hptrail { background: #ffbb69; transition: none; }
/* Gloss highlight and segment ticks over the fill. */
.bar::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0 38%, transparent 38%),
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0, 50, 110, 0.22) calc(10% - 2px) 10%);
}
#hptext { min-width: 28px; font-size: 14px; font-variant-numeric: tabular-nums; }
#health.critical { color: #d52448; box-shadow: 0 0 0 3px #ff4d5e, 0 0 24px #ff4d5e80; animation: critical-glow 0.7s ease-in-out infinite; }
#health.critical #hpfill { background: linear-gradient(90deg, #e8243f, #ff6b7a); }
#health.critical .ico { background: radial-gradient(circle at 35% 30%, #ff8a96, var(--red) 60%, #b81d36); animation: heartbeat 0.7s ease-in-out infinite; }
#timer { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
#timer.urgent { color: #e62c48; }
.pill:has(#timer.urgent) { background: linear-gradient(180deg, #fff, #ffe0e4); box-shadow: 0 0 0 3px #ff4d5e, 0 3px 0 rgba(160, 20, 40, 0.3); }
.pill:has(#timer.urgent) .ico { background: radial-gradient(circle at 35% 30%, #ff8a96, var(--red) 60%, #b81d36); }

.round-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: radial-gradient(circle at 35% 30%, #5cb2ff, var(--blue) 60%, var(--blue-dark));
  font-size: 20px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--blue-dark), 0 6px 12px rgba(0, 40, 100, 0.25);
  transition: transform 0.2s var(--spring), background 0.15s, box-shadow 0.15s;
}
.round-btn:hover { transform: scale(1.1) rotate(-6deg); }
.round-btn:active { transform: scale(0.94); }

#feed { position: absolute; top: 66px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
#feed div { padding: 4px 10px; border-radius: 10px; background: var(--panel-gloss); border: 2px solid rgba(255, 255, 255, 0.5); box-shadow: 0 3px 0 rgba(11, 79, 168, 0.6); animation: slide 0.35s var(--spring); }
#feed div.mine { border-color: var(--yellow); box-shadow: 0 3px 0 #b37d00, 0 0 14px rgba(255, 211, 77, 0.5); }
#feed .tag { margin: 0 6px; padding: 0 6px; border-radius: 6px; background: var(--yellow); color: #5a3a00; font-size: 14px; }

#weapon {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 270px;
  max-width: calc(100vw - 24px);
  padding: 6px 18px 6px 6px;
  border-radius: 999px;
  background: var(--panel-gloss);
  border: 3px solid #fff;
  box-shadow: var(--panel-shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#weapon > div:last-child { min-width: 0; flex: 1; }
#wicon {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #fff, #dcecff 75%);
  font-size: 32px;
  color: var(--blue);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(10, 60, 140, 0.18), 0 2px 0 rgba(0, 0, 0, 0.15);
}
/* Spinning ring around a weapon that is ready to fire. */
#wicon::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(var(--yellow) 0 25%, transparent 25% 50%, var(--yellow) 50% 75%, transparent 75%);
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  opacity: 0;
  transition: opacity 0.2s;
  animation: spin 2.2s linear infinite;
}
#weapon.ready #wicon::before { opacity: 1; }
#wname { font: 700 20px var(--font); text-shadow: 0 2px 0 var(--blue-deep); }
#whint { max-width: 270px; font-size: 12px; opacity: 0.88; }
#weapon.empty #wicon { background: radial-gradient(circle at 40% 30%, #fff1a8, var(--yellow) 70%); color: #8a5a00; animation: wiggle 2.4s ease-in-out infinite; }
#weapon.rolling #wicon { background: radial-gradient(circle at 40% 30%, #fff1a8, var(--yellow) 70%); animation: roll 0.09s linear infinite; }
#weapon.rolling #wname { color: var(--yellow); letter-spacing: 2px; }
#weapon.fresh { animation: bump 0.4s var(--spring); }
#weapon.ready { border-color: #fff3a2; box-shadow: var(--panel-shadow), 0 0 22px rgba(255, 211, 77, 0.45); }
#ammo { display: flex; gap: 4px; align-items: center; height: 10px; margin: 2px 0 1px; }
#ammo:empty { display: none; }
#ammo i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.7); transition: background 0.15s, transform 0.2s var(--spring); }
#ammo i.on { background: var(--yellow); border-color: #fff; box-shadow: 0 0 6px rgba(255, 211, 77, 0.8); }
#ammo b { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ffb347, var(--yellow)); box-shadow: 0 0 6px rgba(255, 211, 77, 0.6); transition: width 0.08s; }
#cooldown { margin-top: 5px; height: 4px; overflow: hidden; border-radius: 8px; background: #082a5a66; }
#readyfill { display: block; width: 100%; height: 100%; background: var(--yellow); transform-origin: left; }

#hurt { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; box-shadow: inset 0 0 200px 50px rgba(255, 40, 60, 0.65); }
#hurt.on { animation: fade 0.5s ease-out; }

/* Banner (round winner, death) */
#banner { position: fixed; left: 0; right: 0; top: 18%; z-index: 9; display: none; text-align: center; pointer-events: none; }
#banner.on { display: block; animation: drop 0.45s var(--spring); }
#btitle { font: 700 clamp(40px, 8vw, 76px)/1.1 var(--font); color: #fff; }
#btitle b { color: #7ff3ff; }
body.dead #btitle { color: #ffd34d; text-shadow: 0 3px 0 #b5321f, 3px 0 0 #b5321f, -3px 0 0 #b5321f, 0 -3px 0 #b5321f, 0 8px 14px rgba(0, 0, 0, 0.35); animation: shake 0.5s ease-out; }
#bsub { display: inline-block; margin-top: 10px; padding: 6px 18px; border-radius: 999px; background: var(--panel-gloss); border: 3px solid #fff; box-shadow: var(--panel-shadow); font: 700 clamp(16px, 3vw, 24px) var(--font); }

/* Menu */
#menu { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px 0; overflow-x: hidden; overflow-y: auto; background: radial-gradient(ellipse at center, rgba(20, 90, 170, 0.1), rgba(10, 50, 110, 0.6)); }
body.playing #menu { display: none; }
#menu .card { margin: auto; } /* centers, but stays top-aligned and scrollable when taller than the screen */
.card {
  position: relative;
  isolation: isolate;
  width: min(460px, calc(100vw - 32px));
  padding: 22px 24px 20px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08));
  border: 3px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 20px 50px rgba(0, 30, 80, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: card-in 0.6s var(--spring) both;
}
.sunburst {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 120px;
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 236, 160, 0.35) 0 9deg, transparent 9deg 18deg);
  mask-image: radial-gradient(circle, #000 0, transparent 55%);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 55%);
  animation: spin 40s linear infinite;
}
.kart-mascot { font-size: 52px; line-height: 1; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.25)); animation: mascot 1.6s ease-in-out infinite; }
h1 { margin: 4px 0 0; font: 700 clamp(48px, 12vw, 86px)/0.95 var(--font); color: var(--yellow); letter-spacing: 1px; }
h1 span { display: inline-block; animation: title-in 0.7s var(--spring) both, title-bob 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 0.06s), calc(0.9s + var(--i) * 0.11s); }
h1 span:nth-of-type(n + 5) { color: var(--orange); }
.arena-tag { display: inline-block; margin: 0 0 12px; padding: 4px 14px; border-radius: 999px; background: rgba(10, 50, 110, 0.45); border: 2px solid rgba(255, 255, 255, 0.5); font-size: 15px; }
.arena-tag:empty { display: none; }
.tag { margin: 10px 0 14px; font-size: 18px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
#animals { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
#animals button {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.25);
  font-size: 30px;
  cursor: pointer;
  transition: transform 0.25s var(--spring), background 0.15s, box-shadow 0.15s;
}
#animals button:hover { transform: translateY(-5px) rotate(-8deg) scale(1.1); background: rgba(255, 255, 255, 0.4); }
#animals button.on { border-color: #fff; background: var(--yellow); transform: translateY(-4px) scale(1.12); box-shadow: 0 4px 0 #b37d00, 0 0 18px rgba(255, 211, 77, 0.6); animation: picked 0.4s var(--spring); }
input {
  width: 100%;
  padding: 14px 16px;
  border: 3px solid #fff;
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--blue-dark);
  font: 700 19px var(--font);
  text-align: center;
  user-select: text;
  box-shadow: inset 0 3px 0 rgba(10, 60, 140, 0.12);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--yellow); box-shadow: inset 0 3px 0 rgba(10, 60, 140, 0.12), 0 0 0 4px rgba(255, 211, 77, 0.4); }
.play {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border: 3px solid #fff;
  border-radius: 16px;
  background: linear-gradient(180deg, #5df08a, #2fc95a);
  box-shadow: 0 6px 0 #1f9a42, 0 10px 20px rgba(20, 110, 50, 0.35);
  color: #fff;
  font: 700 30px var(--font);
  letter-spacing: 2px;
  text-shadow: 0 2px 0 #1f9a42;
  cursor: pointer;
  animation: breathe 1.8s ease-in-out infinite;
}
/* A glint sweeps across the play button. */
.play::after { content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent); transform: skewX(-20deg); animation: glint 2.8s ease-in-out infinite; }
.play:hover { background: linear-gradient(180deg, #74ff9d, #3ddc68); }
.play:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f9a42; animation: none; }
/* Arena picker: one card per public room, with a live count of people racing there. */
.pick-label { margin: 0 0 6px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.85; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.arena-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.arena-cards button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 74px;
  padding: 8px 4px 6px;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  color: #fff;
  font: 700 12px/1.1 var(--font);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.25s var(--spring), border-color 0.15s, box-shadow 0.15s;
}
.arena-cards .icon { font-size: 26px; line-height: 1; }
.arena-cards .count { position: absolute; top: -9px; right: -6px; padding: 1px 6px; border-radius: 999px; background: var(--green); border: 2px solid #fff; font: 700 11px var(--font); font-style: normal; box-shadow: 0 2px 0 #1f9a42; }
.arena-cards .count:empty { display: none; }
.arena-cards .arena-island { background: linear-gradient(160deg, #4fdc3c, #2aa6e0); }
.arena-cards .arena-desert { background: linear-gradient(160deg, #f3c06f, #d9773f); }
.arena-cards .arena-snow { background: linear-gradient(160deg, #e9f4ff, #7cc4ee); color: #164375; text-shadow: none; }
.arena-cards .arena-mix { background: linear-gradient(160deg, #b58cff, #ff8fd1); }
.arena-cards button:hover { transform: translateY(-4px) rotate(-3deg) scale(1.05); }
.arena-cards button.on { border-color: #fff; transform: translateY(-4px) scale(1.07); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2), 0 0 0 3px var(--yellow), 0 0 18px rgba(255, 211, 77, 0.65); }
.arena-cards button:disabled { cursor: default; opacity: 0.5; transform: none; }
.arena-cards button.on:disabled { opacity: 1; transform: translateY(-4px) scale(1.07); }
[hidden] { display: none !important; }
/* Public Quick Match waiting lobby. */
.quick-lobby {
  width: min(510px, calc(100vw - 28px));
  padding: 24px;
  overflow: hidden;
  border: 2px solid #99c8ff80;
  background: radial-gradient(ellipse at 50% 0, #5654a8b3, transparent 58%), linear-gradient(155deg, #153b70f5, #111e43f5);
  box-shadow: 0 24px 80px #06152c80, inset 0 1px 0 #ffffff30;
}
.quick-lobby::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, #81e9ff, #b89aff, #ffd34d); }
.quick-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; letter-spacing: 1.6px; }
.quick-live { display: inline-flex; align-items: center; gap: 7px; color: #a5f5e2; }
.quick-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #70f5bc; box-shadow: 0 0 10px #70f5bc; }
.quick-public { color: #a8bada; }
.quick-radar { position: relative; display: grid; place-items: center; width: 94px; height: 94px; margin: 20px auto 14px; border: 1px solid #a0b8ff55; border-radius: 50%; background: radial-gradient(circle, #87b6ff40, #87b6ff08); }
.quick-radar span { font-size: 43px; filter: drop-shadow(0 7px 8px #06152c80); animation: mascot 2s ease-in-out infinite; }
.quick-radar i { position: absolute; inset: -9px; border: 1px solid #a0b8ff55; border-radius: 50%; animation: quick-pulse 2.4s ease-out infinite; }
.quick-radar i + i { animation-delay: 1.2s; }
.quick-lobby h2 { margin: 0; font-size: clamp(25px, 6vw, 33px); line-height: 1.15; letter-spacing: -0.5px; }
.quick-status { min-height: 20px; margin: 9px 0 20px; color: #bfcee9; font-size: 14px; }
.quick-arena { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border: 1px solid #accbff40; border-radius: 15px; background: linear-gradient(100deg, #74baff20, #b896ff15); text-align: left; }
#quickarenaicon { font-size: 30px; }
.quick-arena div { flex: 1; }
.quick-arena small { display: block; margin-bottom: 3px; color: #adc5eb; font-size: 9px; letter-spacing: 1.6px; }
.quick-arena b { font-size: 17px; }
.quick-check { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #6ff3bd20; color: #91f1c4; }
.quick-roster-label { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; font-size: 14px; }
#quickcount { color: #b8c9e8; font-size: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0; list-style: none; text-align: left; }
.quick-grid li { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 9px 10px; border: 1px solid #abc6f233; border-radius: 12px; background: #c1d9ff0a; }
.quick-grid li.self { background: #ffd34d14; border-color: #ffd34d80; }
.quick-grid li.ready { background: #70f5bc0c; border-color: #70f5bc55; }
.quick-avatar { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #b2cbff12; font-size: 23px; }
.quick-grid li > div { min-width: 0; }
.quick-grid b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.quick-grid small { display: block; margin-top: 3px; color: #99d8c6; font-size: 8px; letter-spacing: 0.7px; }
.quick-grid .self small { color: #ffe48c; }
.quick-grid .open { border-style: dashed; color: #94a9ce; background: transparent; }
.quick-grid .open small { color: #8299bf; letter-spacing: 0; font-size: 10px; }
.quick-launch { display: flex; justify-content: space-between; align-items: center; margin-top: 19px; font-size: 14px; }
.quick-launch > b { color: #ffe38b; font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1; }
.quick-launch small { margin-left: 3px; font-size: 14px; }
.quick-progress { height: 6px; margin-top: 10px; border-radius: 9px; background: #a7c6ff20; overflow: hidden; }
.quick-progress i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b59aff, #80dfff, #ffe38b); transform: scaleX(0); transform-origin: left; }
.quick-hint { max-width: 340px; margin: 13px auto 16px; color: #b1c3e2; font-size: 12px; line-height: 1.5; }
#quickcancel { width: 100%; padding: 11px; color: #d3def2; border: 1px solid #a6c0ec55; background: #afcaff08; }
#quickcancel:hover { background: #afcaff20; }
#quickcancel:focus-visible { outline: 3px solid #ffe38b; outline-offset: 3px; }
#quickcancel:disabled { opacity: 0.5; cursor: wait; }
.quick-lobby.matched .quick-radar { border-color: #70f5bc88; background: radial-gradient(circle, #70f5bc30, transparent); }
.quick-lobby.matched h2 { color: #b4ffdb; }
@keyframes quick-pulse { from { transform: scale(0.85); opacity: 0.8; } to { transform: scale(1.25); opacity: 0; } }
@media (max-width: 380px), (max-height: 760px) {
  .quick-lobby { padding: 18px; }
  .quick-radar { width: 64px; height: 64px; margin: 14px auto 12px; }
  .quick-radar span { font-size: 34px; }
  .quick-status { margin-bottom: 12px; }
  .quick-roster-label { margin-top: 13px; }
  .quick-grid { gap: 6px; }
  .quick-grid li { padding: 7px; gap: 7px; }
  .quick-launch { margin-top: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .quick-lobby, .quick-radar span, .quick-radar i { animation: none; }
}
/* Private room lobby. */
.party { text-align: center; }
.party-code { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 2px 0 6px; }
#partycode { font: 700 54px/1 var(--font); letter-spacing: 8px; color: var(--yellow); text-shadow: 0 3px 0 #b36b00, 2px 0 0 #b36b00, -2px 0 0 #b36b00, 0 -2px 0 #b36b00, 0 6px 12px rgba(0, 0, 0, 0.3); }
.party-hint { margin: 0 0 14px; font-size: 14px; opacity: 0.9; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
#partylist { list-style: none; margin: 0 0 6px; padding: 6px; border-radius: 14px; background: rgba(10, 50, 110, 0.35); border: 2px solid rgba(255, 255, 255, 0.4); text-align: left; }
#partylist li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 10px; animation: slide 0.35s var(--spring); }
#partylist li + li { margin-top: 4px; }
#partylist li.me { background: rgba(255, 211, 77, 0.2); box-shadow: inset 0 0 0 1px rgba(255, 211, 77, 0.6); }
#partylist .avatar { font-size: 24px; }
#partylist b { flex: 1; font-size: 16px; }
#partylist i { font-style: normal; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--yellow); color: #5a3a00; }
.party-wait { margin: 14px 0 4px; font-size: 16px; animation: breathe 1.6s ease-in-out infinite; }
#partyleave { margin-top: 12px; }
/* Private rooms: create one, or join friends with a code. */
.private-row { display: flex; gap: 8px; margin-top: 14px; }
.ghost { flex: none; padding: 9px 12px; border: 2px solid rgba(255, 255, 255, 0.75); border-radius: 12px; background: rgba(10, 50, 110, 0.4); color: #fff; font: 700 14px var(--font); cursor: pointer; }
.ghost:hover { background: rgba(10, 50, 110, 0.6); }
.private-row #create { flex: 1; }
#code { width: 86px; min-width: 0; padding: 8px 6px; font-size: 16px; letter-spacing: 3px; border-width: 2px; border-radius: 12px; }
.room-err { min-height: 0; margin: 8px 0 0; color: #ffe0e4; font-size: 14px; text-shadow: 0 1px 3px rgba(120, 0, 20, 0.6); }
.room-err:empty { display: none; }
/* In-game room badge; for private rooms it copies an invite link. */
#roombadge { position: absolute; right: 22px; bottom: 22px; max-width: 46vw; padding: 7px 14px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.8); background: var(--panel-gloss); color: #fff; font: 700 14px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--panel-shadow); pointer-events: none; }
#roombadge:empty { display: none; }
#roombadge.private { pointer-events: auto; cursor: pointer; border-color: #9ef5ff; }
#roombadge.private:hover { transform: scale(1.05); }
.controls { margin: 16px 0 0; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }

#offline { position: fixed; top: 70px; left: 50%; z-index: 20; display: none; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: var(--red); border: 3px solid #fff; box-shadow: 0 4px 0 #a3243a; }
#offline.on { display: block; }
#offline.action { cursor: pointer; }

/* Action feedback stays at the edges so the driving line remains readable. */
#speedfx { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(ellipse, transparent 48%, #d8faff55 100%), repeating-conic-gradient(from 4deg at 50% 55%, transparent 0deg 14deg, #e5faff70 14.2deg 14.5deg, transparent 14.7deg 30deg); mask-image: radial-gradient(ellipse, transparent 45%, #000 100%); }
#flash { position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0; }
#confetti { position: fixed; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
#confetti i { position: absolute; top: 0; border-radius: 2px; }
#motion { top: 64px; font: 700 14px var(--font); }
#feed { top: 120px; }
#motion[aria-pressed="true"] { background: #315c83; }

/* Circular speedometer: the ring fills through 270° as speed rises. */
#drive { --p: 0; --gauge: #9ef5ff; position: absolute; left: 22px; bottom: 22px; width: 124px; height: 124px; display: grid; place-items: center; font-size: 11px; }
#drive::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #3aa4ff, #1462c8 60%, #0c4598); border: 3px solid #fff; box-shadow: var(--panel-shadow); }
#drive::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: conic-gradient(from 225deg, var(--gauge) calc(var(--p) * 270deg), rgba(255, 255, 255, 0.16) 0 270deg, transparent 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
  filter: drop-shadow(0 0 4px var(--gauge));
  transition: filter 0.2s;
}
#drive.drifting { --gauge: #ffb347; }
#drive.max { --gauge: #ffd34d; }
#drive.max::before { box-shadow: var(--panel-shadow), 0 0 22px rgba(255, 211, 77, 0.55); }
#drive .gauge { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; margin-top: -6px; }
#drive strong { font-size: 36px; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 var(--blue-deep); }
#drive .gauge span { opacity: 0.8; letter-spacing: 1px; }
#drive b { position: absolute; z-index: 1; bottom: -9px; left: 50%; transform: translateX(-50%); padding: 1px 9px; border-radius: 10px; background: var(--blue-deep); border: 2px solid #fff; white-space: nowrap; font-size: 10px; letter-spacing: 0.6px; }

#protection { position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%); padding: 5px 14px; border-radius: 20px; color: #c9fbff; background: #124788db; border: 2px solid #97f6ff; box-shadow: 0 0 14px rgba(95, 227, 255, 0.4); font-size: 12px; opacity: 0; transition: opacity 0.2s; }
#protection.on { opacity: 1; }
#notice { position: absolute; top: 23%; left: 50%; width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 6px 14px; border-radius: 14px; background: #103964d9; border: 2px solid rgba(255, 255, 255, 0.35); transform: translate(-50%, 8px) scale(0.9); opacity: 0; transition: opacity 0.15s, transform 0.3s var(--spring); text-align: center; font-size: clamp(16px, 3vw, 24px); text-shadow: 0 2px 2px #164375, 0 0 12px #164375; }
#notice.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
#hitmarker { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); opacity: 0; font: 700 32px system-ui; color: white; text-shadow: 0 0 6px #164375; }
#hitmarker.on { opacity: 1; animation: hit-pop 0.14s ease-out; }
#hitmarker.kill { color: #ffd34d; font-size: 46px; }
#damage-direction { position: absolute; left: 50%; top: 50%; width: 200px; height: 200px; opacity: 0; color: #ff6577; text-shadow: 0 2px 3px #6d1230; }
#damage-direction span { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font: 700 30px system-ui; }
#damage-readout { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); opacity: 0; color: #fff; background: #b9183fe6; border: 2px solid #fff; border-radius: 18px; padding: 3px 12px; font-size: 18px; }
#damage-direction.on, #damage-readout.on { opacity: 1; }
.damage-number { position: absolute; transform: translate(-50%, -50%); font: 700 26px var(--font); text-shadow: 0 2px 0 #12355d, 2px 0 0 #12355d, -2px 0 0 #12355d, 0 -2px 0 #12355d, 0 4px 6px rgba(0, 0, 0, 0.3); }
.damage-number.big { font-size: 32px; text-shadow: 0 3px 0 #b5321f, 2px 0 0 #b5321f, -2px 0 0 #b5321f, 0 -2px 0 #b5321f, 0 0 16px rgba(255, 180, 60, 0.8); }

/* Slammed-down words: kills, countdown, GO! */
#stamp { position: absolute; left: 50%; top: 34%; z-index: 2; opacity: 0; text-align: center; white-space: nowrap; font: 700 clamp(44px, 9vw, 92px)/1 var(--font); }
#stamp::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: 3.2em;
  height: 3.2em;
  margin: -1.6em 0 0 -1.6em;
  background: repeating-conic-gradient(rgba(255, 220, 120, 0.5) 0 10deg, transparent 10deg 20deg);
  mask-image: radial-gradient(circle, #000 15%, transparent 65%);
  -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 65%);
  animation: spin 6s linear infinite;
}
.stamp-main { letter-spacing: 1px; text-shadow: 0 4px 0 #8a2a12, 3px 0 0 #8a2a12, -3px 0 0 #8a2a12, 0 -3px 0 #8a2a12, 3px 3px 0 #8a2a12, -3px 3px 0 #8a2a12, 0 10px 18px rgba(0, 0, 0, 0.35); }
.stamp-sub { margin-top: 6px; font-size: 0.32em; color: #fff; text-shadow: 0 2px 0 var(--blue-deep), 2px 0 0 var(--blue-deep), -2px 0 0 var(--blue-deep), 0 -2px 0 var(--blue-deep); }
.score-fly { position: fixed; left: 50%; top: 40%; z-index: 9; pointer-events: none; font: 700 56px var(--font); color: var(--yellow); text-shadow: 0 4px 0 #b36b00, 3px 0 0 #b36b00, -3px 0 0 #b36b00, 0 -3px 0 #b36b00, 0 8px 14px rgba(0, 0, 0, 0.3); }

button { transition: background 0.15s, box-shadow 0.15s; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }

body.reduced-motion #speedfx { display: none; }
body.reduced-motion #weapon.fresh,
body.reduced-motion #banner.on,
body.reduced-motion h1 span,
body.reduced-motion .card,
body.reduced-motion .sunburst,
body.reduced-motion .kart-mascot,
body.reduced-motion .quick-radar span,
body.reduced-motion .quick-radar i,
body.reduced-motion .play,
body.reduced-motion .party-wait,
body.reduced-motion .play::after,
body.reduced-motion #stamp::before,
body.reduced-motion #weapon.empty #wicon,
body.reduced-motion #weapon.rolling #wicon,
body.reduced-motion #health.critical,
body.reduced-motion #health.critical .ico,
body.reduced-motion.dead #btitle { animation: none; }
body.reduced-motion #notice { transition: opacity 0.15s; }

@keyframes fade { from { opacity: 1; } to { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateX(24px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-30px) scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes bump { 0% { transform: translateX(-50%) scale(1); } 40% { transform: translateX(-50%) scale(1.15); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.15); } }
@keyframes critical-glow { 50% { box-shadow: 0 0 0 3px #ff4d5e, 0 0 36px #ff4d5ecc; } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-6deg); } }
@keyframes roll { 0% { transform: translateY(-3px); } 50% { transform: translateY(3px); } 100% { transform: translateY(-3px); } }
@keyframes shake { 0%, 100% { transform: none; } 15% { transform: translate(-8px, 2px) rotate(-3deg); } 30% { transform: translate(7px, -2px) rotate(2deg); } 45% { transform: translate(-5px, 1px) rotate(-1deg); } 60% { transform: translate(3px, 0); } }
@keyframes hit-pop { from { transform: translate(-50%, -50%) scale(1.6); } to { transform: translate(-50%, -50%) scale(1); } }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes title-in { from { opacity: 0; transform: translateY(-60px) scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes title-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-3deg); } }
@keyframes mascot { 0%, 100% { transform: translateX(-6px) rotate(-4deg); } 50% { transform: translateX(6px) translateY(-4px) rotate(3deg); } }
@keyframes picked { 0% { transform: scale(0.85); } 100% { transform: translateY(-4px) scale(1.12); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes glint { 0%, 55% { left: -60%; } 85%, 100% { left: 130%; } }

@media (max-width: 700px) {
  #roombadge { right: 10px; bottom: 96px; font-size: 12px; }
  .arena-cards { gap: 6px; }
  .arena-cards button { min-height: 66px; font-size: 11px; }
  #rankbox { width: 160px; font-size: 13px; }
  #rank { font-size: 18px; }
  .pill { font-size: 17px; padding: 4px 8px 4px 4px; gap: 4px; }
  #feed { display: none; }
  #topbar { left: auto; right: 66px; transform: none; gap: 5px; }
  .pill .ico { width: 25px; height: 25px; font-size: 14px; }
  .bar { width: 55px; }
  #hptext { display: none; }
  #drive { width: 98px; height: 98px; font-size: 9px; }
  #drive strong { font-size: 27px; }
  #weapon { min-width: 250px; }
  #wname { font-size: 17px; }
  #wicon { width: 52px; height: 52px; font-size: 28px; }
}
@media (max-width: 420px) {
  #notice { top: 34%; }
  #rankbox { width: 128px; }
  #topbar { gap: 3px; }
  .bar { width: 35px; }
  #timer { min-width: 30px; }
  .rank-delta { top: 4px; font-size: 13px; }
}
@media (max-width: 580px) {
  #drive { bottom: 108px; left: 10px; }
}
@media (pointer: coarse) and (max-height: 600px) {
  #weapon { bottom: 18px; }
  #drive { bottom: 142px; }
  #protection { bottom: 108px; }
  #board li:nth-child(n+5) { display: none; }
}
/* Short screens: drop decoration so the whole menu fits. */
@media (max-height: 820px) {
  .kart-mascot, .tag { display: none; }
  .card { padding-top: 16px; }
}

/* ───────────── Touch screens ───────────── */
/* The menu still scrolls with a finger even though the page itself blocks gestures. */
#menu { touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch .keys-only { display: none; }
body.touch { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* Keep HUD clear of notches and the home indicator. */
#hud { top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px); bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px); }

#touch { display: none; }
body.touch #touch { display: block; }
#touch > * { position: absolute; pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
#steer { left: 16px; bottom: 16px; display: flex; gap: 8px; width: 196px; height: 100px; }
#steer span, #tbrake, #tfire { display: grid; place-items: center; border: 3px solid rgba(255, 255, 255, 0.85); color: #fff; font: 700 15px var(--font); text-shadow: 0 2px 0 var(--blue-deep); box-shadow: 0 4px 0 rgba(11, 79, 168, 0.75), 0 6px 14px rgba(0, 40, 100, 0.25); transition: transform 0.08s, background 0.08s; }
#steer span { flex: 1; border-radius: 26px; background: rgba(31, 139, 255, 0.55); font-size: 36px; }
#steer span.on, #tbrake.on { transform: translateY(3px) scale(0.96); background: rgba(255, 211, 77, 0.85); box-shadow: 0 1px 0 rgba(11, 79, 168, 0.75); }
#tfire { right: 16px; bottom: 16px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #ff8a6b, #ff4d5e 60%, #c22740); align-content: center; gap: 0; }
#tfire span { font-size: 38px; line-height: 1; text-shadow: none; }
#tfire b { font-size: 13px; letter-spacing: 1px; }
#tfire.on { transform: scale(0.92); background: radial-gradient(circle at 40% 30%, #ffd34d, #ff8a3d 60%, #d4561c); }
#tbrake { right: 138px; bottom: 14px; width: 76px; height: 76px; border-radius: 50%; background: rgba(10, 50, 110, 0.6); font-size: 12px; letter-spacing: 0.5px; }

/* Compact HUD that leaves the corners to the thumbs. */
body.touch #rankbox { width: 150px; font-size: 12px; }
body.touch #rank { font-size: 17px; padding: 2px 10px; margin-bottom: 4px; }
body.touch #board li { padding: 1px 4px; gap: 6px; }
body.touch #board .pos { width: 18px; height: 18px; font-size: 11px; }
body.touch #board li:nth-child(n + 4):not(.me) { display: none; }
body.touch #network-ping { margin-top: 4px; padding: 3px 8px; font-size: 10px; }
body.touch #topbar { gap: 6px; }
body.touch .pill { font-size: 17px; padding: 3px 10px 3px 4px; gap: 5px; }
body.touch .pill .ico { width: 26px; height: 26px; font-size: 14px; }
body.touch .bar { width: 90px; height: 13px; }
body.touch .round-btn { width: 38px; height: 38px; font-size: 16px; border-width: 2px; }
body.touch #motion { top: 54px; font-size: 12px; }
body.touch #feed { top: 100px; font-size: 12px; }
body.touch #feed div:nth-child(n + 4) { display: none; }
body.touch #drive { left: 16px; bottom: 128px; width: 74px; height: 74px; font-size: 8px; }
body.touch #drive strong { font-size: 22px; }
body.touch #drive b { display: none; }
body.touch #weapon { bottom: 14px; min-width: 0; width: auto; max-width: calc(100vw - 480px); padding: 4px 14px 4px 4px; gap: 8px; }
body.touch #wicon { width: 44px; height: 44px; font-size: 24px; }
body.touch #wname { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #whint { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #protection { bottom: 80px; }
body.touch #roombadge { top: 54px; right: auto; bottom: auto; left: 50%; transform: translateX(-50%); max-width: 50vw; padding: 3px 10px; font-size: 11px; }
body.touch #roombadge.private:hover { transform: translateX(-50%); }
body.touch .label { font-size: 13px; }
body.touch #stamp { top: 30%; }
/* Full-screen blur, masks and huge shadows cost phones a lot of fill rate for little gain. */
body.touch #speedfx { display: none; }
body.touch #hurt { box-shadow: inset 0 0 90px 24px rgba(255, 40, 60, 0.6); }
body.touch .card { backdrop-filter: none; -webkit-backdrop-filter: none; }
body.touch #maincard, body.touch .party { background: linear-gradient(180deg, rgba(20, 90, 180, 0.72), rgba(12, 60, 140, 0.72)); }
body.touch .play::after { display: none; }
body.touch .round-btn:hover, body.touch .arena-cards button:hover, body.touch #animals button:hover { transform: none; }

/* Narrow landscape phones: shrink the weapon panel down to its icon and name. */
@media (max-width: 760px) {
  body.touch #weapon { max-width: calc(100vw - 440px); }
  body.touch #whint, body.touch #cooldown { display: none; }
  body.touch #steer { width: 170px; height: 88px; }
  body.touch #tfire { width: 96px; height: 96px; }
  body.touch #tbrake { right: 122px; width: 66px; height: 66px; }
  body.touch #drive { bottom: 114px; }
}

/* Phones play in landscape only: held upright, a full-screen prompt asks to turn the phone. */
#rotate { display: none; }
@media (orientation: portrait) {
  body.touch #rotate { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; background: radial-gradient(ellipse at center, #1f8bff, #0a3f8f); touch-action: none; }
  body.touch #rotate b { font: 700 28px var(--font); color: var(--yellow); text-shadow: 0 3px 0 #b36b00; }
  body.touch #rotate p { max-width: 280px; margin: 0; font-size: 16px; opacity: 0.9; }
  body.touch .rotate-phone { font-size: 72px; line-height: 1; animation: rotate-phone 2s ease-in-out infinite; }
  /* Nothing behind the prompt needs drawing or animating. */
  body.touch #menu, body.touch #hud { visibility: hidden; }
}
@keyframes rotate-phone { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

/* Short landscape screens (phones on their side): the menu splits into two columns. */
.menu-brand, .menu-form { position: relative; }
@media (orientation: landscape) and (max-height: 540px) {
  #menu { padding: 10px 0; }
  #maincard { display: flex; align-items: center; gap: 18px; overflow: hidden; width: min(820px, calc(100vw - 24px)); padding: 14px 18px; text-align: center; }
  #maincard .menu-brand { flex: 0 0 38%; }
  #maincard .menu-form { flex: 1; min-width: 0; }
  #maincard .sunburst { left: 19%; top: 50%; }
  #maincard h1 { font-size: clamp(38px, 9vh, 56px); }
  #maincard .tag { display: block; margin: 6px 0 10px; font-size: 14px; }
  #animals { gap: 6px; margin-bottom: 0; }
  #animals button { width: 44px; height: 44px; font-size: 24px; border-radius: 12px; }
  .arena-cards { margin-bottom: 6px; }
  .arena-cards button { min-height: 56px; padding: 6px 4px 4px; }
  .arena-cards .icon { font-size: 20px; }
  .arena-tag { margin-bottom: 8px; font-size: 13px; }
  input { padding: 9px 12px; font-size: 17px; }
  .play { margin-top: 8px; padding: 9px; font-size: 24px; }
  .private-row { margin-top: 8px; }
  .controls { margin-top: 8px; font-size: 12px; }
  .quick-lobby, .party { width: min(640px, calc(100vw - 24px)); }
  .quick-lobby { padding: 14px 18px; }
  .quick-radar, .quick-hint { display: none; }
  .quick-status { margin: 4px 0 10px; }
  .quick-roster-label { margin: 10px 0 6px; }
  .quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .quick-grid li { padding: 5px 7px; gap: 6px; }
  .quick-avatar { width: 26px; height: 26px; font-size: 18px; }
  .quick-launch { margin-top: 10px; }
  #quickcancel { margin-top: 10px; padding: 8px; }
  #partycode { font-size: 40px; }
}
/* Narrow portrait phones: keep the six animals on one row. */
@media (max-width: 420px) {
  #maincard { padding: 18px 14px 16px; }
  #animals { gap: 6px; }
  #animals button { width: 46px; height: 46px; font-size: 25px; border-radius: 13px; }
}

/* ───────────── Pause ───────────── */
/* Pause takes the top-right corner; sound and FX move down one slot. */
#pause { top: 10px; }
/* Two white bars, drawn so they look the same on every phone's font. */
#pause::before { content: ''; position: absolute; left: 50%; top: 50%; width: 30%; height: 38%; transform: translate(-50%, -50%); background: linear-gradient(90deg, #fff 0 35%, transparent 35% 65%, #fff 65%); border-radius: 2px; }
#mute { top: 64px; }
#motion { top: 118px; }
#feed { top: 174px; }
body.touch #pause { top: 10px; }
body.touch #mute { top: 54px; }
body.touch #motion { top: 98px; }
body.touch #feed { top: 142px; }
body.paused #touch { visibility: hidden; }

#pausemenu { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: rgba(6, 30, 70, 0.55); touch-action: pan-y; }
.pause-card { width: min(380px, calc(100vw - 32px)); background: linear-gradient(180deg, rgba(20, 90, 180, 0.94), rgba(12, 60, 140, 0.94)); backdrop-filter: none; -webkit-backdrop-filter: none; animation-duration: 0.35s; }
.pause-card h2 { margin: 0; font: 700 40px/1 var(--font); color: var(--yellow); letter-spacing: 2px; text-shadow: 0 3px 0 #b36b00; }
.pause-note { margin: 10px 0 4px; font-size: 14px; opacity: 0.9; }
.pause-card .play { font-size: 26px; padding: 11px; }
.pause-row { display: flex; gap: 8px; margin-top: 12px; }
.pause-row .ghost { flex: 1; padding: 10px; }
.pause-card .exit { width: 100%; margin-top: 10px; padding: 11px; border-color: #ffb3bc; background: rgba(160, 20, 50, 0.45); }
.pause-card .exit:hover { background: rgba(160, 20, 50, 0.65); }
@media (max-height: 420px) {
  .pause-card { padding: 14px 18px; }
  .pause-card h2 { font-size: 30px; }
  .pause-note { font-size: 12px; margin: 6px 0 0; }
  .pause-card .play { margin-top: 8px; padding: 7px; font-size: 22px; }
  .pause-row { margin-top: 8px; }
  .pause-row .ghost, .pause-card .exit { padding: 7px; margin-top: 8px; }
  .pause-row .ghost { margin-top: 0; }
}
