/* ===== Responsive UI scale =====
   js/uiscale.js sets --ui from the screen size (1 on desktop ... 0.5 on phones). Every pixel size in this
   file is written as calc(N * var(--u)) so the whole interface - text, buttons, panels, borders - scales
   together. Touch controls use --ut, which never drops below 0.85 so they stay finger-sized. */
:root { --ui: 1; --u: calc(var(--ui) * 1px); --ut: calc(max(var(--ui), 0.85) * 1px); }
html { font-size: calc(16 * var(--u)); }

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #071e12;
  font-family: 'Inter', sans-serif;
  touch-action: none;
}
#game-canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
}
/* Floating HUD Layer */
#ui-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.interactive {
  pointer-events: auto;
}
/* Floating 3D-projected Badges */
.world-label {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
  transition: opacity 0.15s ease;
  will-change: transform, left, top;
}
/* Custom floating combat text animation */
@keyframes floatUpFade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -90%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(0.95); }
}
.floating-callout {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  animation: floatUpFade 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  text-shadow: 0 calc(3 * var(--u)) calc(10 * var(--u)) rgba(0,0,0,0.65);
  white-space: nowrap;
  z-index: 25;
}
/* Virtual Joystick Styling */
#joystick-zone {
  touch-action: none;
}
.mono-num {
  font-family: 'JetBrains Mono', monospace;
}

/* ===================== Minimal HUD ===================== */
/* Small, translucent, out of the way: the court is the star. */
#ui-layer { padding: calc(8 * var(--u)) calc(10 * var(--u)); }

.hud-top {
  position: relative;
  display: flex; align-items: flex-start; justify-content: space-between;
  width: 100%;
}
.hud-text-btn {
  background: none; border: 0; padding: calc(2 * var(--u)) calc(4 * var(--u));
  color: rgba(255,255,255,0.7); font-size: calc(10 * var(--u)); font-weight: 700; letter-spacing: 0.08em;
  text-shadow: 0 calc(1 * var(--u)) calc(3 * var(--u)) rgba(0,0,0,0.8); cursor: pointer;
}
.hud-text-btn:hover { color: #d9f99d; }
.hud-right { position: relative; display: flex; align-items: center; gap: calc(4 * var(--u)); }
.hud-icon {
  width: calc(24 * var(--u)); height: calc(24 * var(--u)); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35); border: 0; color: rgba(255,255,255,0.85); cursor: pointer;
}
.hud-icon:hover { background: rgba(0,0,0,0.6); }

/* Compact scoreboard */
#scoreboard {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  padding: calc(3 * var(--u)) calc(12 * var(--u)) calc(4 * var(--u));
  background: rgba(0,0,0,0.4);
  border-radius: calc(10 * var(--u));
  text-align: center; white-space: nowrap; line-height: 1;
}
.sb-row { display: flex; align-items: center; gap: calc(6 * var(--u)); }
.sb-name { font-size: calc(10 * var(--u)); font-weight: 800; letter-spacing: 0.08em; color: rgba(255,255,255,0.75); }
.sb-cpu { color: #67e8f9; }
.sb-score { font-size: calc(16 * var(--u)); font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; min-width: calc(10 * var(--u)); }
.sb-sep { color: rgba(255,255,255,0.4); font-size: calc(12 * var(--u)); }
.sb-serve { width: calc(6 * var(--u)); height: calc(6 * var(--u)); border-radius: 50%; background: #a3e635; box-shadow: 0 0 calc(5 * var(--u)) #a3e635; }
.sb-serve.hidden { display: none; }
.sb-sub { margin-top: calc(2 * var(--u)); font-size: calc(9 * var(--u)); color: rgba(255,255,255,0.5); font-variant-numeric: tabular-nums; }
.sb-sub #rally-count { color: #fde047; font-weight: 700; }

/* Settings dropdown */
.hud-panel {
  position: absolute; top: calc(30 * var(--u)); right: 0; width: calc(170 * var(--u)); padding: calc(6 * var(--u));
  background: rgba(10, 14, 22, 0.88); border-radius: calc(10 * var(--u));
  z-index: 30;
}
.hud-menu-item {
  width: 100%; padding: calc(5 * var(--u)) calc(8 * var(--u)); text-align: left;
  background: rgba(255,255,255,0.06); border: 0; border-radius: calc(6 * var(--u));
  color: #fff; font-size: calc(11 * var(--u)); font-weight: 700;
}
.hud-menu-item:hover { background: rgba(255,255,255,0.14); }
.hud-menu-item option { background: #0f172a; color: #fff; }
.hud-panel-hint { padding: calc(4 * var(--u)) calc(2 * var(--u)) 0; font-size: calc(9 * var(--u)); line-height: 1.35; color: rgba(255,255,255,0.45); }

/* Serve / point banner */
#banner-title.hud-banner {
  --accent: #a3e635;
  padding: calc(4 * var(--u)) calc(14 * var(--u));
  background: rgba(0,0,0,0.45);
  border-radius: calc(8 * var(--u));
  border-bottom: calc(2 * var(--u)) solid var(--accent);
  color: #fff; font-weight: 800; font-size: calc(14 * var(--u)); letter-spacing: 0.06em;
}
.hud-banner-sub {
  margin-top: calc(4 * var(--u)); padding: calc(1 * var(--u)) calc(8 * var(--u)); border-radius: calc(6 * var(--u)); background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.75); font-size: calc(11 * var(--u)); font-weight: 500;
  text-shadow: 0 calc(1 * var(--u)) calc(3 * var(--u)) rgba(0,0,0,0.9);
}

/* Floating callouts: just text */
.floating-callout { font-size: calc(12 * var(--u)); }

/* YOU marker + swing meter */
.you-tag {
  font-size: calc(9 * var(--u)); font-weight: 900; letter-spacing: 0.1em; color: #a3e635;
  text-shadow: 0 calc(1 * var(--u)) calc(3 * var(--u)) rgba(0,0,0,0.9);
}
.swing-meter { width: calc(40 * var(--u)); height: calc(4 * var(--u)); border-radius: calc(2 * var(--u)); background: rgba(0,0,0,0.5); overflow: hidden; }
#swing-meter-fill { height: 100%; background: #a3e635; }

/* Touch controls: translucent, compact, touch screens only */
.touch-controls { display: flex; align-items: flex-end; justify-content: space-between; width: 100%; }
@media (hover: hover) and (pointer: fine) {
  .touch-controls { display: none; }
}
#joystick-zone {
  position: relative; width: calc(96 * var(--ut)); height: calc(96 * var(--ut)); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); border: calc(1.5 * var(--ut)) solid rgba(255,255,255,0.25);
  margin: 0 0 calc(4 * var(--ut)) calc(6 * var(--ut));
}
#joystick-knob { width: calc(36 * var(--ut)); height: calc(36 * var(--ut)); border-radius: 50%; background: rgba(255,255,255,0.55); }
.action-cluster { position: relative; width: calc(170 * var(--u)); height: calc(112 * var(--u)); margin: 0 calc(4 * var(--u)) calc(4 * var(--u)) 0; }
.touch-btn {
  position: absolute; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3); border: calc(2 * var(--ut)) solid; color: #fff;
  font-size: calc(10 * var(--ut)); font-weight: 800; letter-spacing: 0.05em;
  transition: transform 0.06s ease, background 0.06s ease;
}
.touch-btn:active, .touch-btn.active-press { transform: scale(0.92); background: rgba(255,255,255,0.18); }
.btn-swing { right: 0; bottom: 0; width: calc(66 * var(--ut)); height: calc(66 * var(--ut)); border-color: rgba(163,230,53,0.85); font-size: calc(11 * var(--ut)); }
.btn-smash { right: calc(74 * var(--ut)); bottom: 0; width: calc(50 * var(--ut)); height: calc(50 * var(--ut)); border-color: rgba(251,146,60,0.85); }
.btn-lob   { right: calc(60 * var(--ut)); bottom: calc(58 * var(--ut)); width: calc(46 * var(--ut)); height: calc(46 * var(--ut)); border-color: rgba(103,232,249,0.85); }

/* ===================== Main menu ===================== */
/* While the menu is open, the in-game HUD is hidden so the arena shot stays clean. */
body.in-menu #ui-layer,
body.in-menu #world-labels-container,
body.in-menu #callouts-container { display: none; }

#main-menu {
  position: absolute; inset: 0; z-index: 50; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif; color: #0f1f4a;
  background: radial-gradient(ellipse at 50% 55%, rgba(18,60,150,.35) 0%, rgba(8,28,80,.72) 100%);
  -webkit-backdrop-filter: blur(calc(4 * var(--u))); backdrop-filter: blur(calc(4 * var(--u)));
}
#main-menu.hidden { display: none; }
#main-menu button { font-family: inherit; }
#main-menu .hidden { display: none !important; }

/* centre column: logo + button stack */
.mm-center { display: flex; flex-direction: column; align-items: center; gap: calc(18 * var(--u)); width: min(calc(380 * var(--u)), 90vw); margin-top: calc(-10 * var(--u)); }
.mm-logo { position: relative; text-align: center; }
.mm-logo-art { position: absolute; right: calc(-92 * var(--u)); top: calc(-26 * var(--u)); filter: drop-shadow(0 calc(4 * var(--u)) 0 rgba(15,31,74,.5)); }
.menu-title { font-size: clamp(calc(44 * var(--u)), 7.6vh, calc(76 * var(--u))); font-weight: 700; line-height: .9; color: #fff; letter-spacing: .01em;
  -webkit-text-stroke: calc(10 * var(--u)) #0f1f4a; paint-order: stroke fill; text-shadow: 0 calc(6 * var(--u)) 0 #0f1f4a; }
.menu-title .amp { color: #facc15; margin-left: .12em; }
.menu-title .dr { font-style: normal; color: #a3e635; }
.menu-subtitle { margin-top: calc(8 * var(--u)); font-size: clamp(calc(15 * var(--u)), 2.4vh, calc(21 * var(--u))); font-weight: 700; letter-spacing: .5em; padding-left: .5em; color: #facc15;
  -webkit-text-stroke: calc(5 * var(--u)) #0f1f4a; paint-order: stroke fill; }

.mm-stack { width: 100%; display: flex; flex-direction: column; gap: calc(14 * var(--u)); }
.mm-btn { display: flex; align-items: center; justify-content: center; gap: calc(14 * var(--u)); width: 100%; padding: calc(12 * var(--u)) calc(18 * var(--u)); cursor: pointer;
  background: #fff; color: #0f1f4a; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(16 * var(--u)); box-shadow: 0 calc(6 * var(--u)) 0 #0f1f4a;
  font-size: clamp(calc(22 * var(--u)), 3.8vh, calc(32 * var(--u))); font-weight: 700; letter-spacing: .03em; transition: transform .08s ease, box-shadow .08s ease, filter .15s; }
.mm-btn.lime { background: #a3e635; }
.mm-btn.small { padding: calc(8 * var(--u)) calc(18 * var(--u)); font-size: calc(20 * var(--u)); }
.mm-btn:hover { transform: translateY(calc(-2 * var(--u))); box-shadow: 0 calc(8 * var(--u)) 0 #0f1f4a; filter: brightness(1.04); }
.mm-btn:active { transform: translateY(calc(5 * var(--u))); box-shadow: 0 calc(1 * var(--u)) 0 #0f1f4a; }
.mm-btn svg { flex: none; }
.mm-footer { position: absolute; bottom: calc(24 * var(--u)); left: 0; right: 0; text-align: center; font-size: calc(18 * var(--u)); font-weight: 700; letter-spacing: .06em; color: #fff;
  -webkit-text-stroke: calc(5 * var(--u)) #0f1f4a; paint-order: stroke fill; pointer-events: none; }

/* corner widgets */
.mm-sq { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: calc(58 * var(--u)); height: calc(58 * var(--u)); padding: 0 calc(8 * var(--u));
  background: #fff; color: #0f1f4a; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(14 * var(--u)); box-shadow: 0 calc(5 * var(--u)) 0 #0f1f4a; cursor: pointer; transition: transform .08s, box-shadow .08s; }
.mm-sq:hover { transform: translateY(calc(-2 * var(--u))); box-shadow: 0 calc(7 * var(--u)) 0 #0f1f4a; }
.mm-sq:active { transform: translateY(calc(4 * var(--u))); box-shadow: 0 calc(1 * var(--u)) 0 #0f1f4a; }
.mm-gear { top: calc(16 * var(--u)); right: calc(18 * var(--u)); }
.mm-help { left: calc(18 * var(--u)); bottom: calc(18 * var(--u)); height: calc(66 * var(--u)); }
.mm-help .q { font-size: calc(28 * var(--u)); font-weight: 700; line-height: 1; }
.mm-help small { font-size: calc(9.5 * var(--u)); font-weight: 700; letter-spacing: .04em; margin-top: calc(2 * var(--u)); }
.mm-bottom-right { position: absolute; right: calc(18 * var(--u)); bottom: calc(18 * var(--u)); display: flex; gap: calc(10 * var(--u)); }
.mm-bottom-right .mm-sq { position: static; height: calc(62 * var(--u)); }
.mm-lang b { font-size: calc(24 * var(--u)); line-height: 1; }
.mm-lang small { font-size: calc(12 * var(--u)); font-weight: 600; opacity: .7; }
.mm-badge { position: absolute; top: calc(16 * var(--u)); left: calc(18 * var(--u)); display: flex; align-items: center; gap: calc(10 * var(--u)); padding: calc(8 * var(--u)) calc(14 * var(--u)); background: #fff; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(14 * var(--u)); box-shadow: 0 calc(5 * var(--u)) 0 #0f1f4a; font-size: calc(24 * var(--u)); font-weight: 700; }
.mm-badge .tr { display: flex; align-items: center; gap: calc(4 * var(--u)); }

/* menu mascots */
.mm-char svg { display: block; width: 100%; height: auto; }
.mm-char { position: absolute; bottom: calc(62 * var(--u)); width: clamp(calc(130 * var(--u)), 17vw, calc(210 * var(--u))); height: auto; pointer-events: none; filter: drop-shadow(0 calc(6 * var(--u)) 0 rgba(15,31,74,.25)); animation: mmBob 2.8s ease-in-out infinite; }
.mm-char-l { left: calc(50% - calc(190 * var(--u)) - clamp(calc(130 * var(--u)), 17vw, calc(210 * var(--u))) - calc(18 * var(--u))); }
.mm-char-r { right: calc(50% - calc(190 * var(--u)) - clamp(calc(130 * var(--u)), 17vw, calc(210 * var(--u))) - calc(18 * var(--u))); animation-delay: -1.4s; }
@keyframes mmBob { 50% { transform: translateY(calc(-7 * var(--u))); } }
/* 3D mascots: the real in-game characters animate themselves, so no sticker shadow or bobbing */
.mm-char.is-3d { filter: none; animation: none; bottom: calc(40 * var(--u)); }
.mascot3d { display: block; width: 100%; height: auto; aspect-ratio: 2 / 3; }
.cust-preview .mascot3d { max-height: calc(300 * var(--u)); margin: 0 auto; }
@media (max-width: 860px) { .mm-char { display: none; } }

/* popups (settings, how to play) */
.mm-pop { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: calc(16 * var(--u)); background: rgba(6,20,60,.62); }
.mm-card { position: relative; width: min(calc(500 * var(--u)), 94vw); max-height: 92vh; overflow-y: auto; padding: calc(18 * var(--u)) calc(22 * var(--u)) calc(22 * var(--u)); background: #fff; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(20 * var(--u)); box-shadow: 0 calc(8 * var(--u)) 0 #0f1f4a; }
.mm-card h2 { margin: 0 0 calc(12 * var(--u)); text-align: center; font-size: calc(34 * var(--u)); font-weight: 700; letter-spacing: .04em; }
.mm-x { position: absolute; top: calc(12 * var(--u)); right: calc(12 * var(--u)); width: calc(40 * var(--u)); height: calc(40 * var(--u)); border-radius: calc(12 * var(--u)); border: calc(3.5 * var(--u)) solid #0f1f4a; background: #fb7185; color: #fff; font-size: calc(18 * var(--u)); font-weight: 700; cursor: pointer; box-shadow: 0 calc(3 * var(--u)) 0 #0f1f4a; }
.mm-x:active { transform: translateY(calc(3 * var(--u))); box-shadow: none; }
.mm-rows { display: flex; flex-direction: column; gap: calc(10 * var(--u)); margin-bottom: calc(18 * var(--u)); }
.menu-label { margin-bottom: calc(4 * var(--u)); font-size: calc(12 * var(--u)); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(15,31,74,.6); }
.menu-seg { display: flex; border: calc(3 * var(--u)) solid #0f1f4a; border-radius: calc(11 * var(--u)); overflow: hidden; background: #e8effc; }
.menu-seg button { flex: 1; padding: calc(6 * var(--u)) 0; border: 0; background: none; color: rgba(15,31,74,.7); font-size: calc(17 * var(--u)); font-weight: 700; cursor: pointer; }
.menu-seg button + button { border-left: calc(3 * var(--u)) solid #0f1f4a; }
.menu-seg button:hover { background: #d3e1fb; color: #0f1f4a; }
.menu-seg button.selected { background: #a3e635; color: #0f1f4a; }
.mm-howto-body { font-size: calc(17 * var(--u)); line-height: 1.45; margin-bottom: calc(18 * var(--u)); }
.mm-howto-body p { margin: 0 0 calc(8 * var(--u)); }
.mm-howto-body b { background: #e6fba8; border-radius: calc(6 * var(--u)); padding: 0 calc(6 * var(--u)); }

@media (max-height: 560px) { .mm-center { gap: calc(10 * var(--u)); } .mm-stack { gap: calc(9 * var(--u)); } .mm-logo-art { display: none; } }
@media (max-width: 560px) { .mm-logo-art { right: calc(-70 * var(--u)); width: calc(80 * var(--u)); } }
/* phones: the footer hint collides with the corner buttons, and landscape leaves very little height */
@media (max-width: 600px), (max-height: 480px) { .mm-footer { display: none; } }
/* landscape phones: bring the 3D mascots back, smaller, beside the button column */
@media (min-width: 620px) and (max-height: 560px) { .mm-char { display: block; } }

/* Commentary caption: small line above the bottom edge */
#commentary-caption {
  position: absolute; left: 50%; bottom: calc(14 * var(--u)); transform: translate(-50%, calc(6 * var(--u)));
  z-index: 15; max-width: 80vw; padding: calc(3 * var(--u)) calc(12 * var(--u));
  background: rgba(0,0,0,0.45); border-radius: calc(8 * var(--u));
  color: #fff; font-size: calc(13 * var(--u)); font-weight: 600; font-style: italic; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
#commentary-caption::before { content: '🎙 '; font-style: normal; }
#commentary-caption.show { opacity: 1; transform: translate(-50%, 0); }
body.in-menu #commentary-caption { display: none; }

/* ===================== CUP MODE (js/cup.js) =====================
   Chunky "sticker" UI: straight rounded rectangles, thick dark outline, hard offset shadow.
   No skew / rotation anywhere. */
:root { --ink: #0f1f4a; --lime: #a3e635; --lime-d: #7bbf1a; --sun: #facc15; --coral: #f43f5e; }
.menu-cup { margin-bottom: calc(8 * var(--u)); }

#cup-screen {
  position: absolute; inset: 0; z-index: 60; color: var(--ink); overflow: auto;
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  /* night stadium: deep navy, a warm tier-coloured glow behind the bracket centre */
  --tier: #facc15; --tier-hi: #fff1a8; --tier-lo: #8a6a00;
  background:
    radial-gradient(ellipse 55% 42% at 50% 56%, color-mix(in srgb, var(--tier) 20%, transparent), transparent 72%),
    radial-gradient(ellipse at 50% -10%, #1d3478 0%, #0d1a40 42%, #060b1e 100%);
  display: flex; align-items: center; justify-content: center;
}
#cup-screen[data-tier="bronze"] { --tier: #d98a45; --tier-hi: #ffd2a6; --tier-lo: #7a3f12; }
#cup-screen[data-tier="silver"] { --tier: #c9d3e0; --tier-hi: #ffffff; --tier-lo: #66758c; }
#cup-screen[data-tier="gold"]   { --tier: #ffc21a; --tier-hi: #fff1a8; --tier-lo: #8a6200; }
/* two floodlight beams sweeping slowly + a vignette */
#cup-screen::before { content: ''; position: fixed; inset: 0; pointer-events: none; transform-origin: 50% 0;
  background:
    conic-gradient(from 158deg at 14% -4%, transparent 0deg, rgba(170,205,255,.13) 7deg, rgba(170,205,255,.05) 15deg, transparent 19deg),
    conic-gradient(from 183deg at 86% -4%, transparent 0deg, rgba(170,205,255,.05) 4deg, rgba(170,205,255,.13) 12deg, transparent 19deg);
  animation: cupBeams 8s ease-in-out infinite alternate; }
#cup-screen::after { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(0,0,0,.55) 100%); }
@keyframes cupBeams { from { transform: rotate(-1.6deg); opacity: .8; } to { transform: rotate(1.6deg); opacity: 1; } }
#cup-screen > * { position: relative; z-index: 1; }
#cup-screen.hidden { display: none; }
#cup-screen button { font-family: inherit; }

.flag { display: inline-block; overflow: hidden; border-radius: calc(6 * var(--u)); vertical-align: middle; }
.flag svg { display: block; }
.flag-sm { width: calc(24 * var(--u)); height: calc(16 * var(--u)); border: calc(2 * var(--u)) solid var(--ink); border-radius: calc(5 * var(--u)); }
.flag-md { width: calc(46 * var(--u)); height: calc(31 * var(--u)); }
.flag-lg { width: calc(64 * var(--u)); height: calc(43 * var(--u)); border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(9 * var(--u)); }

/* ---- buttons ---- */
.cup-btn { border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(12 * var(--u)); padding: calc(8 * var(--u)) calc(18 * var(--u)); font-size: calc(15 * var(--u)); font-weight: 700; letter-spacing: .04em;
  cursor: pointer; color: var(--ink); background: #fff; box-shadow: 0 calc(4 * var(--u)) 0 var(--ink); transition: transform .08s ease, box-shadow .08s ease, filter .15s; }
.cup-btn:hover { transform: translateY(calc(-2 * var(--u))); box-shadow: 0 calc(7 * var(--u)) 0 var(--ink); filter: brightness(1.04); }
.cup-btn:active { transform: translateY(calc(4 * var(--u))); box-shadow: 0 calc(1 * var(--u)) 0 var(--ink); }
.cup-btn.primary { background: var(--lime); }
.cup-btn.big { font-size: calc(20 * var(--u)); padding: calc(9 * var(--u)) calc(28 * var(--u)); border-radius: calc(13 * var(--u)); }
.cup-btn.sm { font-size: calc(13 * var(--u)); padding: calc(6 * var(--u)) calc(12 * var(--u)); display: inline-flex; align-items: center; gap: calc(8 * var(--u)); }
.cup-btn .arr { font-size: calc(20 * var(--u)); line-height: 0.7; margin-top: calc(-2 * var(--u)); }
.cup-btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: 0 calc(5 * var(--u)) 0 var(--ink); filter: grayscale(.4); }

/* ---- team select ---- */
.cup-panel { width: min(calc(600 * var(--u)), 94%); text-align: center; }
.cup-kicker { font-size: calc(12 * var(--u)); font-weight: 700; letter-spacing: .34em; color: var(--sun); text-shadow: 0 calc(2 * var(--u)) 0 var(--ink); }
.cup-title { margin: calc(2 * var(--u)) 0 calc(18 * var(--u)); font-size: clamp(calc(24 * var(--u)), 3.4vw, calc(36 * var(--u))); font-weight: 700; color: #fff; -webkit-text-stroke: calc(5 * var(--u)) var(--ink); paint-order: stroke fill; text-shadow: 0 calc(5 * var(--u)) 0 var(--ink); }
.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: calc(11 * var(--u)); }
@media (max-width: 600px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
.team-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: calc(4 * var(--u)); padding: calc(12 * var(--u)) calc(6 * var(--u)) calc(9 * var(--u)); cursor: pointer;
  background: #fff; border: calc(3.5 * var(--u)) solid var(--ink); border-radius: calc(18 * var(--u)); box-shadow: 0 calc(6 * var(--u)) 0 var(--ink); color: var(--ink); transition: transform .1s, box-shadow .1s; }
.team-card:hover { transform: translateY(calc(-3 * var(--u))); box-shadow: 0 calc(9 * var(--u)) 0 var(--ink); }
.team-card:active { transform: translateY(calc(4 * var(--u))); box-shadow: 0 calc(2 * var(--u)) 0 var(--ink); }
.team-card.selected { background: #e6fba8; box-shadow: 0 0 0 calc(4 * var(--u)) var(--lime), 0 calc(6 * var(--u)) 0 var(--ink), 0 0 calc(26 * var(--u)) rgba(163,230,53,.9); }
.team-check { position: absolute; top: calc(-12 * var(--u)); right: calc(-10 * var(--u)); width: calc(30 * var(--u)); height: calc(30 * var(--u)); border-radius: 50%; background: var(--lime); border: calc(3 * var(--u)) solid var(--ink); font-size: calc(17 * var(--u)); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.team-code { margin-top: calc(4 * var(--u)); font-size: calc(20 * var(--u)); font-weight: 700; letter-spacing: .04em; }
.team-name { font-size: calc(12 * var(--u)); font-weight: 500; opacity: .6; }
.cup-actions { display: flex; gap: calc(14 * var(--u)); justify-content: center; margin-top: calc(22 * var(--u)); }

/* ---- journey map screen ---- */
.cup-map-wrap { width: 100%; height: 100%; display: flex; flex-direction: column; }
.cup-topbar { display: flex; align-items: center; justify-content: space-between; gap: calc(10 * var(--u)); padding: calc(12 * var(--u)) calc(16 * var(--u)) 0; flex-wrap: wrap; }
.cup-tabs { display: flex; border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(12 * var(--u)); overflow: hidden; box-shadow: 0 calc(4 * var(--u)) 0 var(--ink); background: #2d6fd6; }
.cup-tab { display: flex; align-items: center; gap: calc(6 * var(--u)); border: 0; padding: calc(6 * var(--u)) calc(16 * var(--u)); font-size: calc(14 * var(--u)); font-weight: 700; letter-spacing: .05em; cursor: pointer; color: rgba(255,255,255,.75); background: transparent; }
.cup-tab + .cup-tab { border-left: calc(3 * var(--u)) solid var(--ink); }
.cup-tab.selected { background: var(--lime); color: var(--ink); }
.cup-tab:disabled { cursor: default; color: rgba(255,255,255,.5); background: #2a62bd; }
.cup-tab .cnt { font-size: calc(13 * var(--u)); background: var(--ink); color: var(--sun); border-radius: calc(8 * var(--u)); padding: calc(1 * var(--u)) calc(6 * var(--u)); }

.bk-host { position: relative; flex: 1; min-height: 0; }
.bk { position: absolute; left: 50%; top: 50%; width: 1000px; height: 340px; transform-origin: 50% 50%; }
.bk-lines { position: absolute; inset: 0; overflow: visible; }
.bk-lines polyline { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.bk-lines .d { stroke: var(--ink); stroke-width: 9; }
.bk-lines .l { stroke: var(--lime); stroke-width: 4.5; filter: drop-shadow(0 0 4px rgba(163,230,53,.9)); }

/* round headers: white tab sitting on a line */
.bk-head { position: absolute; top: 0; width: 176px; height: 46px; transform: translateX(-50%); border-bottom: 3px solid rgba(255,255,255,.9); text-align: center; }
.bk-head span { position: relative; display: inline-block; min-width: 104px; height: 40px; line-height: 38px; padding: 0 14px; box-sizing: border-box;
  background: #fff; border: 3.5px solid var(--ink); border-bottom: 0; border-radius: 20px 20px 0 0; font-size: 24px; font-weight: 700; letter-spacing: .03em; }
.bk-head.cur span::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 42px; height: 7px; margin-left: -21px; border-radius: 4px; background: var(--lime); border: 2px solid var(--ink); }

/* match cards */
.bk-m { position: absolute; transform: translate(-50%, -50%); width: 158px; padding: 12px 12px 8px; box-sizing: border-box; text-align: center;
  background: #fff; border: 3.5px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); }
.bk-m.big { width: 196px; padding: 14px 12px; }
.bk-slots { display: flex; justify-content: center; align-items: center; gap: 8px; }
.bk-s { position: relative; width: 62px; height: 44px; border: 3px solid var(--ink); border-radius: 11px; overflow: hidden; background: var(--ink); flex: none; box-sizing: border-box; }
.bk-m.big .bk-s { width: 72px; height: 52px; }
.bk-s .flag { display: block; width: 100%; height: 100%; border-radius: 0; border: 0; }
.bk-s.tbd { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; font-weight: 700; }
.bk-s.me { box-shadow: 0 0 0 3px var(--lime); overflow: visible; }
.bk-s.me .flag { border-radius: 8px; }
.bk-s.out .flag { filter: grayscale(1) brightness(.75); opacity: .55; }
.bk-s.out { background: #9aa6bd; }
.bk-x { position: absolute; right: -3px; top: -3px; width: 20px; height: 20px; border-radius: 50%; background: var(--coral); border: 2.5px solid var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.bk-vs { font-size: 17px; font-weight: 700; opacity: .55; }
.bk-cap { margin-top: 6px; font-size: 19px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.bk-cap i { font-style: normal; font-weight: 500; opacity: .45; font-size: 15px; margin: 0 2px; }
.bk-cap b.q { opacity: .45; }

.bk-m.cur { background: #e6fba8; box-shadow: 0 0 0 5px var(--lime), 0 6px 0 var(--ink), 0 0 30px rgba(163,230,53,.95); animation: bkPulse 1.5s ease-in-out infinite; z-index: 3; }
.bk-tag { position: absolute; top: -17px; right: -8px; background: var(--ink); color: var(--lime); font-size: 14px; font-weight: 700; letter-spacing: .08em; padding: 2px 10px; border-radius: 9px; border: 2.5px solid var(--ink); }
.bk-m.pop { animation: bkPop .7s cubic-bezier(.2, 1.6, .4, 1); }
.bk-s.reveal .flag { animation: cupReveal .8s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bkPulse { 50% { box-shadow: 0 0 0 8px rgba(163,230,53,.55), 0 6px 0 var(--ink), 0 0 42px rgba(163,230,53,1); } }
@keyframes bkPop { 0% { transform: translate(-50%, -50%) scale(.8); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes cupReveal { from { transform: scale(.2) translateY(calc(-10 * var(--u))); opacity: 0; } to { transform: none; opacity: 1; } }

/* champion card */
.bk-champ-card { position: absolute; transform: translate(-50%, -50%); width: 196px; box-sizing: border-box; background: #fff; border: 3.5px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; text-align: center; }
.bk-champ-head { background: var(--sun); border-bottom: 3.5px solid var(--ink); font-size: 22px; font-weight: 700; letter-spacing: .06em; padding: 4px 0 3px; }
.bk-champ-body { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 12px 12px; }
.bk-champ-body .bk-s { width: 66px; height: 50px; }
.bk-champ-name { margin-top: -4px; padding-bottom: 8px; font-size: 18px; font-weight: 700; letter-spacing: .05em; }
.bk-champ-card.win { box-shadow: 0 0 0 5px var(--sun), 0 6px 0 var(--ink), 0 0 40px rgba(250,204,21,.95); animation: bkPulse 1.6s ease-in-out infinite; }
.bk-trophy { filter: drop-shadow(0 3px 0 rgba(15,31,74,.25)); }

/* bottom band */
.cup-footer { display: flex; align-items: center; justify-content: space-between; gap: calc(16 * var(--u)); flex-wrap: wrap; padding: calc(10 * var(--u)) calc(24 * var(--u)) calc(14 * var(--u));
  background: linear-gradient(180deg, #1c58c8, #174aa8); border-top: calc(4 * var(--u)) solid var(--ink); }
.cup-headline { font-size: clamp(calc(22 * var(--u)), 2.6vw, calc(30 * var(--u))); font-weight: 700; line-height: 1; color: #fff; -webkit-text-stroke: calc(5 * var(--u)) var(--ink); paint-order: stroke fill; text-shadow: 0 calc(4 * var(--u)) 0 var(--ink); }
.cup-sub { margin-top: calc(5 * var(--u)); font-size: calc(12 * var(--u)); font-weight: 600; letter-spacing: .05em; color: var(--sun); text-shadow: 0 calc(2 * var(--u)) 0 var(--ink); }
.cup-footer.lost .cup-headline { color: #ffd1d9; }
.cup-footer.won .cup-headline { color: var(--sun); }

.cup-footer .cup-btn { margin-left: auto; }

/* ================= Cup: night-stadium theme (dark glass cards, tier colours, 3D trophy) ================= */
.cup-hero { text-align: center; padding-top: calc(4 * var(--u)); }
.cup-hero-tier { display: inline-block; font-size: clamp(calc(26 * var(--u)), 3.6vw, calc(42 * var(--u))); font-weight: 700; letter-spacing: .1em; line-height: 1.05;
  background: linear-gradient(180deg, #fff 0%, var(--tier-hi) 35%, var(--tier) 70%, var(--tier-lo) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 calc(3 * var(--u)) 0 #050a1c) drop-shadow(0 0 calc(16 * var(--u)) color-mix(in srgb, var(--tier) 55%, transparent)); }
.cup-hero-sub { margin-top: calc(2 * var(--u)); font-size: calc(11 * var(--u)); font-weight: 600; letter-spacing: .34em; color: rgba(255,255,255,.5); }

.cup-tabs { background: #0e1940; border-color: #050a1c; box-shadow: 0 calc(4 * var(--u)) 0 #050a1c, 0 0 0 calc(1 * var(--u)) rgba(255,255,255,.06) inset; }
.cup-tab + .cup-tab { border-left-color: #050a1c; }
.cup-tab.selected { background: linear-gradient(180deg, var(--tier-hi), var(--tier)); color: var(--ink); }
.cup-tab:disabled { background: #0b1433; color: rgba(255,255,255,.35); }
#cup-screen .cup-btn.ghost { background: #16244f; color: #fff; border-color: #050a1c; box-shadow: 0 calc(4 * var(--u)) 0 #050a1c; }
#cup-screen .cup-btn.ghost:hover { background: #1d2f63; }

/* connector lines: subtle rails, your route in glowing lime that flows toward the final */
.bk-lines .d { stroke: #24366f; stroke-width: 6; }
.bk-lines .l { stroke-dasharray: 12 8; animation: cupFlow 0.9s linear infinite; }
@keyframes cupFlow { to { stroke-dashoffset: -20; } }

/* match cards: dark glass */
.bk-m { background: linear-gradient(180deg, #1e2f66 0%, #15224e 100%); color: #fff; border-color: #050a1c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 6px 0 #050a1c, 0 12px 26px rgba(0,0,0,.35); }
.bk-s { border-color: #050a1c; }
.bk-s.tbd { background: #0b1534; color: rgba(255,255,255,.45); border-color: #2a3d7c; border-style: dashed; }
.bk-s.out { background: #283152; }
.bk-vs { color: rgba(255,255,255,.7); }
.bk-m.cur { background: linear-gradient(180deg, #2c5226 0%, #1c3a1f 100%); }
.bk-tag { background: var(--lime); color: var(--ink); border-color: #050a1c; }

/* champion card: tier-metal header, rotating light rays behind the live 3D trophy */
.bk-champ-card { width: 236px; background: radial-gradient(ellipse at 35% 60%, color-mix(in srgb, var(--tier) 28%, #132050) 0%, #111c45 70%);
  border-color: #050a1c; color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tier) 80%, transparent), 0 6px 0 #050a1c, 0 0 34px color-mix(in srgb, var(--tier) 45%, transparent); }
.bk-champ-head { background: linear-gradient(180deg, var(--tier-hi), var(--tier) 70%, var(--tier-lo)); border-bottom-color: #050a1c; color: var(--ink); font-size: 20px; padding: 3px 0 2px; }
.bk-champ-body { position: relative; padding: 4px 12px 8px; gap: 8px; }
.bk-trophy-3d { position: relative; display: block; width: 112px; height: 112px; flex: none; }
.bk-trophy-3d::before { content: ''; position: absolute; inset: -14px; border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--tier) 35%, transparent) 0deg 8deg, transparent 8deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: cupRays 14s linear infinite; }
.bk-trophy-3d .trophy3d, .bk-trophy-3d .bk-trophy { position: relative; display: block; width: 100%; height: 100%; }
@keyframes cupRays { to { transform: rotate(360deg); } }
.bk-champ-card.win { box-shadow: 0 0 0 5px var(--tier), 0 6px 0 #050a1c, 0 0 60px var(--tier); animation: cupChampGlow 1.6s ease-in-out infinite; }
.bk-champ-card.win .bk-trophy-3d::before { animation-duration: 5s; }
@keyframes cupChampGlow { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--tier) 60%, transparent), 0 6px 0 #050a1c, 0 0 90px var(--tier); } }

/* bottom band */
.cup-footer { background: linear-gradient(180deg, rgba(12,22,58,.92), #070d24); border-top: calc(3 * var(--u)) solid color-mix(in srgb, var(--tier) 70%, #050a1c);
  box-shadow: 0 calc(-12 * var(--u)) calc(34 * var(--u)) rgba(0,0,0,.45); }
.cup-footer .cup-headline { -webkit-text-stroke-color: #050a1c; text-shadow: 0 calc(4 * var(--u)) 0 #050a1c; }
.cup-footer.lost .cup-headline { color: #ff8fa3; }
.cup-footer.won .cup-headline { background: linear-gradient(180deg, #fff, var(--tier-hi) 40%, var(--tier)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0; filter: drop-shadow(0 calc(3 * var(--u)) 0 #050a1c); }
.cup-footer .cup-btn.primary { box-shadow: 0 calc(4 * var(--u)) 0 #050a1c, 0 0 calc(22 * var(--u)) rgba(163,230,53,.55); }

/* ===================== IN-GAME HUD: same sticker style as the menu / cup screens =====================
   Straight rounded rectangles, thick ink outline, hard offset shadow, Fredoka type. Overrides the
   older translucent HUD above. */
#ui-layer, #callouts-container, #world-labels-container, #commentary-caption { font-family: 'Fredoka', 'Inter', system-ui, sans-serif; }
#ui-layer { padding: calc(10 * var(--u)) calc(12 * var(--u)); }

/* scoreboard */
#scoreboard { top: calc(2 * var(--u)); padding: calc(5 * var(--u)) calc(16 * var(--u)) calc(6 * var(--u)); background: #fff; border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(13 * var(--u)); box-shadow: 0 calc(4 * var(--u)) 0 var(--ink); }
.sb-row { gap: calc(9 * var(--u)); }
.sb-name { font-size: calc(15 * var(--u)); font-weight: 700; letter-spacing: .05em; color: var(--ink); }
.sb-cpu { color: #2563eb; }
.sb-score { font-size: calc(26 * var(--u)); font-weight: 700; color: var(--ink); min-width: calc(16 * var(--u)); }
.sb-sep { color: rgba(15,31,74,.4); font-size: calc(18 * var(--u)); font-weight: 700; }
.sb-serve { width: calc(11 * var(--u)); height: calc(11 * var(--u)); background: var(--lime); border: calc(2.5 * var(--u)) solid var(--ink); box-shadow: none; }
.sb-sub { margin-top: calc(3 * var(--u)); font-size: calc(11 * var(--u)); font-weight: 600; color: rgba(15,31,74,.55); }
.sb-sub #rally-count { color: #d97706; font-weight: 700; }

/* top-left / top-right controls */
.hud-text-btn { padding: calc(5 * var(--u)) calc(11 * var(--u)); background: #fff; border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(11 * var(--u)); box-shadow: 0 calc(3 * var(--u)) 0 var(--ink);
  color: var(--ink); font-size: calc(12 * var(--u)); font-weight: 700; letter-spacing: .05em; text-shadow: none; transition: transform .08s, box-shadow .08s; }
.hud-text-btn:hover { color: var(--ink); transform: translateY(calc(-1 * var(--u))); box-shadow: 0 calc(4 * var(--u)) 0 var(--ink); }
.hud-text-btn:active { transform: translateY(calc(3 * var(--u))); box-shadow: 0 0 0 var(--ink); }
.hud-right { gap: calc(8 * var(--u)); }
.hud-icon { width: calc(34 * var(--u)); height: calc(34 * var(--u)); border-radius: calc(11 * var(--u)); background: #fff; border: calc(3 * var(--u)) solid var(--ink); box-shadow: 0 calc(3 * var(--u)) 0 var(--ink); color: var(--ink); transition: transform .08s, box-shadow .08s; }
.hud-icon:hover { background: #e6fba8; transform: translateY(calc(-1 * var(--u))); box-shadow: 0 calc(4 * var(--u)) 0 var(--ink); }
.hud-icon:active { transform: translateY(calc(3 * var(--u))); box-shadow: 0 0 0 var(--ink); }
.hud-icon svg { width: calc(16 * var(--u)); height: calc(16 * var(--u)); }

/* settings dropdown */
.hud-panel { top: calc(46 * var(--u)); width: calc(200 * var(--u)); padding: calc(10 * var(--u)); background: #fff; border: calc(3.5 * var(--u)) solid var(--ink); border-radius: calc(16 * var(--u)); box-shadow: 0 calc(5 * var(--u)) 0 var(--ink); gap: calc(6 * var(--u)); }
.hud-menu-item { padding: calc(7 * var(--u)) calc(10 * var(--u)); background: #e8effc; border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(10 * var(--u)); color: var(--ink) !important; font-family: inherit; font-size: calc(13 * var(--u)); font-weight: 700; cursor: pointer; }
.hud-menu-item:hover { background: #d3e1fb; }
.hud-menu-item option { background: #fff; color: var(--ink); }
#btn-reset.hud-menu-item { background: #ffd9de; }
.hud-panel-hint { padding: calc(4 * var(--u)) calc(2 * var(--u)) 0; font-size: calc(11 * var(--u)); font-weight: 500; color: rgba(15,31,74,.6); }

/* serve / point banner */
#banner-title.hud-banner { padding: calc(7 * var(--u)) calc(20 * var(--u)) calc(9 * var(--u)); background: #fff; color: var(--ink); border: calc(3.5 * var(--u)) solid var(--ink); border-radius: calc(14 * var(--u));
  box-shadow: inset 0 calc(-6 * var(--u)) 0 var(--accent), 0 calc(5 * var(--u)) 0 var(--ink); font-size: calc(22 * var(--u)); font-weight: 700; letter-spacing: .04em; }
.hud-banner-sub { margin-top: calc(10 * var(--u)); padding: 0 calc(8 * var(--u)); background: none; color: #fff; font-size: calc(14 * var(--u)); font-weight: 600;
  -webkit-text-stroke: calc(4 * var(--u)) var(--ink); paint-order: stroke fill; text-shadow: none; }

/* floating callouts + YOU tag + swing meter */
.floating-callout { font-size: calc(22 * var(--u)); font-weight: 700; letter-spacing: .03em; -webkit-text-stroke: calc(6 * var(--u)) var(--ink); paint-order: stroke fill; text-shadow: 0 calc(3 * var(--u)) 0 var(--ink); }
.you-tag { padding: calc(1 * var(--u)) calc(8 * var(--u)) calc(2 * var(--u)); background: var(--lime); color: var(--ink); border: calc(2.5 * var(--u)) solid var(--ink); border-radius: calc(8 * var(--u)); font-size: calc(12 * var(--u)); font-weight: 700; letter-spacing: .08em; text-shadow: none; box-shadow: 0 calc(2 * var(--u)) 0 var(--ink); }
.swing-meter { width: calc(52 * var(--u)); height: calc(9 * var(--u)); border-radius: calc(5 * var(--u)); background: #fff; border: calc(2.5 * var(--u)) solid var(--ink); box-shadow: 0 calc(2 * var(--u)) 0 var(--ink); }
#swing-meter-fill { background: var(--lime); border-radius: calc(3 * var(--u)); }

/* touch controls */
#joystick-zone { width: calc(108 * var(--ut)); height: calc(108 * var(--ut)); background: rgba(255,255,255,.55); border: calc(3.5 * var(--ut)) solid var(--ink); box-shadow: 0 calc(4 * var(--ut)) 0 var(--ink); margin: 0 0 calc(6 * var(--ut)) calc(8 * var(--ut)); }
#joystick-knob { width: calc(44 * var(--ut)); height: calc(44 * var(--ut)); background: var(--lime); border: calc(3.5 * var(--ut)) solid var(--ink); }
.touch-btn { border: calc(3.5 * var(--ut)) solid var(--ink) !important; box-shadow: 0 calc(4 * var(--ut)) 0 var(--ink); color: var(--ink); font-family: inherit; font-size: calc(13 * var(--ut)); font-weight: 700; letter-spacing: .04em; }
.touch-btn:active, .touch-btn.active-press { transform: translateY(calc(3 * var(--ut))) scale(.97); box-shadow: 0 calc(1 * var(--ut)) 0 var(--ink); background: inherit; }
.btn-swing { background: var(--lime); font-size: calc(15 * var(--ut)); }
.btn-smash { background: #fb923c; }
.btn-lob { background: #38bdf8; }

/* commentary caption */
#commentary-caption { bottom: calc(16 * var(--u)); padding: calc(6 * var(--u)) calc(16 * var(--u)); background: #fff; color: var(--ink); border: calc(3 * var(--u)) solid var(--ink); border-radius: calc(13 * var(--u)); box-shadow: 0 calc(4 * var(--u)) 0 var(--ink);
  font-size: calc(15 * var(--u)); font-weight: 600; font-style: normal; }

/* customise popup */
.cust-card { width: min(calc(720 * var(--u)), 96vw); }
.cust-body { display: grid; grid-template-columns: calc(240 * var(--u)) 1fr; gap: calc(20 * var(--u)); margin-bottom: calc(16 * var(--u)); align-items: start; }
.cust-preview { background: linear-gradient(180deg, #4a97ff, #2f7cf2); border: calc(3.5 * var(--u)) solid #0f1f4a; border-radius: calc(16 * var(--u)); padding: calc(10 * var(--u)) calc(6 * var(--u)) 0; box-shadow: 0 calc(4 * var(--u)) 0 #0f1f4a; }
.cust-preview svg { display: block; width: 100%; height: auto; }
.cust-opts .menu-row { margin-top: 0; margin-bottom: calc(9 * var(--u)); }
.cust-note { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }
.sw-row { display: flex; gap: calc(9 * var(--u)); flex-wrap: wrap; }
.sw { width: calc(36 * var(--u)); height: calc(36 * var(--u)); border-radius: calc(11 * var(--u)); border: calc(3 * var(--u)) solid #0f1f4a; cursor: pointer; padding: 0; box-shadow: 0 calc(3 * var(--u)) 0 #0f1f4a; transition: transform .08s, box-shadow .08s; }
.sw:hover { transform: translateY(calc(-2 * var(--u))); box-shadow: 0 calc(5 * var(--u)) 0 #0f1f4a; }
.sw.selected { outline: calc(4 * var(--u)) solid #a3e635; outline-offset: calc(1 * var(--u)); }
@media (max-width: 600px) { .cust-body { grid-template-columns: 1fr; } .cust-preview { max-width: calc(200 * var(--u)); margin: 0 auto; } }

/* ===================== REPLAY (js/replay.js) ===================== */
#replay-ui { position: absolute; inset: 0; z-index: 40; pointer-events: none; opacity: 0; transition: opacity .2s; font-family: 'Fredoka', 'Inter', system-ui, sans-serif; }
#replay-ui.on { opacity: 1; }
.rp-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .35s ease; }
.rp-bar.top { top: 0; } .rp-bar.bot { bottom: 0; }
#replay-ui.on .rp-bar { height: 9vh; }
.rp-tag { position: absolute; top: calc(9vh + calc(14 * var(--u))); left: calc(18 * var(--u)); padding: calc(4 * var(--u)) calc(16 * var(--u)) calc(5 * var(--u)); background: #f43f5e; color: #fff; border: calc(3.5 * var(--u)) solid #0f1f4a; border-radius: calc(12 * var(--u)); box-shadow: 0 calc(4 * var(--u)) 0 #0f1f4a; font-size: calc(22 * var(--u)); font-weight: 700; letter-spacing: .12em; }
.rp-tag::before { content: ''; display: inline-block; width: calc(11 * var(--u)); height: calc(11 * var(--u)); margin-right: calc(9 * var(--u)); border-radius: 50%; background: #fff; animation: rpBlink 1s steps(2) infinite; }
.rp-hint { position: absolute; bottom: calc(9vh + calc(12 * var(--u))); left: 0; right: 0; text-align: center; font-size: calc(14 * var(--u)); font-weight: 600; letter-spacing: .1em; color: #fff; -webkit-text-stroke: calc(4 * var(--u)) #0f1f4a; paint-order: stroke fill; }
@keyframes rpBlink { 50% { opacity: 0; } }
body.replaying #world-labels-container, body.replaying #callouts-container, body.replaying #center-banner,
body.replaying .touch-controls, body.replaying #commentary-caption { display: none !important; }

/* ===================== VERSUS SCREEN (js/versus.js) ===================== */
#versus-screen { position: absolute; inset: 0; z-index: 70; overflow: hidden; color: #0f1f4a; font-family: 'Fredoka', 'Inter', system-ui, sans-serif; cursor: pointer; }
#versus-screen.hidden { display: none; }
#versus-screen.out { opacity: 0; transition: opacity .3s ease; }
.vs-bg { position: absolute; inset: 0; display: flex; }
.vs-half { flex: 1; position: relative; }
.vs-half.l { background: linear-gradient(180deg, #3d8bff, #1f5fd1); transform: translateX(-101%); }
.vs-half.r { background: linear-gradient(180deg, #fb7185, #e11d48); transform: translateX(101%); }
.vs-half::after { content: ''; position: absolute; inset: 0; opacity: .14;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='360' height='360' viewBox='0 0 360 360' fill='none' stroke='white' stroke-width='3'><rect x='40' y='40' width='280' height='280'/><path d='M40 180h280M180 40v280M40 110h280M40 250h280'/></svg>"); }
#versus-screen.in .vs-half.l, #versus-screen.in .vs-half.r { transform: none; transition: transform .45s cubic-bezier(.2, .9, .25, 1); }
.vs-top { position: absolute; top: 5vh; left: 0; right: 0; text-align: center; z-index: 3; transform: translateY(-160%); }
#versus-screen.in .vs-top { transform: none; transition: transform .5s .1s cubic-bezier(.2, 1.2, .3, 1); }
.vs-title { display: inline-block; padding: calc(6 * var(--u)) calc(28 * var(--u)) calc(8 * var(--u)); background: #fff; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(16 * var(--u)); box-shadow: 0 calc(6 * var(--u)) 0 #0f1f4a; font-size: clamp(calc(22 * var(--u)), 3.6vw, calc(38 * var(--u))); font-weight: 700; letter-spacing: .06em; }
.vs-sub { margin-top: calc(12 * var(--u)); font-size: clamp(calc(13 * var(--u)), 1.8vw, calc(18 * var(--u))); font-weight: 600; letter-spacing: .12em; color: #fff; -webkit-text-stroke: calc(5 * var(--u)) #0f1f4a; paint-order: stroke fill; }

.vs-side { position: absolute; top: 14vh; bottom: 14vh; width: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; z-index: 2; }
.vs-side.l { left: 0; transform: translateX(-120%); } .vs-side.r { right: 0; transform: translateX(120%); }
#versus-screen.in .vs-side { transform: none; transition: transform .6s .2s cubic-bezier(.2, 1.15, .3, 1); }
.vs-art { width: min(34vh, 30vw); filter: drop-shadow(0 1.2vh 0 rgba(15,31,74,.35)); }
.vs-art svg { display: block; width: 100%; height: auto; }
.vs-side.l .vs-art { margin-right: 6vw; } .vs-side.r .vs-art { margin-left: 6vw; }
.vs-card { min-width: min(34vh, 28vw); padding: 1.2vh 2.2vh 1.6vh; text-align: center; background: #fff; border: calc(4 * var(--u)) solid #0f1f4a; border-radius: calc(18 * var(--u)); box-shadow: 0 calc(6 * var(--u)) 0 #0f1f4a; }
.vs-side.l .vs-card { margin-right: 6vw; } .vs-side.r .vs-card { margin-left: 6vw; }
.vs-tag { display: inline-block; margin-bottom: .8vh; padding: calc(1 * var(--u)) calc(12 * var(--u)); background: var(--c); color: #fff; border: calc(3 * var(--u)) solid #0f1f4a; border-radius: calc(9 * var(--u)); font-size: clamp(calc(11 * var(--u)), 1.6vh, calc(15 * var(--u))); font-weight: 700; letter-spacing: .14em; }
.vs-flagwrap { margin: .4vh 0; }
.vs-flag { width: min(15vh, 13vw); height: min(10vh, 8.7vw); border: calc(3 * var(--u)) solid #0f1f4a; border-radius: calc(9 * var(--u)); }
.vs-code { font-size: clamp(calc(30 * var(--u)), 8vh, calc(78 * var(--u))); font-weight: 700; line-height: 1; letter-spacing: .04em; }
.vs-name { margin-top: .4vh; font-size: clamp(calc(13 * var(--u)), 2.4vh, calc(22 * var(--u))); font-weight: 500; opacity: .6; }

.vs-badge { position: absolute; left: 50%; top: 50%; z-index: 5; width: min(22vh, 20vw); height: min(22vh, 20vw); transform: translate(-50%, -50%) scale(0) rotate(-20deg); display: flex; align-items: center; justify-content: center;
  background: #facc15; border: calc(5 * var(--u)) solid #0f1f4a; border-radius: 50%; box-shadow: 0 calc(8 * var(--u)) 0 #0f1f4a, 0 0 0 calc(10 * var(--u)) rgba(255,255,255,.85); }
.vs-badge span { font-size: min(11vh, 10vw); font-weight: 700; letter-spacing: .02em; }
#versus-screen.in .vs-badge { animation: vsSlam .55s .5s cubic-bezier(.2, 1.7, .4, 1) forwards, vsPulse 1.1s 1.1s ease-in-out infinite; }
@keyframes vsSlam { 0% { transform: translate(-50%, -50%) scale(3.2) rotate(-20deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; } }
@keyframes vsPulse { 50% { transform: translate(-50%, -50%) scale(1.07); } }
#versus-screen.in { animation: vsShake .35s .5s linear; }
@keyframes vsShake { 20% { transform: translate(calc(-6 * var(--u)), calc(4 * var(--u))); } 40% { transform: translate(calc(5 * var(--u)), calc(-5 * var(--u))); } 60% { transform: translate(calc(-4 * var(--u)), calc(3 * var(--u))); } 80% { transform: translate(calc(3 * var(--u)), calc(-2 * var(--u))); } }

.vs-ready { position: absolute; left: 0; right: 0; bottom: 6vh; z-index: 3; text-align: center; font-size: clamp(calc(22 * var(--u)), 4.4vh, calc(40 * var(--u))); font-weight: 700; letter-spacing: .2em; color: #fff; -webkit-text-stroke: calc(7 * var(--u)) #0f1f4a; paint-order: stroke fill; opacity: 0; }
#versus-screen.in .vs-ready { animation: vsReady .5s 1.3s forwards; }
@keyframes vsReady { from { opacity: 0; transform: translateY(calc(20 * var(--u))); } to { opacity: 1; transform: none; } }
.vs-hint { position: absolute; right: calc(18 * var(--u)); bottom: calc(12 * var(--u)); z-index: 3; font-size: calc(12 * var(--u)); font-weight: 600; letter-spacing: .12em; color: rgba(255,255,255,.85); text-shadow: 0 calc(2 * var(--u)) 0 #0f1f4a; }

/* ===================== SERVE METER (js/servemeter.js) ===================== */
#serve-meter { position: absolute; left: 50%; bottom: 17vh; transform: translateX(-50%); z-index: 18; width: min(calc(270 * var(--u)), 52vw); text-align: center; pointer-events: none; font-family: 'Fredoka', 'Inter', system-ui, sans-serif; }
#serve-meter.hidden { display: none; }
body.in-menu #serve-meter, body.replaying #serve-meter { display: none !important; }
.sm-title:empty { display: none; }
.sm-title { margin-bottom: calc(8 * var(--u)); font-size: calc(18 * var(--u)); font-weight: 700; letter-spacing: .1em; color: #fff; -webkit-text-stroke: calc(5 * var(--u)) #0f1f4a; paint-order: stroke fill; }
.sm-bar { position: relative; height: calc(20 * var(--u)); border: calc(3 * var(--u)) solid #0f1f4a; border-radius: calc(10 * var(--u)); box-shadow: 0 calc(3 * var(--u)) 0 #0f1f4a; overflow: visible;
  background: linear-gradient(90deg, #f43f5e 0 12%, #fb923c 12% 30%, #a3e635 30% 44%, #a3e635 56% 70%, #fb923c 70% 88%, #f43f5e 88% 100%); }
.sm-bar::after { content: ''; position: absolute; left: 44%; width: 12%; top: calc(-3 * var(--u)); bottom: calc(-3 * var(--u)); background: linear-gradient(180deg, #fff6a8, #ffd700 55%, #ffb800); border: calc(2 * var(--u)) solid #0f1f4a; border-radius: calc(6 * var(--u)); box-shadow: 0 0 0 calc(2 * var(--u)) #fff; }
.sm-bar::before { content: ''; position: absolute; inset: 0; border-radius: calc(7 * var(--u)); background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 55%); }
.sm-marker { z-index: 2; position: absolute; top: calc(-7 * var(--u)); bottom: calc(-7 * var(--u)); width: calc(7 * var(--u)); margin-left: calc(-3.5 * var(--u)); background: #fff; border: calc(2 * var(--u)) solid #0f1f4a; border-radius: calc(4 * var(--u)); box-shadow: 0 0 0 calc(2 * var(--u)) rgba(255,255,255,.6); }
#serve-meter.gold .sm-bar { box-shadow: 0 calc(3 * var(--u)) 0 #0f1f4a, 0 0 calc(16 * var(--u)) calc(4 * var(--u)) rgba(255, 215, 0, .95); }
#serve-meter.gold .sm-marker { background: #ffd700; }
.sm-result { margin-top: calc(8 * var(--u)); min-height: calc(26 * var(--u)); font-size: calc(22 * var(--u)); font-weight: 700; letter-spacing: .06em; color: var(--rc, #fff); -webkit-text-stroke: calc(5 * var(--u)) #0f1f4a; paint-order: stroke fill; }
#serve-meter.locked .sm-result { animation: smPop .45s cubic-bezier(.2, 1.7, .4, 1); }
#serve-meter.locked.perfect .sm-bar { box-shadow: 0 calc(3 * var(--u)) 0 #0f1f4a, 0 0 calc(20 * var(--u)) calc(6 * var(--u)) rgba(255, 215, 0, 1); }
@keyframes smPop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }


/* FPS counter (F3) */
#fps-counter { position: absolute; left: calc(10 * var(--u)); bottom: calc(10 * var(--u)); z-index: 90; padding: calc(6 * var(--u)) calc(10 * var(--u)); background: rgba(8,16,40,.88); color: #e2e8f0; border-radius: calc(10 * var(--u)); font: 500 calc(12 * var(--u))/1.45 'JetBrains Mono', monospace; pointer-events: none; }
#fps-counter b { color: #a3e635; font-size: calc(14 * var(--u)); }
#fps-counter .ok { color: #a3e635; } #fps-counter .bad { color: #fb7185; font-weight: 700; }
#fps-counter canvas { display: block; margin-top: calc(4 * var(--u)); width: calc(240 * var(--u)); height: calc(44 * var(--u)); background: rgba(255,255,255,.06); border-radius: calc(4 * var(--u)); }
#fps-counter.hidden { display: none; }

/* quick match mode picker */
.mode-card { width: min(calc(640 * var(--u)), 96vw); }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(12 * var(--u)); margin-bottom: calc(14 * var(--u)); }
@media (max-width: 560px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-opt { display: flex; flex-direction: column; align-items: center; gap: calc(6 * var(--u)); padding: calc(14 * var(--u)) calc(10 * var(--u)) calc(12 * var(--u)); cursor: pointer; text-align: center;
  background: #fff; color: #0f1f4a; border: calc(3.5 * var(--u)) solid #0f1f4a; border-radius: calc(16 * var(--u)); box-shadow: 0 calc(5 * var(--u)) 0 #0f1f4a; transition: transform .08s, box-shadow .08s; }
.mode-opt:hover { transform: translateY(calc(-2 * var(--u))); box-shadow: 0 calc(7 * var(--u)) 0 #0f1f4a; }
.mode-opt.selected { background: #e6fba8; box-shadow: 0 0 0 calc(4 * var(--u)) #a3e635, 0 calc(5 * var(--u)) 0 #0f1f4a; }
.mode-opt b { font-size: calc(26 * var(--u)); font-weight: 700; letter-spacing: .04em; }
.mode-opt small { font-size: calc(13 * var(--u)); font-weight: 500; opacity: .7; line-height: 1.3; }
.mode-ic { height: calc(42 * var(--u)); display: flex; align-items: center; }
.mode-ic svg { height: 100%; width: auto; max-width: 100%; }
.mode-card .menu-row { margin-bottom: calc(16 * var(--u)); }

/* F4 GPU benchmark */
#bench-panel { position: absolute; right: calc(12 * var(--u)); top: calc(64 * var(--u)); z-index: 95; width: calc(360 * var(--u)); padding: calc(12 * var(--u)) calc(14 * var(--u)); background: rgba(8,16,40,.93); color: #e2e8f0; border: calc(2 * var(--u)) solid #a3e635; border-radius: calc(12 * var(--u)); font: 500 calc(12 * var(--u))/1.45 'JetBrains Mono', monospace; }
#bench-panel.hidden { display: none; }
#bench-panel h3 { margin: 0 0 calc(4 * var(--u)); color: #a3e635; font-size: calc(14 * var(--u)); letter-spacing: .08em; }
#bench-panel table { width: 100%; border-collapse: collapse; margin-top: calc(6 * var(--u)); }
#bench-panel td { padding: calc(2 * var(--u)) calc(4 * var(--u)); border-top: calc(1 * var(--u)) solid rgba(255,255,255,.08); }
#bench-panel td:nth-child(2) { text-align: right; white-space: nowrap; } #bench-panel td:nth-child(3) { text-align: right; color: #facc15; white-space: nowrap; }
#bench-panel .b-hint { margin-top: calc(8 * var(--u)); color: rgba(255,255,255,.55); }

/* Smash available: the touch SMASH button pulses (matches the orange ring under the player) */
.btn-smash.smash-ready { animation: smashReadyPulse 0.35s ease-in-out infinite alternate; box-shadow: 0 0 calc(18 * var(--ut)) calc(6 * var(--ut)) rgba(251,146,60,0.9); }
@keyframes smashReadyPulse { from { transform: scale(1); } to { transform: scale(1.15); } }

/* Cup screen on short (landscape phone) screens: compact header so the bracket gets the height */
@media (max-height: 520px) {
  .cup-hero { padding-top: 0; }
  .cup-hero-sub { display: none; }
  .cup-topbar { padding-top: calc(8 * var(--u)); }
  .cup-footer { padding-top: calc(6 * var(--u)); padding-bottom: calc(8 * var(--u)); }
}

/* ===== Touch controls on phones / tablets: big, thumb-sized, sized from the screen height ===== */
#joy-area { display: none; }
@media (pointer: coarse) {
  :root { --tb: clamp(72px, 24vh, 118px); }          /* swing button size; everything else follows it */
  #joy-area { display: block; position: fixed; left: 0; top: 22%; width: 48%; bottom: 0; z-index: 0; touch-action: none; }
  .touch-controls { position: relative; z-index: 1; pointer-events: none; }
  .touch-controls .interactive, .touch-controls #joystick-zone { pointer-events: auto; }
  #joystick-zone { width: calc(var(--tb) * 1.45); height: calc(var(--tb) * 1.45); margin: 0 0 calc(var(--tb) * 0.08) calc(var(--tb) * 0.12);
    background: rgba(255,255,255,.28); border-width: 3px; box-shadow: 0 4px 0 var(--ink); transition: opacity .15s; opacity: .75; }
  #joystick-zone.active { opacity: 1; }
  #joystick-knob { width: calc(var(--tb) * 0.62); height: calc(var(--tb) * 0.62); border-width: 3px; }
  .action-cluster { width: calc(var(--tb) * 2.05); height: calc(var(--tb) * 1.8); margin: 0 calc(var(--tb) * 0.08) calc(var(--tb) * 0.08) 0; }
  .touch-btn { border-width: 3px !important; box-shadow: 0 4px 0 var(--ink); }
  .btn-swing { width: var(--tb); height: var(--tb); right: 0; bottom: 0; font-size: calc(var(--tb) * 0.19); }
  .btn-smash { width: calc(var(--tb) * 0.76); height: calc(var(--tb) * 0.76); right: calc(var(--tb) + 10px); bottom: 0; font-size: calc(var(--tb) * 0.15); }
  .btn-lob   { width: calc(var(--tb) * 0.68); height: calc(var(--tb) * 0.68); right: calc(var(--tb) * 0.5); bottom: calc(var(--tb) + 10px); font-size: calc(var(--tb) * 0.15); }
}
