*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #2b3338;
  --ink-dim: #6b777e;
  --line: #c9d4d9;
  --court-blue: #35aee8;
  --court-blue-2: #8fd6fa;
  --gold: #f6c431;
  --font: 'M PLUS Rounded 1c', 'Arial Rounded MT Bold', -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);    /* phones in landscape: the notch side */
  --safe-r: env(safe-area-inset-right, 0px);
}
html, body { height: 100%; overflow: hidden; background: #8fcbe8; }
body {
  font-family: var(--font);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: fine) {
  body, button { cursor: url('assets/ui/hand.svg') 22 6, pointer; }
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ============ INTRO ============ */
.intro {
  position: fixed; inset: 0;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: calc(9vh + 4vh);
  pointer-events: auto;
}
/* cinematic bars */
.intro::before, .intro::after {
  content: ''; position: absolute; left: 0; right: 0; height: 9vh;
  background: #000; transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}
.intro::before { top: 0; }
.intro::after { bottom: 0; }
.intro.out::before { transform: translateY(-100%); }
.intro.out::after { transform: translateY(100%); }
.intro-logo {
  width: min(70vw, 620px);
  opacity: 0;
  transform: scale(0.92);
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, 0.35));
  transition: opacity 0.7s, transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.intro.logo .intro-logo { opacity: 1; transform: none; }
.intro.out .intro-logo { opacity: 0; transform: scale(1.05); transition-duration: 0.4s; }
.intro-skip {
  position: absolute; bottom: calc(9vh + 14px); right: calc(20px + var(--safe-r));
  font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ============ MENU ============ */
.menu { position: fixed; inset: 0; pointer-events: none; display: grid; grid-template-rows: auto 1fr auto; }
.menu > * { pointer-events: auto; }
.menu-top {
  position: relative;
  height: calc(clamp(52px, 9vh, 86px) + var(--safe-t));
  padding-top: var(--safe-t);
  background: #fff;
  border-bottom: 3px solid #9aa4a8;
  display: flex; align-items: center; justify-content: space-between;
  animation: slideDown 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.menu-tab {
  align-self: flex-start;
  margin-top: calc(var(--safe-t) + clamp(12px, 2.2vh, 20px));
  padding: 0.28em 2.6em 0.28em calc(1.1em + var(--safe-l));
  font-size: clamp(15px, 2.1vw, 26px);
  font-weight: 500;
  color: #fff;
  background: #8e9799;
  clip-path: polygon(0 0, calc(100% - 1.1em) 0, 100% 100%, 0 100%);
}
.menu-logo { height: 62%; margin-right: calc(clamp(12px, 2vw, 28px) + var(--safe-r)); }
.menu-panel {
  pointer-events: none;
  position: relative;
}
.menu-list {
  pointer-events: auto;
  position: absolute; top: 0; bottom: 0; left: 0;
  width: clamp(280px, 38vw, 560px);
  padding: clamp(18px, 4vh, 44px) 0 0 calc(clamp(10px, 1.2vw, 18px) + var(--safe-l));
  display: flex; flex-direction: column; gap: clamp(8px, 1.6vh, 16px);
  background: #fff;
  clip-path: polygon(0 0, 82% 0, 100% 100%, 0 100%);
  animation: slideRight 0.6s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.mbtn {
  position: relative;
  width: 74%;
  padding: 0.24em 0;
  border: 0;
  background: none;
  font-size: clamp(20px, 2.6vw, 36px);
  font-weight: 500;
  color: var(--ink);
  isolation: isolate;
  transition: transform 0.15s;
}
/* stair-step to the right, like a console menu */
.mbtn:nth-child(2) { margin-left: 3.5%; }
.mbtn:nth-child(3) { margin-left: 7%; }
.mbtn:nth-child(4) { margin-left: 10.5%; }
.mbtn:nth-child(5) { margin-left: 14%; }
.mbtn:nth-child(6) { margin-left: 17.5%; }
/* a skin unlocked that you haven't looked at yet */
.mbtn.new::after {
  content: 'NEW'; position: absolute; top: -6px; right: 4%;
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 900; color: #fff;
  background: #ff5cc8; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ============ SKINS (in the menu, in the list's place) ============ */
.skins {
  pointer-events: auto;
  position: absolute; top: 0; bottom: 0; left: 0;
  width: clamp(280px, 38vw, 560px);
  padding: clamp(14px, 3vh, 36px) 15% 14px calc(clamp(14px, 1.6vw, 24px) + var(--safe-l));
  display: flex; flex-direction: column; gap: 10px;
  background: #fff;
  clip-path: polygon(0 0, 82% 0, 100% 100%, 0 100%);
  animation: slideRight 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.skins-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.skins-head > span:first-child { font-size: clamp(22px, 2.6vw, 34px); font-weight: 800; }
.skins-best { font-size: 13px; font-weight: 800; color: var(--court-blue); white-space: nowrap; }
.skin-list { list-style: none; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.skin-row {
  position: relative; width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
  padding: 10px 14px; border: 0; border-radius: 12px; text-align: left;
  background: linear-gradient(180deg, #f3f8fa, #d9e5ea);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.85), 0 0 0 1.5px #bccdd4;
}
.skin-row.sel { background: linear-gradient(180deg, #8fd6fa, #35aee8); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6), 0 0 0 2px #2b9ad3; }
.skin-name { font-size: clamp(17px, 1.8vw, 22px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skin-state { font-size: 12px; font-weight: 800; opacity: 0.8; white-space: nowrap; }
.skin-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.1); overflow: hidden; }
.skin-bar i { display: block; height: 100%; background: #ff5cc8; border-radius: 3px; }
.skins-actions { margin-top: auto; display: grid; gap: 8px; }
.map-pick { display: grid; gap: 4px; }
.map-pick > span { font-size: 12px; font-weight: 800; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.map-pick .tabs { margin-bottom: 0; }
/* Halloween update notice */
.card.news .card-head { background: linear-gradient(#8a4df0, #5b22b8); }
.news-art { display: block; width: calc(100% + 44px); max-width: none; height: auto; aspect-ratio: 1; object-fit: cover; margin: -16px -22px 14px; background: #120a1e; }
.news-title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
#newsWear { background: linear-gradient(#a874ff, #7a3fe0); box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 0 0 2px #6a2fd0, 0 4px 0 #4d1fa0; }
.skins-actions .wbtn { margin-top: 0; white-space: nowrap; }
/* glass buttons: a soft gloss on the upper half and a little light at the lower edge;
   the selected one is blue glass with a faint reflection passing over it */
.mbtn::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  border-radius: 11px;
  transform: skewX(-9deg);
  background:
    linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%) -150% 0 / 250% 100% no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.35) 46%, rgba(255, 255, 255, 0) 52%),
    radial-gradient(100% 70% at 50% 130%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 65%),
    linear-gradient(180deg, #f3f8fa 0%, #d9e5ea 55%, #cbdae1 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.85),
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1.5px #bccdd4,
    0 4px 10px rgba(70, 110, 125, 0.16);
  transition: filter 0.2s;
}
.mbtn:hover::before { filter: brightness(1.03); }
.mbtn.sel::before {
  background:
    linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.4) 50%, transparent 60%) -150% 0 / 250% 100% no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.28) 46%, rgba(255, 255, 255, 0) 52%),
    radial-gradient(100% 70% at 50% 130%, rgba(210, 248, 255, 0.6), rgba(210, 248, 255, 0) 65%),
    linear-gradient(180deg, #bfe8fc 0%, #7ccdf5 55%, #4cb5ea 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.75),
    inset 0 2px 0 rgba(255, 255, 255, 0.85),
    0 0 0 1.5px #39a7df,
    0 0 10px rgba(53, 174, 232, 0.3),
    0 4px 10px rgba(30, 120, 170, 0.18);
  animation: glassSweep 4s ease-in-out infinite;
}
@keyframes glassSweep {
  0%, 55% { background-position: -150% 0, 0 0, 0 0, 0 0; }
  85%, 100% { background-position: 250% 0, 0 0, 0 0, 0 0; }
}
.mbtn.sel { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
.mbtn.sel { transform: translateX(6px); }

.mbtn:active::before { filter: brightness(0.94); }
.mbtn:active { transform: translateX(6px) scale(0.98); }
.menu-bottom {
  height: calc(clamp(44px, 7.5vh, 70px) + var(--safe-b));
  padding: 0 calc(clamp(12px, 1.6vw, 22px) + var(--safe-r)) var(--safe-b) calc(clamp(12px, 1.6vw, 22px) + var(--safe-l));
  background: #fff;
  border-top: 3px solid #9aa4a8;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  animation: slideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.badge { height: 58%; width: auto; display: block; }   /* Cocoon logo, cut out of the menu PSD */
.menu-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 0; }
.menu-me { font-size: clamp(12px, 1.4vw, 16px); font-weight: 700; color: var(--ink-dim); text-align: right; }
.ai-note { font-size: 9px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-dim); opacity: 0.55; text-align: right; }   /* wraps on narrow phones */
/* "Get the App": a small glass chip over the scene, outside the stair-stepped list */
.app-chip {
  pointer-events: auto;
  position: absolute; top: clamp(10px, 2vh, 18px); right: calc(clamp(10px, 1.6vw, 22px) + var(--safe-r));
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 5px;
  border: 0; border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(233, 242, 246, 0.88));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.9), 0 0 0 1.5px #bccdd4, 0 4px 12px rgba(40, 80, 100, 0.18);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  cursor: pointer;
  animation: chipIn 0.5s 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.15s, filter 0.15s;
}
.app-chip img { width: 26px; height: 26px; border-radius: 7px; display: block; }
.app-chip:hover { filter: brightness(1.04); }
.app-chip:active { transform: scale(0.96); }
@keyframes chipIn { from { opacity: 0; transform: translateY(-8px); } }
.menu-me b { color: var(--court-blue); }

@keyframes slideDown { from { transform: translateY(-100%); } }
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes slideRight { from { transform: translateX(-100%); } }

/* phones (portrait): your player on top, menu as a sheet underneath */
@media (max-aspect-ratio: 4/5) {
  .menu-list {
    top: auto; right: 0; width: auto;
    padding: 34px 18px 14px 10px;
    clip-path: polygon(0 26px, 100% 0, 100% 100%, 0 100%);
    gap: 9px;
    animation-name: slideUpList;
  }
  .mbtn { width: 80%; font-size: 19px; padding: 0.2em 0; }
  .mbtn:nth-child(n) { margin-left: calc((var(--i, 0)) * 2.5%); }
  .skins {
    top: auto; right: 0; width: auto; max-height: 62%;
    padding: 34px 16px 12px calc(16px + var(--safe-l));
    clip-path: polygon(0 26px, 100% 0, 100% 100%, 0 100%);
    gap: 8px;
    animation-name: slideUpList;
  }
  .skin-row { padding: 8px 12px; }
  .skins-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .menu-logo { height: 52%; }
}
@keyframes slideUpList { from { transform: translateY(100%); } }

/* ============ MATCH HUD ============ */
.hud { position: fixed; inset: 0; pointer-events: none; }
.score {
  position: absolute; top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l));
  display: grid; gap: 3px; padding: 7px 8px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.score .row { display: flex; align-items: center; gap: 10px; }
.score .who { min-width: 42px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; color: #fff; text-align: center; }
.score .you { background: #2f8de4; }
.score .cpu { background: #e4572f; }
.score .pts { min-width: 34px; font-size: 18px; font-weight: 900; text-align: right; font-variant-numeric: tabular-nums; }
.score .serving::after { content: ' •'; color: #c7e33a; }
.rally {
  position: absolute; top: calc(16px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  font-size: 14px; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* round pause button while playing (sound, restart and how-to are in the pause menu) */
.pause {
  position: fixed; top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r));
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  color: var(--ink); background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 5;
}
.pause svg { width: 20px; height: 20px; fill: currentColor; }
.pause:active { transform: scale(0.94); }
.pause-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }

/* ============ HIGHSCORE HUD ============ */
.hs-hud {
  position: fixed; left: 0; right: 0; top: calc(10px + var(--safe-t));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: 0 calc(66px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  pointer-events: none;
}
.hs-lives { display: flex; gap: 6px; padding-top: 8px; }
.hs-lives i {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4ff9a, #d2ec3b 55%, #9fbe1d);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
  position: relative;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s, opacity 0.3s;
}
.hs-lives i::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85); border-left-color: transparent; border-right-color: transparent;
  transform: rotate(35deg);
}
.hs-lives i.lost { filter: grayscale(1); opacity: 0.35; transform: scale(0.7); }
.hs-lives i.gain { animation: lifeGain 0.6s; }
@keyframes lifeGain { 40% { transform: scale(1.5); } }
.hs-center { text-align: center; }
.hs-score {
  font-size: clamp(34px, 7.5vw, 58px); font-weight: 900; line-height: 1;
  color: #fff; font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 2px #1f4d66;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #1f4d66, 0 8px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}
.hs-score.bump { transform: scale(1.12); }
.hs-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 6px; justify-content: center; }
.hs-level, .hs-best {
  white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.hs-level {                       /* fills up towards the next level */
  color: #fff;
  background: linear-gradient(90deg, #1b86c4 var(--p, 0%), var(--court-blue) var(--p, 0%));
}
.hs-best:empty { display: none; }
.hs-mult { justify-self: end; display: grid; justify-items: center; gap: 5px; }
.hs-mult .x {
  display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 50%;
  font-size: 21px; font-weight: 900; color: #fff;
  background: radial-gradient(circle at 35% 30%, #9adcf9, #2f9fdc);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), inset 0 0 0 3px rgba(255, 255, 255, 0.55);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
}
.hs-mult[data-m="2"] .x { background: radial-gradient(circle at 35% 30%, #b6f08f, #3cb84a); }
.hs-mult[data-m="3"] .x { background: radial-gradient(circle at 35% 30%, #ffe98a, #f2b417); }
.hs-mult[data-m="4"] .x { background: radial-gradient(circle at 35% 30%, #ffc28a, #f0731c); }
.hs-mult[data-m="5"] .x, .hs-mult[data-m="6"] .x { background: radial-gradient(circle at 35% 30%, #ff9db0, #e3304f); }
.hs-mult[data-m="7"] .x, .hs-mult[data-m="8"] .x { background: radial-gradient(circle at 35% 30%, #e0b3ff, #8a3de0); box-shadow: 0 0 18px #c58cff, inset 0 0 0 3px rgba(255,255,255,0.55); }
.hs-mult.up .x { transform: scale(1.35) rotate(-8deg); }
.hs-mult .pips { display: flex; gap: 3px; }
.hs-mult .pips i { width: 10px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.55); box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: background 0.2s; }
.hs-mult .pips i.on { background: #fff26b; }

/* narrow phones: the score gets all the room between lives and multiplier, six digits included */
@media (max-width: 480px) {
  .hs-hud { grid-template-columns: auto 1fr auto; column-gap: 6px; padding-left: calc(12px + var(--safe-l)); padding-right: calc(62px + var(--safe-r)); }
  .hs-lives { gap: 4px; }
  .hs-lives i { width: 18px; height: 18px; }
  .hs-score { font-size: clamp(26px, 8vw, 40px); }
  .hs-mult .x { width: 46px; height: 46px; font-size: 18px; }
}

/* floating score popups */
.popups { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%);
  font-size: clamp(18px, 4vw, 28px); font-weight: 900; white-space: nowrap;
  color: #fff; -webkit-text-stroke: 1.5px #1f4d66; paint-order: stroke fill;
  text-shadow: 0 3px 0 #1f4d66;
  animation: popUp 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.pop small { display: block; font-size: 0.55em; text-align: center; letter-spacing: 0.04em; }
.pop.perfect { color: #8ee3ff; }
.pop.target { color: #ffe45c; font-size: clamp(22px, 5vw, 36px); }
.pop.gold { color: #ffd34d; }
.pop.power { color: #ff8ad8; font-size: clamp(22px, 5vw, 36px); }
/* timing tip on a missed swing: the advice under the word */
.pop.tip { display: flex; flex-direction: column-reverse; align-items: center; color: #ffb36b; font-size: clamp(24px, 6vw, 34px);
  -webkit-text-stroke-color: #5a2a06; text-shadow: 0 3px 0 #5a2a06; animation-duration: 1.6s; }
.pop.tip small { font-size: 0.6em; color: #fff; }
.pop.miss { color: #ff7a7a; -webkit-text-stroke-color: #5a1010; text-shadow: 0 3px 0 #5a1010; }
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  70% { opacity: 1; transform: translate(-50%, -120%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(0.95); }
}

/* big centre callouts (arcade style) */
.callout {
  position: fixed; top: 32%; left: 50%; width: max-content;   /* else the box stops at the right edge and the text runs off it */
  transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(34px, 9vw, 72px); font-weight: 900; font-style: italic; letter-spacing: -0.01em;
  color: #fff; -webkit-text-stroke: 2px #1d2a12; paint-order: stroke fill; text-shadow: 0 6px 0 #1d2a12;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.callout.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.callout.small { font-size: clamp(22px, 5.5vw, 38px); -webkit-text-stroke-width: 1.5px; text-shadow: 0 4px 0 #1d2a12; }

.hint {
  position: fixed; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 800; color: #fff; background: rgba(20, 30, 10, 0.55);
  white-space: nowrap; pointer-events: none; transition: opacity 0.3s;
}
.hint:empty { opacity: 0; }

/* ============ KRANK BUTTON (momentum) ============ */
/* a ring that fills with good play; full = glows, tap it (or E) and the next return is the KRANK shot.
   Bottom right, in thumb reach, away from your player in the bottom centre. */
.krank {
  position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(64px + var(--safe-b));
  width: 72px; height: 72px; border-radius: 50%; border: 0; padding: 5px;
  background: conic-gradient(#ff5cc8 var(--m, 0deg), rgba(255, 255, 255, 0.45) var(--m, 0deg));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  z-index: 5; touch-action: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.krank span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  font-size: 13px; font-weight: 900; font-style: italic; letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.9);
  background: rgba(31, 77, 102, 0.75);
}
.krank.ready { animation: krankGlow 0.9s ease-in-out infinite alternate; }
.krank.ready span { color: #fff; background: radial-gradient(circle at 35% 30%, #ff9de0, #d81b8f); }
.krank.armed { transform: scale(1.12); background: #fff26b; box-shadow: 0 0 26px #ff5cc8; }
.krank.armed span { color: #fff; background: radial-gradient(circle at 35% 30%, #ffb35c, #ff2f6e); }
.krank:active { transform: scale(0.94); }
@keyframes krankGlow { to { box-shadow: 0 0 28px #ff5cc8, 0 4px 14px rgba(0, 0, 0, 0.22); transform: scale(1.06); } }

/* ============ POWER-UPS (highscore) ============ */
.power-tag {
  position: fixed; transform: translate(-50%, -100%);
  padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 900; color: #fff; white-space: nowrap;
  background: var(--c, #ff5cc8); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.hs-power { margin-top: 6px; display: flex; gap: 4px; justify-content: center; }
.hs-power:empty { display: none; }
.hs-power span {
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 900; color: #fff;
  background: var(--c); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ============ PANELS (arcade style) ============ */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: flex-start;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  z-index: 10;
  overflow-y: auto; overscroll-behavior: contain;   /* a card taller than the screen scrolls instead of being cut off */
  background: rgba(20, 50, 70, 0.32);
  animation: fadeIn 0.25s both;
}
@keyframes fadeIn { from { opacity: 0; } }
.card {
  width: min(400px, 100%);
  margin: auto;                     /* centred, and from the top when it's taller than the screen */
  padding: 24px 22px 22px;
  border-radius: 22px; text-align: center;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } }
.card-logo { width: 78%; }
.card.arcade { padding-top: 0; overflow: hidden; }
.card-head {
  margin: 0 -22px 16px;
  padding: 12px 22px;
  font-size: 20px; font-weight: 800; color: #fff;
  background: linear-gradient(#5ec3f2, #2f9fdc);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}
.sub { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--ink-dim); }
.how { list-style: none; text-align: left; display: grid; gap: 9px; margin-bottom: 18px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.how li { padding-left: 22px; position: relative; }
.how li::before { content: '🎾'; position: absolute; left: 0; font-size: 13px; }
.how b { font-weight: 800; }
.tgt { color: #d79a00; font-weight: 800; }
.fan-note { margin: -6px 0 12px; font-size: 11px; font-weight: 600; line-height: 1.4; color: var(--ink-dim); }
.gold { color: #c99400; font-weight: 800; }
.wbtn {
  display: block; width: 100%;
  margin-top: 8px; padding: 12px;
  border: 0; border-radius: 14px;
  font-size: 17px; font-weight: 800; color: var(--ink);
  background: linear-gradient(#f7fafb, #d8e4e8);
  box-shadow: inset 0 2px 0 #fff, 0 0 0 2px var(--line), 0 4px 0 #b9c7cc;
}
.wbtn.primary { color: #fff; background: linear-gradient(#7fd0f7, #35aee8); box-shadow: inset 0 2px 0 rgba(255,255,255,0.6), 0 0 0 2px #2b9ad3, 0 4px 0 #1f7fb2; }
.wbtn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 #fff, 0 0 0 2px var(--line), 0 1px 0 #b9c7cc; }
.wbtn.primary:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.6), 0 0 0 2px #2b9ad3, 0 1px 0 #1f7fb2; }
.wbtn:disabled { opacity: 0.6; }
#nameInput, #pwInput, #pwNew, #pwCurrent, #delPw {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 20px; font-weight: 800; text-align: center; color: var(--ink);
  outline: none; user-select: text; -webkit-user-select: text;
}
#nameInput:focus, #pwInput:focus, #pwNew:focus, #pwCurrent:focus { border-color: var(--court-blue); box-shadow: 0 0 0 4px rgba(53, 174, 232, 0.2); }
.err { min-height: 1.3em; margin: 6px 0 2px; font-size: 13px; font-weight: 700; color: #d6453d; }

/* leaderboard */
.board-card { width: min(460px, 100%); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; padding: 4px; border-radius: 12px; background: #e9f0f3; }
.tab { flex: 1; padding: 8px; border: 0; border-radius: 9px; font-size: 14px; font-weight: 800; color: var(--ink-dim); background: none; }
.tab.on { color: #fff; background: var(--court-blue); box-shadow: 0 2px 6px rgba(53, 174, 232, 0.35); }
.board-list { list-style: none; max-height: min(48vh, 420px); overflow-y: auto; text-align: left; margin: 0 -6px; padding: 0 6px; }
.board-list li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  font-size: 15px; font-weight: 700;
  animation: rowIn 0.35s both;
}
.board-list li:nth-child(odd) { background: #f3f7f9; }
.board-list li.me { background: #d7f0fc; box-shadow: inset 0 0 0 2px var(--court-blue); }
.board-list .rk {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; font-weight: 900; color: var(--ink-dim); background: #e3eaed;
}
.board-list li:nth-child(1) .rk { color: #6b4b00; background: linear-gradient(#ffe48a, #f2b417); }
.board-list li:nth-child(2) .rk { color: #444; background: linear-gradient(#f2f2f2, #c3c7c9); }
.board-list li:nth-child(3) .rk { color: #5a3112; background: linear-gradient(#f5c597, #cd8a4b); }
.board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { font-weight: 900; font-variant-numeric: tabular-nums; }
.board-note { min-height: 1.2em; margin: 8px 0 2px; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
@keyframes rowIn { from { opacity: 0; transform: translateX(-10px); } }

/* results */
.results-card { position: relative; }
/* new best: a gold banner across the whole card, right under the head, with a light passing over it */
.res-ribbon {
  margin: -16px -22px 12px;
  padding: 9px 12px;
  font-size: 18px; font-weight: 900; letter-spacing: 0.08em; color: #5a3d00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  background:
    linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.65) 50%, transparent 65%) -150% 0 / 250% 100% no-repeat,
    linear-gradient(#ffe48a, #f2b417);
  box-shadow: inset 0 -2px 0 rgba(150, 100, 0, 0.25), 0 3px 8px rgba(180, 120, 0, 0.25);
  animation: ribbonIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both, ribbonShine 2.4s 0.5s ease-in-out infinite;
}
@keyframes ribbonIn { from { transform: scaleX(0.3); opacity: 0; } }
@keyframes ribbonShine { 0%, 40% { background-position: -150% 0, 0 0; } 80%, 100% { background-position: 250% 0, 0 0; } }
.res-score {
  font-size: clamp(44px, 12vw, 64px); font-weight: 900; line-height: 1.1;
  color: var(--court-blue); font-variant-numeric: tabular-nums;
}
.res-rank { min-height: 1.4em; margin: 2px 0 14px; font-size: 15px; font-weight: 800; color: var(--ink-dim); }
.res-rank b { color: var(--ink); }
.res-claim { margin: -6px 0 16px; }
.res-next { margin: -8px 0 14px; font-size: 13px; font-weight: 800; color: var(--court-blue); }
.res-next:empty { display: none; }
.res-skin { margin: -6px 0 12px; padding: 6px 10px; border-radius: 10px; font-size: 14px; font-weight: 900; color: #fff; background: #ff5cc8; }
.res-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.res-stats div { padding: 8px; border-radius: 12px; background: #f1f6f8; }
.res-stats dt { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
.res-stats dd { font-size: 22px; font-weight: 900; }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
/* share: a golden button on the results, then a preview of the story card */
.wbtn.share-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 4px 0 6px; color: #3a2a00;
  background: linear-gradient(#fff0a0, #ffd23a);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.7), 0 0 0 2px #e0a800, 0 4px 0 #b88700;
}
.wbtn.share-btn svg { width: 20px; height: 20px; }
.wbtn.share-btn:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.7), 0 0 0 2px #e0a800, 0 1px 0 #b88700; }
#sharePanel { z-index: 13; }
.share-card { width: min(380px, 92vw); }
.share-frame {
  position: relative; margin: 0 auto 10px;
  height: min(52vh, 460px); aspect-ratio: 9 / 16;
  border-radius: 16px; overflow: hidden; background: #0f3a9e;
  box-shadow: 0 0 0 2px var(--line), 0 8px 22px rgba(0, 20, 60, 0.25);
}
.share-frame img { width: 100%; height: 100%; display: block; object-fit: cover; }
.share-frame img:not([src]) { visibility: hidden; }
/* press & hold saves the card (the rest of the game blocks that menu) */
#shareImg { -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
#shareImg.pulse { animation: cardPulse 1.4s ease-in-out 2; }
@keyframes cardPulse { 50% { transform: scale(0.96); } }
.share-hint { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; line-height: 1.4; color: #0f3a5e; background: #e3f4fd; }
.share-hint small { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-dim); }
.share-wait { position: absolute; inset: 0; display: grid; place-items: center; color: #cfeeff; font-size: 14px; font-weight: 800; }
/* phone: the big button goes straight to the share sheet (pick Instagram → Story); computer: pick a platform */
#shareGo { display: flex; align-items: center; justify-content: center; gap: 8px; }
#shareGo .ico { width: 22px; height: 22px; flex: none; }
#shareGo .ico-ig, #shareGo.ig .ico-post { display: none; }
#shareGo.ig .ico-ig { display: block; }
#shareGo.ig {
  background: linear-gradient(100deg, #f9a83a 0%, #ee2a7b 45%, #8a3ab9 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 0 0 2px #b8307a, 0 4px 0 #7a2470;
}
#shareGo.ig:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 0 0 2px #b8307a, 0 1px 0 #7a2470; }
.share-platforms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.share-platforms[hidden] { display: none; }
.share-platforms button {
  padding: 9px 4px; border: 0; border-radius: 11px;
  font: inherit; font-size: 13px; font-weight: 800; color: var(--ink);
  background: linear-gradient(#f7fafb, #dfe9ed); box-shadow: inset 0 1px 0 #fff, 0 0 0 1.5px var(--line);
  cursor: pointer;
}
.share-platforms button:active { transform: translateY(1px); }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.share-note { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.res-actions .primary { grid-column: 1 / -1; }

.bar { height: 8px; margin: 18px 0 10px; border-radius: 4px; background: rgba(0, 0, 0, 0.1); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--court-blue); transition: width 0.2s; }
#loadText { font-size: 13px; font-weight: 700; color: var(--ink-dim); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* panels opened from other panels sit on top of them */
#board, #howto { z-index: 12; }
#nameEntry { z-index: 13; }

/* account panels */
#nameForm, #pwForm { display: grid; gap: 8px; }
#nameForm .err, #pwForm .err { margin: 0; }
.note { margin: 0 0 4px; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 700; line-height: 1.35; color: #6b4b00; background: #fff4cc; text-align: left; }
#profile { z-index: 12; }
#delForm { display: grid; gap: 8px; margin-top: 8px; }
#delPw { width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font: inherit; font-size: 18px; font-weight: 800; text-align: center; }
.wbtn.danger { color: #b3261e; }
.note.warn { color: #7a1a12; background: #ffe1dc; }

/* get the app */
.app-icon { display: block; width: 84px; height: 84px; margin: 2px auto 12px; border-radius: 20px; box-shadow: 0 0 0 2px var(--line), 0 4px 12px rgba(0,0,0,0.18); }
.app-steps { margin: 0 0 12px; padding: 0 0 0 26px; text-align: left; display: grid; gap: 8px; font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.app-steps b { font-weight: 800; }
.app-steps .ico { display: inline-block; vertical-align: -3px; width: 18px; height: 18px; color: var(--court-blue); }
a.wbtn { text-align: center; text-decoration: none; box-sizing: border-box; }

/* privacy note + legal links */
.privacy { margin: 2px 0 0; font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--ink-dim); }
.privacy a, .legal-links a { color: var(--court-blue); font-weight: 800; }
.legal-links { margin-top: 12px; font-size: 12px; font-weight: 700; color: var(--ink-dim); }

/* phones in landscape: compact panels, so most fit without scrolling */
@media (max-height: 500px) {
  .card { padding: 16px 18px; }
  .card.arcade { padding-top: 0; }
  .card-head { margin: 0 -18px 10px; padding: 8px 18px; font-size: 17px; }
  .sub { margin-bottom: 10px; }
  .wbtn { margin-top: 6px; padding: 9px; font-size: 16px; }
  .how { gap: 5px; margin-bottom: 10px; font-size: 13px; line-height: 1.35; }
  .results-card, .board-card { width: min(520px, 100%); }
  .res-ribbon { margin: -10px -18px 8px; padding: 6px 12px; font-size: 16px; }
  .res-score { font-size: 42px; }
  .res-rank { margin-bottom: 8px; }
  .res-next { margin: -4px 0 8px; }
  .res-stats { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
  .res-stats dd { font-size: 18px; }
  .board-list { max-height: 50vh; }
  .share-frame { height: min(70vh, 460px); }
  .hint { left: auto; right: calc(14px + var(--safe-r)); transform: none; font-size: 13px; }   /* your player stands bottom centre */
  .krank { bottom: calc(52px + var(--safe-b)); width: 62px; height: 62px; }   /* above the hint, which moves to the right here */
  .skins { gap: 6px; padding-top: 10px; padding-bottom: 10px; }
  .skin-list { gap: 5px; }
  .skin-row { padding: 5px 12px; }
  .skin-name { font-size: 16px; }
  .skins-actions { grid-template-columns: 1fr 1fr; gap: 6px; }
  .skins-actions .wbtn { padding: 8px; font-size: 14px; }
}
