:root {
  color-scheme: dark;
  --ink: #eef4ff;
  --muted: #9ab0cf;
  --panel-a: #244f8c;
  --panel-b: #0f2952;
  --panel-edge: #5aa0e6;
  --cyan: #63c1ff;
  --gold: #ffcf3f;
  --gold-deep: #f2a11c;
  --blue: #55bdff;
  --green: #62e35b;
  --blue-rgb: 85, 189, 255;
  --green-rgb: 98, 227, 91;
  /* "you" / "opponent" accents: blue and green marbles, swapped when you are the green side */
  --you: var(--blue);
  --opp: var(--green);
  --you-rgb: var(--blue-rgb);
  --opp-rgb: var(--green-rgb);
  --danger: #ec5a50;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Fredoka: the chunky rounded UI font of the top board (SIL OFL, bundled) */
@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-stretch: 75% 125%;
  font-display: swap;
}

/* Baloo 2: chunky rounded display font used for the Profile screen (OFL, bundled) */
@font-face {
  font-family: "Baloo 2";
  src: url("assets/fonts/Baloo2.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(8, 20, 44, 0.93), rgba(4, 11, 28, 0.985)),
    url("assets/arena.jpg") center / cover fixed,
    #071634;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  /* #app (the actual match board -- online, practice, and Solo Run/Challenge
     gameplay all use it) is a normal-flow child of body, not its own
     position:fixed screen like #home/#live/#solo, so IT needs body's own
     top padding to clear the phone's status bar; those other screens
     already carry the same env(safe-area-inset-top) treatment themselves. */
  padding: max(8px, var(--safe-area-inset-top, env(safe-area-inset-top))) 12px max(8px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
}

#app {
  /* --cu = 1% of a side card's width, so the top board scales with the screen */
  --app-w: min(100vw - 24px, 460px);
  --cu: calc((var(--app-w) - 16px) / 292);
  /* everything in the game window that is NOT the board (padding, gaps, top bar,
     cards, status line, the power-meter + buttons row) -- the board only
     shrinks if the screen is genuinely too short to fit it at full size */
  --stack: calc(var(--cu) * 98 + 157px);
  position: relative;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#app.has-hint { --stack: calc(var(--cu) * 98 + 180px); } /* a hint line is showing: it costs one line */
/* Tablets (and any tall, wide window, 860 px high or more): the game column may grow from 460 px up to 700 px. Everything inside
   is sized from --cu, so the cards, buttons and board all grow together. Phones and shorter windows keep exactly the layout above.
   --stack (everything in the window that is not the board) must grow with it: part of it (text lines, borders) does not scale,
   and from 860 px up the footer line shows too. Measured on the real page (tablet-size windows, 513-622 px columns): it is
   0.46 x column width + 129 px, +5 px of slack; in cu terms "134.3cu + 136px". How wide the column gets depends on the HEIGHT
   as well, because the board is the smaller of the column width and the height left over: (100vh - 129px) / 1.46 is the width
   at which the two are equal (the most board a window can show). It never goes below today's 460 px or above 700 px or the
   window width, so a short or landscape window (a 1280 x 720 desktop window) is exactly as before. The column's box takes the
   same width, so cards, board and buttons line up. A 768 x 1024 tablet goes from a 460 px board to about 613 px. */
@media (min-width: 600px) and (min-height: 860px) {
  #app { --app-w: clamp(460px, calc((100vh - 129px) / 1.46), min(100vw - 48px, 700px)); --stack: calc(var(--cu) * 134.3 + 136px); max-width: var(--app-w); }
  #app.has-hint { --stack: calc(var(--cu) * 134.3 + 159px); }
}
/* online, the second player owns the green marbles: swap the you/opponent accents to match */
#app[data-you="green"] {
  --you: var(--green);
  --opp: var(--blue);
  --you-rgb: var(--green-rgb);
  --opp-rgb: var(--blue-rgb);
}

#dock,
#chatwrap {
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 0 24px rgba(8, 26, 60, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.5);
}

button {
  font: inherit;
  color: var(--ink);
  background: linear-gradient(180deg, #3168ab, #17386a);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 6px rgba(0, 0, 0, 0.45);
  -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled) { border-color: var(--cyan); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- toast ---- */
#setcard {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(120% 80% at 50% 45%, rgba(10, 22, 46, 0.6), rgba(4, 10, 24, 0.92));
  backdrop-filter: blur(2px);
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Glossy blue card behind the set-complete / next-set text (the user's
   supplied reference image failed to upload again -- this is a close CSS
   recreation of that flat glossy-pill look: recover the real asset and
   swap it in as background-image here if it comes through later). */
#setcard .setcard__in {
  width: min(88vw, 340px);
  padding: 26px 20px;
  border-radius: 26px;
  background:
    radial-gradient(110px 80px at 14% 18%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%),
    radial-gradient(110px 80px at 86% 18%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #1a4fa0, #0a2a63);
  border: 3px solid #2ab0ff;
  box-shadow:
    0 0 0 2px rgba(6, 16, 34, 0.7),
    0 0 22px 3px rgba(42, 176, 255, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.setcard__kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.22em; color: var(--cyan); text-transform: uppercase; }
.setcard__kicker--pop {
  color: var(--gold);
  font-size: clamp(15px, 4.6vw, 22px);
  letter-spacing: 0.14em;
  text-shadow: 0 0 20px rgba(255, 207, 63, 0.6);
  animation: kickerPulse 0.9s ease-in-out infinite alternate;
}
@keyframes kickerPulse { from { opacity: 0.75; } to { opacity: 1; transform: scale(1.04); } }
.setcard__big {
  font-size: clamp(36px, 11vw, 64px);
  font-weight: 900;
  line-height: 0.95;
  color: var(--gold);
  text-shadow: 0 6px 0 #6a3d0a, 0 0 30px rgba(255, 207, 63, 0.5);
  margin: 6px 0;
}
.setcard__big--lc {
  color: #ff5a4d;
  text-shadow: 0 6px 0 #6a0f0a, 0 0 40px rgba(255, 90, 77, 0.7);
  font-size: clamp(30px, 9vw, 52px);
}
.setcard__sub { font-size: clamp(15px, 4.4vw, 22px); font-weight: 700; color: #fff; }
.setcard__lead { font-size: clamp(13px, 3.6vw, 17px); color: var(--muted); margin-top: 4px; }
.setcard__score { font-size: clamp(13px, 3.6vw, 17px); color: var(--cyan); font-weight: 700; margin-top: 6px; }
/* ---- on-board points: white "+10" over each marble left, then SET WIN ---- */
#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.fxpop {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-weight: 900;
  font-size: clamp(16px, 4.8vw, 24px);
  letter-spacing: 0.03em;
  color: #fff;
  --glow: 255, 207, 63;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 14px rgba(var(--glow), 0.95);
  animation: fxFloat 1.05s ease-out forwards;
}
.fxpop--you { --glow: var(--you-rgb); }
.fxpop--opp { --glow: var(--opp-rgb); }
.fxpop--above { transform: translate(-50%, -100%); }
.fxpop--big {
  font-size: clamp(24px, 8vw, 40px);
  color: #fff;
  text-shadow: 0 3px 0 var(--gold-deep), 0 0 24px rgba(255, 207, 63, 0.95);
  animation: fxSlam 1.5s ease-out forwards;
}
.fxpop small { display: block; font-size: 0.5em; font-weight: 800; letter-spacing: 0.14em; line-height: 1.1; margin-bottom: 2px; }
.fxpop span { display: block; line-height: 1; }
.fxpop--big { text-align: center; }
@keyframes fxFloat {
  0% { opacity: 0; scale: 0.4; translate: 0 6px; }
  15% { opacity: 1; scale: 1.35; }
  30% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; scale: 1; translate: 0 -34px; }
}
@keyframes fxSlam {
  0% { opacity: 0; scale: 0.3; }
  18% { opacity: 1; scale: 1.25; }
  32% { scale: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; scale: 1.05; translate: 0 -22px; }
}
.fxcap {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  text-align: center;
  font-size: clamp(14px, 4.2vw, 20px);
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #fff;
  --glow: 255, 207, 63;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 16px rgba(var(--glow), 0.9);
  animation: fxCap 0.35s ease-out;
}
.fxcap--you { --glow: var(--you-rgb); }
.fxcap--opp { --glow: var(--opp-rgb); }
@keyframes fxCap { from { opacity: 0; scale: 0.7; } to { opacity: 1; scale: 1; } }

/* a player's live points counter flashes as shot points are added / lost */
.pcard__points b { display: inline-block; font-variant-numeric: tabular-nums; }
.pcard__points b.bump-up { animation: bumpUp 0.6s ease-out; }
.pcard__points b.bump-down { animation: bumpDown 0.6s ease-out; }
@keyframes bumpUp { 0% { transform: scale(1.5); color: #0a8a3a; text-shadow: 0 0 8px rgba(255, 255, 255, 0.95); } 100% { transform: scale(1); } }
@keyframes bumpDown { 0% { transform: scale(1.4); color: #c40000; text-shadow: 0 0 8px rgba(255, 255, 255, 0.95); } 100% { transform: scale(1); } }

/* "POINTS x1.25 THIS SET" + the multiplier ladder, on the between-set card */
.setcard__mult {
  margin: 10px auto 0;
  font-size: clamp(15px, 4.6vw, 22px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 2px 0 #b8620a, 0 0 18px rgba(255, 207, 63, 0.7);
  animation: kickerPulse 0.9s ease-in-out infinite alternate;
}
.setcard__mult b { color: var(--gold); font-size: 1.25em; }
.setcard__ladder { display: flex; justify-content: center; gap: 6px; margin: 6px auto 0; flex-wrap: wrap; }
.setcard__step {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: clamp(10px, 2.9vw, 12px);
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}
.setcard__step b { color: #dbe8ff; }
.setcard__step.is-next { color: #4a2600; background: linear-gradient(180deg, #ffe25a, #f9b111); }
.setcard__step.is-next b { color: #4a2600; }
.setcard__note {
  font-size: clamp(12px, 3.4vw, 15px);
  color: var(--gold);
  font-weight: 600;
  margin: 12px auto 0;
  max-width: 22em;
  line-height: 1.35;
}
@keyframes slam {
  0% { transform: scale(2.2); opacity: 0; }
  55% { transform: scale(0.94); opacity: 1; }
  75% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

#toast {
  position: fixed;
  top: max(14px, var(--safe-area-inset-top, env(safe-area-inset-top)));
  left: 50%;
  transform: translate(-50%, -18px);
  z-index: 60;
  background: linear-gradient(180deg, #2a5aa0, #143972);
  border: 1px solid var(--cyan);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---- top bar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.brand {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.brand__logo { display: block; height: 46px; width: auto; max-width: 100%; object-fit: contain; }
.topbar__actions { display: flex; align-items: center; gap: 6px; }

/* the three glossy blue buttons are the art itself (icon included) */
.ui-btn {
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: center / contain no-repeat;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.ui-btn:hover:not(:disabled) { filter: brightness(1.08); }
.ui-btn:active:not(:disabled) { transform: translateY(2px) scale(0.97); }
.ui-btn--back { width: 38px; height: 42px; background-image: url("assets/ui-back.png"); }
.ui-btn--friends { width: 44px; height: 41px; background-image: url("assets/ui-friends.png"); }
.ui-btn--settings { width: 45px; height: 41px; background-image: url("assets/ui-settings.png"); }

/* gold coin pill */
.coins {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 11px 0 5px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 1.4px #7d4306;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(120, 60, 0, 0.55);
  background: linear-gradient(180deg, #ffe066 0%, #fdc40b 38%, #ffbf06 70%, #f0951a 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 0 #d8790a,
    0 3px 0 #a75d0a,
    0 5px 8px rgba(0, 0, 0, 0.4);
}
.coins__ico { display: block; width: 27px; height: 27px; }
.coins::after {
  content: "";
  position: absolute;
  right: 9%;
  top: 5px;
  width: 26%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.9);
}

/* ---- match bar: your card | set card | opponent card (blue / green = the marble colours) ---- */
#matchbar {
  display: grid;
  /* minmax(0, ..) -- not just 1fr -- so a long opponent name can never force
     this track wider than the other; both player cards stay exactly equal. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr) minmax(0, 1fr);
  gap: 8px;
  font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.pcard,
.setbox {
  position: relative;
  min-width: 0;
  border-radius: calc(var(--cu) * 9);
  border: calc(var(--cu) * 1.1) solid var(--edge);
  background: linear-gradient(180deg, var(--face1) 0%, var(--face2) 26%, var(--face3) 100%);
  box-shadow:
    inset 0 calc(var(--cu) * 1.6) 0 var(--rim),
    inset 0 calc(var(--cu) * -2.6) 0 var(--lip),
    0 6px 10px rgba(0, 0, 0, 0.45);
}
/* the small white glint on the top-right corner */
.pcard::after,
.setbox::after {
  content: "";
  position: absolute;
  top: calc(var(--cu) * 2.2);
  right: calc(var(--cu) * 5);
  width: calc(var(--cu) * 8);
  height: calc(var(--cu) * 1.7);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.9);
  transform: rotate(-14deg);
  pointer-events: none;
}
/* a card wears its player's marble colour: blue or green, whichever side they are on */
.pcard--blue {
  --face1: #1f92f0; --face2: #0e79d9; --face3: #026bc9;
  --lip: #07458b; --rim: #46aefa; --edge: #0a56ab;
  --dark: #01418a; --label: #8ec8ff; --outline: #0a3b86; --track: #013e79;
}
.pcard--green {
  --face1: #43d94c; --face2: #22b432; --face3: #129a26;
  --lip: #0a5c1a; --rim: #86ee7d; --edge: #0b6a20;
  --dark: #0a6a22; --label: #c2f7bd; --outline: #08541a; --track: #0b5a1e;
}
.pcard {
  display: grid;
  grid-template-columns: 31% minmax(0, 1fr);
  grid-template-areas: "av id" "st st" "pt pt";
  column-gap: calc(var(--cu) * 4.5);
  row-gap: calc(var(--cu) * 3.6);
  padding: calc(var(--cu) * 6) calc(var(--cu) * 6) calc(var(--cu) * 7.5);
  transition: box-shadow 0.2s;
}
.pcard--opp {
  grid-template-columns: minmax(0, 1fr) 31%;
  grid-template-areas: "id av" "st st" "pt pt";
}
.setbox {
  --face1: #b27a45; --face2: #975f2f; --face3: #8f5a2a;
  --lip: #6b3b1b; --rim: #dda46a; --edge: #76461f;
  display: flex;
  flex-direction: column;
  gap: calc(var(--cu) * 3.4);
  padding: calc(var(--cu) * 6) calc(var(--cu) * 5) calc(var(--cu) * 7.5);
}

/* whoever is on turn right now glows gold -- unmistakable at a glance */
.pcard.is-turn { animation: turnBlink 1.1s ease-in-out infinite; }
@keyframes turnBlink {
  0%, 100% {
    box-shadow:
      inset 0 calc(var(--cu) * 1.6) 0 var(--rim),
      inset 0 calc(var(--cu) * -2.6) 0 var(--lip),
      0 6px 10px rgba(0, 0, 0, 0.45),
      0 0 0 2px rgba(255, 207, 63, 0.9),
      0 0 0 0 rgba(255, 207, 63, 0.7);
  }
  50% {
    box-shadow:
      inset 0 calc(var(--cu) * 1.6) 0 var(--rim),
      inset 0 calc(var(--cu) * -2.6) 0 var(--lip),
      0 6px 10px rgba(0, 0, 0, 0.45),
      0 0 0 2px rgba(255, 207, 63, 1),
      0 0 14px 5px rgba(255, 207, 63, 0.9);
  }
}

.pcard__avatar {
  grid-area: av;
  align-self: start;
  aspect-ratio: 134 / 146;
  border-radius: calc(var(--cu) * 6);
  border: calc(var(--cu) * 1.5) solid #c98613;
  background: #ffd21a center / cover no-repeat;
  box-shadow: 0 calc(var(--cu) * 1.4) 0 #a86a0a, 0 3px 5px rgba(0, 0, 0, 0.35);
}
.pcard--you .pcard__avatar { background-image: url("assets/avatar-you.png"); }
.pcard--opp .pcard__avatar { background-image: url("assets/avatar-opp.png"); }
.pcard__id {
  grid-area: id;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--cu) * 2);
}
.pcard--opp .pcard__id { align-items: flex-end; text-align: right; }
.pcard__name {
  max-width: 100%;
  font-weight: 700;
  font-size: max(10.5px, calc(var(--cu) * 9.4));
  line-height: 1.05;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-text-stroke: max(0.7px, calc(var(--cu) * 0.7)) var(--outline);
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--cu) * 1) 0 var(--outline);
}
.pcard__level { font-weight: 500; font-size: max(9.5px, calc(var(--cu) * 8)); line-height: 1; color: var(--label); display: flex; align-items: center; gap: calc(var(--cu) * 3); }
.pcard--opp .pcard__level { justify-content: flex-end; }
.pcard__level .flag { font-size: max(9.5px, calc(var(--cu) * 8)); }
.pcard__level .flag[hidden] { display: none; }
.xpbar {
  width: 100%;
  height: max(5px, calc(var(--cu) * 6));
  padding: 1px;
  border-radius: 999px;
  background: var(--track);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.xpbar i {
  display: block;
  height: 100%;
  width: 12%;
  min-width: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe36a, #fdca0a 55%, #f0a90d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: width 0.4s ease;
}
.pcard__stats {
  grid-area: st;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--cu) * 3);
}
.pcard__stats span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cu) * 2.2);
  padding: calc(var(--cu) * 3.4) calc(var(--cu) * 1.5);
  border-radius: calc(var(--cu) * 4.5);
  background: var(--dark);
  box-shadow: inset 0 calc(var(--cu) * 1.3) 0 rgba(0, 0, 0, 0.28), inset 0 calc(var(--cu) * -1) 0 rgba(255, 255, 255, 0.08);
  font-weight: 500;
  font-size: max(9px, calc(var(--cu) * 7.4));
  line-height: 1;
  color: var(--label);
  white-space: nowrap;
}
.pcard__stats b {
  font-weight: 700;
  font-size: max(11px, calc(var(--cu) * 9.4));
  color: #ffd21a;
  -webkit-text-stroke: 0.5px rgba(60, 20, 0, 0.7);
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(60, 20, 0, 0.6);
}
/* sets won: one small marble per set (4 in a match) -- an empty socket until that
   set is won, then a marble in the card's own colour pops in */
.pcard__sets { gap: calc(var(--cu) * 1.3); }
.pcard__sets i {
  flex: none;
  width: calc(var(--cu) * 9.4);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.12);
}
.pcard__sets i.is-won {
  background: center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85), 0 0 5px rgba(255, 255, 255, 0.6), 0 1px 3px rgba(0, 0, 0, 0.55);
  animation: setPip 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.pcard--blue .pcard__sets i.is-won { background-image: url("assets/marble-blue.png"); }
.pcard--green .pcard__sets i.is-won { background-image: url("assets/marble-green.png"); }
@keyframes setPip { from { transform: scale(0.2); } to { transform: scale(1); } }

/* the REAL match-decider (gameState.points) -- always visible while playing,
   not just on the match-end screen. */
.pcard__points {
  grid-area: pt;
  margin: 0 calc(var(--cu) * 10);
  padding: calc(var(--cu) * 3.6) 0 calc(var(--cu) * 4);
  border-radius: calc(var(--cu) * 5);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.3em;
  text-align: center;
  font-weight: 700;
  font-size: max(12px, calc(var(--cu) * 10.6));
  line-height: 1;
  color: #6a1a0a;
  background: linear-gradient(180deg, #ffe25a 0%, #fecb0d 50%, #f9b111 100%);
  box-shadow: inset 0 calc(var(--cu) * 1.3) 0 rgba(255, 255, 255, 0.75), 0 calc(var(--cu) * 1.9) 0 #e28203, 0 4px 6px rgba(0, 0, 0, 0.35);
}

/* set balls: the art carries the number and the "SET n" tag */
.settabs { display: flex; justify-content: space-between; align-items: flex-start; }
.settab {
  position: relative;
  flex: 0 0 22.6%;
  aspect-ratio: 101 / 118;
  background: center top / contain no-repeat;
  font-size: 0;
  filter: brightness(0.9) saturate(0.9);
  transition: filter 0.2s, transform 0.2s;
}
.settab[data-set="1"] { background-image: url("assets/set-1.png"); }
.settab[data-set="2"] { background-image: url("assets/set-2.png"); }
.settab[data-set="3"] { background-image: url("assets/set-3.png"); }
.settab[data-set="4"] { background-image: url("assets/set-4.png"); }
.settab.is-active { filter: drop-shadow(0 0 5px rgba(255, 236, 130, 0.95)); transform: scale(1.12); z-index: 1; }
.settab.is-done { filter: none; }
/* small winner dot, like a mini scoreboard strip: who actually cleared the
   board that set (or grey for a void/drawn one) */
.settab[data-winner]::before {
  content: "";
  position: absolute;
  right: -7%;
  top: 52%;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid #4a250d;
  background: var(--muted);
  z-index: 2;
}
.settab[data-winner="you"]::before { background: var(--you); }
.settab[data-winner="opp"]::before { background: var(--opp); }

.lead { display: flex; flex-direction: column; gap: calc(var(--cu) * 3.2); text-align: center; }
.lead__label {
  align-self: center;
  width: 96%;
  padding: calc(var(--cu) * 2.8) 0;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
  font-weight: 600;
  font-size: max(8.5px, calc(var(--cu) * 6.6));
  letter-spacing: 0.03em;
  line-height: 1;
  color: #f6dfb0;
  background: linear-gradient(180deg, #75401b, #693718);
  box-shadow: inset 0 calc(var(--cu) * 1.3) 0 rgba(0, 0, 0, 0.3), 0 calc(var(--cu) * 1) 0 rgba(255, 214, 150, 0.18);
}
.lead__value {
  padding: calc(var(--cu) * 3.4) 0 calc(var(--cu) * 2.6);
  border-radius: calc(var(--cu) * 6);
  font-weight: 700;
  font-size: calc(var(--cu) * 23);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fdd20d;
  -webkit-text-stroke: max(1px, calc(var(--cu) * 1)) #7a4300;
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--cu) * 2) 0 #b8760b;
  background: linear-gradient(180deg, #77421c, #6a3717);
  box-shadow: inset 0 calc(var(--cu) * 2) 0 rgba(0, 0, 0, 0.3), 0 calc(var(--cu) * 1.4) 0 #4a250d;
}
/* this set's points multiplier, as a small gold chip on the score box (hidden at x1) */
.lead__value { position: relative; }
.lead__value::after {
  content: "\00d7" attr(data-mult);
  position: absolute;
  top: calc(var(--cu) * -2.6);
  right: calc(var(--cu) * 2.4);
  padding: calc(var(--cu) * 1.3) calc(var(--cu) * 3);
  border-radius: 999px;
  font-size: max(8px, calc(var(--cu) * 6));
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: #5a2600;
  -webkit-text-stroke: 0;
  text-shadow: none;
  background: linear-gradient(180deg, #ffe25a, #f9b111);
  box-shadow: 0 1px 0 #b8620a, 0 2px 3px rgba(0, 0, 0, 0.4);
}
.lead__value[data-mult="1"]::after,
.lead__value:not([data-mult])::after { display: none; }
.lead__sub { min-height: 1em; font-weight: 500; font-size: max(9px, calc(var(--cu) * 7.2)); line-height: 1.15; color: #f6dfb0; }
.lead__sub[data-tone="you"] { color: #b9ffd0; }
.lead__sub[data-tone="opp"] { color: #ffc79a; }
.lead__sub[data-tone="lc"] { color: var(--gold); }

/* ---- board ---- */
#stage {
  position: relative;
  aspect-ratio: 1 / 1;
  /* fit the screen: the board takes whatever height is left after everything
     else in the game window (see --stack on #app), so nothing needs scrolling.
     vh first as a fallback for older WebViews, then dvh (the real visible height).
     BOARD.WIDTH/BOARD.HEIGHT = 1 (square) -- converts the leftover height
     budget straight into the matching width. */
  width: min(100%, calc(100vh - var(--stack)));
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55));
}
@supports (height: 100dvh) {
  #stage { width: min(100%, calc(100dvh - var(--stack))); }
}
#board { width: 100%; height: 100%; touch-action: none; display: block; }
#fx-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  padding: 0 6%;
  text-align: center;
  /* #stage's own width is derived from leftover HEIGHT (see #stage's comment),
     so on a short screen the board -- and this banner's box, since #stage
     clips with overflow:hidden -- can end up much narrower than a fixed
     30px bold banner needs for something like "Finding an opponent....".
     A vw-based clamp shrinks it with the board instead of clipping/spilling
     past the wood edges; line-height gives the wrapped 2-line case room. */
  font-size: clamp(15px, 6vw, 30px);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 0 var(--gold-deep), 0 0 18px rgba(255, 207, 63, 0.8);
  pointer-events: none;
}
#fx-banner.pop { animation: pop 0.9s ease-out; }
@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  20% { transform: scale(1.15); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.05) translateY(-14px); opacity: 0; }
}
/* Shown for BOTH players' turns, not just yours -- but styled differently so
   it's obvious at a glance whose clock is running, no text required:
   your turn is full-opacity with a glow; the opponent's is dimmed and flat. */
#timerbar {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin: 0 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  opacity: 0.5;
  transition: opacity 0.25s ease;
}
#timerbar.mine { opacity: 1; }
#timerbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: #45d17a;
  transform-origin: left;
  transition: transform 0.2s linear, background-color 0.3s linear, box-shadow 0.3s linear;
}
/* last few seconds: the bar itself pulses so a stalling player can't miss it */
#timerbar.low i { animation: timerLow 0.5s ease-in-out infinite; }
@keyframes timerLow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

#overlay {
  position: absolute;
  inset: 9%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(6, 16, 34, 0.86);
  border-radius: 12px;
  text-align: center;
  padding: 20px;
}
/* the forfeit card is a self-contained image with its own border/shadow --
   drop the generic dark panel behind it so it isn't double-framed. */
#overlay.is-plain { background: none; padding: 0; border-radius: 0; }
#overlay h2 { margin: 0; font-size: 22px; color: #fff; }
#overlay h2.room-code {
  font-size: clamp(32px, 10vw, 56px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 0 3px 0 #6a3d0a, 0 0 20px rgba(255, 207, 63, 0.5);
}
#overlay p { margin: 0; color: var(--muted); }
.ov-actions { display: flex; gap: 10px; margin-top: 6px; }
/* pill + glossy shine -- same recipe as Home's Play/Solo/Friend button art. */
.ov-actions button {
  position: relative;
  font-weight: 800;
  padding: 11px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5a6270, #2b303a);
  border-color: #8a93a3;
  color: #fff;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.4),
    inset 0 -8px 14px rgba(0, 0, 0, 0.28),
    0 6px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.14s ease, filter 0.14s ease;
}
.ov-actions button::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 8%;
  height: 32%;
  border-radius: 999px;
  background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
@media (hover: hover) {
  .ov-actions button:hover { filter: brightness(1.1); }
}
.ov-actions .ov-danger {
  background: linear-gradient(180deg, #ff8a6a, #c8362c);
  border-color: #ffb3ac;
  color: #fff;
}

/* ---- Forfeit confirm: the user's supplied template art
   (assets/forfeit-card.png) used literally, with real hit-tested buttons
   over its painted X / Cancel / Forfeit. Same pattern as .daily-banner
   and .profile. ---- */
.forfeitcard { position: relative; width: 100%; }
.forfeitcard__bg { display: block; width: 100%; height: auto; }
.forfeitcard__hit { position: absolute; border: none; background: none; box-shadow: none; padding: 0; cursor: pointer; }
.forfeitcard__hit--close { top: 6.8%; left: 39.1%; width: 21.8%; height: 28.3%; border-radius: 50%; }
.forfeitcard__hit--cancel { top: 63%; left: 6.5%; width: 42.3%; height: 20.5%; border-radius: 999px; }
.forfeitcard__hit--forfeit { top: 63%; left: 51.1%; width: 42.3%; height: 20.5%; border-radius: 999px; }

/* ---- Play with Friend room card: the user's supplied art (assets/invite-card.png) used literally, the room
   code drawn in its empty box, and real hit-tested buttons over its painted X / Invite a Friend / Copy Invite.
   It is a popup layer on the page, not inside #overlay: the art is portrait and taller than the board, and
   #stage clips and filters its children. --w is the card's width (kept short enough to fit the screen's height);
   the code's type size follows it. Boxes are % of the 800x1066 art. ---- */
.invitelayer {
  position: fixed;
  inset: 0;
  z-index: 50; /* above the game, below the toast (60) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(4, 10, 24, 0.62);
}
.invitecard { --w: min(340px, 88vw, 66vh); position: relative; flex: none; width: var(--w); }
.invitecard__bg { display: block; width: 100%; height: auto; }
.invitecard__code {
  position: absolute;
  left: 14.9%;
  top: 43.9%;
  width: 70%;
  height: 11.6%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.1em; /* the trailing letter-spacing would otherwise push the code off centre */
  font-weight: 900;
  font-size: calc(var(--w) * 0.125);
  letter-spacing: 0.1em;
  color: var(--gold);
  text-shadow: 0 3px 0 #6a3d0a, 0 0 18px rgba(255, 207, 63, 0.5);
  pointer-events: none;
}
.invitecard__hit { position: absolute; border: none; background: none; box-shadow: none; padding: 0; cursor: pointer; }
@media (hover: hover) {
  .invitecard__hit:hover { background: rgba(255, 255, 255, 0.1); }
}
.invitecard__hit:active { background: rgba(0, 0, 0, 0.14); }
.invitecard__hit--close { top: 8.1%; left: 81.5%; width: 15.4%; height: 11.5%; border-radius: 50%; }
.invitecard__hit--invite { top: 60.8%; left: 15%; width: 70%; height: 9.3%; border-radius: 999px; }
.invitecard__hit--copy { top: 73%; left: 15%; width: 70%; height: 8.6%; border-radius: 999px; }

/* ---- Solo Run's "Quit level?" card: the user's supplied template PNG
   (assets/soloquit-card.png), title/subtitle baked in since that text
   never changes -- same "art + invisible hotspots" pattern as .forfeitcard
   above (which is the online-match equivalent of this same prompt). ---- */
.soloquit { position: relative; width: 100%; }
.soloquit__bg { display: block; width: 100%; height: auto; }
.soloquit__hit { position: absolute; border: none; background: none; box-shadow: none; padding: 0; font-size: 0; cursor: pointer; }
.soloquit__hit--keep { top: 50.63%; left: 8.42%; width: 82.71%; height: 22.23%; border-radius: 999px; }
.soloquit__hit--quit { top: 74%; left: 25%; width: 50%; height: 16%; }

/* ---- match-end card: WIN / LOSE / DRAW, cartoonish, colour-coded ---- */
.matchend {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.matchend__kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.matchend__title {
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 900;
  line-height: 1.05;
  margin: 2px 0;
}
.matchend--win .matchend__title {
  color: var(--gold);
  text-shadow: 0 4px 0 #6a3d0a, 0 0 26px rgba(255, 207, 63, 0.65);
}
.matchend--lose .matchend__title {
  color: #ff9a8f;
  text-shadow: 0 4px 0 #5e150f, 0 0 20px rgba(236, 90, 80, 0.5);
}
.matchend--draw .matchend__title {
  color: var(--cyan);
  text-shadow: 0 4px 0 #0a3c5e, 0 0 20px rgba(99, 193, 255, 0.5);
}
.matchend__sub { font-size: clamp(15px, 4.2vw, 19px); font-weight: 700; color: #fff; }
.matchend__note { font-size: clamp(11px, 3.2vw, 14px); color: var(--muted); margin-top: 2px; }

/* win/lose: the user's own template art (assets/matchend-win.png,
   assets/matchend-lose.png) is the whole card -- "MATCH OVER" and the big
   title are baked into the image. Only the points/sets line and lead-text
   note go on top, sized to each image's own blank panel (measured off the
   art -- the two templates aren't the same shape, so the zone differs). */
/* The card is deliberately smaller than the overlay (73% of it = about 60% of the board), and the SAME width for win and lose so the
   two titles match: the Challenge Again block sits right under it, and at full width it ran off the bottom of the board. */
.matchend--win, .matchend--lose { display: block; width: 73%; animation: none; }
.matchend__card { position: relative; width: 100%; }
.matchend__bg { display: block; width: 100%; height: auto; animation: slam 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
.matchend__zone {
  position: absolute;
  left: 8%;
  width: 84%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}
.matchend--win .matchend__zone { top: 70%; height: 19%; }
.matchend--lose .matchend__zone { top: 55%; height: 37%; }
.matchend--win .matchend__zone .matchend__sub,
.matchend--lose .matchend__zone .matchend__sub {
  font-weight: 800;
  color: #fff3d6;
  text-shadow: 0 2px 0 #052a66, 0 0 10px rgba(0, 0, 0, 0.4);
}
/* the win panel is shorter than lose's, so its points/sets line -- often the
   longer of the two once "· Sets X–Y" is appended -- needs a smaller cap to
   stand a chance of staying on one line instead of eating the panel. */
.matchend--win .matchend__zone .matchend__sub { font-size: clamp(10px, 3.1vw, 13px); }
.matchend--lose .matchend__zone .matchend__sub { font-size: clamp(11px, 3.4vw, 16px); }
.matchend .nw { white-space: nowrap; }
.matchend--win .matchend__zone .matchend__note,
.matchend--lose .matchend__zone .matchend__note {
  font-size: clamp(9px, 2.8vw, 12px);
  font-weight: 600;
  color: #bcd6ff;
  margin-top: 3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ---- rematch prompt: under the result, in the middle of the board. Both sides get a
   few seconds to say yes or no; a rematch only starts if both say yes in time. ---- */
.rematch {
  width: 100%;
  margin-top: -6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.rematch__msg { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 700; color: #fff; }
.rematch__msg.is-called { color: var(--gold); }
/* the user's own template art (assets/btn-challenge-again.png) -- icon and
   label are baked in, so the button is just that image, no drawn pill. Its
   label span still changes in JS ("Challenge again" -> "Waiting..." once
   you've said yes and it's disabled) -- there's no art for that second
   state, so the label stays transparent (the art speaks for itself) until
   disabled, when it's shown as plain text over a dimmed button instead. */
.rematch__yes {
  position: relative;
  width: 50%;
  aspect-ratio: 1900 / 562;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: center / contain no-repeat url("assets/btn-challenge-again.png");
  box-shadow: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}
/* under the (smaller) painted result card the button is a bigger share of the card's width, so it stays about the same size on screen */
.matchend--win .rematch__yes, .matchend--lose .rematch__yes { width: 72%; }
.matchend--win .rematch, .matchend--lose .rematch { margin-top: 3px; } /* clear of the smaller card's glowing edge */
.rematch__yeslabel { color: transparent; font-size: 11px; font-weight: 700; }
.rematch__yes:disabled {
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) grayscale(0.7);
  opacity: 0.85;
}
.rematch__yes:disabled .rematch__yeslabel { color: #cfe0f5; }
.rematch__yes.is-called { animation: rematchCall 0.9s ease-in-out infinite; }
@keyframes rematchCall {
  0%, 100% { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 0 rgba(255, 207, 63, 0)); transform: scale(1); }
  50% { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 10px rgba(255, 207, 63, 0.9)); transform: scale(1.04); }
}
/* the countdown is a small notification-bubble badge on the button's corner --
   same recipe as the undo button's remaining-shots badge (.ico-undo b) --
   instead of a bar or a big centered number. */
.rematch__secs {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  color: #4a2a05;
  background: linear-gradient(180deg, #ffe382, var(--gold-deep));
  border: 1.5px solid #fff2c0;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  font-variant-numeric: tabular-nums;
  animation: rematchTick 0.3s ease-out;
}
.rematch__secs:empty { display: none; }
@keyframes rematchTick {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.rematch__no {
  margin-top: -5px;
  padding: 2px 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  background: none;
  border-color: transparent;
  box-shadow: none;
  text-decoration: underline;
}
.rematch.is-over .rematch__yes,
.rematch.is-over .rematch__no { display: none; }
/* Watch Replay waits until the offer is over (No thanks, Time's up, or the opponent said no). While the offer is live the only
   choices are Challenge again and No thanks: tapping Watch Replay used to end the offer anyway, so it was a second "No thanks". */
.rematch:not(.is-over) .rematch__replay { display: none; }
/* "Watch replay" under the rematch buttons -- the user's painted button (assets/btn-watch-replay.webp, 640 x 156), used literally.
   It stays up after the rematch window closes, since a saved match can be watched any time (also from Profile). */
/* the rematch extras are stacked and centred under Challenge again: No thanks, then the painted Watch Replay button (a small
   positive gap above, since the old -5px pulled the button up into the line of text above it) */
.rematch__row { display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 2px; }
/* stacked under Challenge again, all centred: No thanks, then Watch Replay. Nothing in it may wrap or shrink. */
.rematch__row .rematch__no { margin-top: 0; padding: 2px 10px; flex: none; white-space: nowrap; }
/* with a replay to offer, the result card gives up a little height (and its line of text a little size) so Challenge
   again, No thanks and Watch replay all fit on the board */
.matchend.has-replay .matchend__card { width: 82%; margin: 0 auto; }
.matchend--win.has-replay .matchend__zone .matchend__sub { font-size: clamp(9px, 2.6vw, 12px); }
.matchend--lose.has-replay .matchend__zone .matchend__sub { font-size: clamp(10px, 3vw, 15px); }
.matchend--win.has-replay .matchend__zone .matchend__note,
.matchend--lose.has-replay .matchend__zone .matchend__note { font-size: clamp(9px, 2.6vw, 12px); }
/* the points line wraps to two lines in the smaller card, so the three lines were as tall as the blue panel and the last one sat on the
   panel's bottom edge. Now the text is sized to the panel (the zone is the band between the stars and the bottom edge), with tight lines. */
.matchend.has-replay .matchend__zone { gap: 0; }
.matchend.has-replay .matchend__zone .matchend__sub { line-height: 1.1; }
.matchend.has-replay .matchend__zone .matchend__note { margin-top: 0; line-height: 1.15; }
.matchend--win.has-replay .matchend__zone { top: 63%; height: 19%; }
.matchend--lose.has-replay .matchend__zone { top: 53%; height: 30%; }
.rematch__replay {
  display: block;
  flex: none;
  width: 114px;
  margin: 0;
  padding: 0;
  line-height: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  cursor: pointer;
}
.rematch__replay img { display: block; width: 100%; height: auto; }

#status-line { margin: 0; text-align: center; line-height: 18px; }
#status { font-weight: 700; font-size: 13px; }
#status.turn-you { color: var(--you); }
#status.turn-opp { color: var(--opp); }
#hint { margin: 0; text-align: center; color: var(--muted); font-size: 11px; min-height: 1.1em; }

/* ---- dock: power readout (aiming already shows power live via the drag
   arrow on the board -- this is just a compact confirmation, not a control:
   dragging to aim is the only way to shoot, so there's no separate button) ---- */
#bottombar { display: flex; align-items: center; gap: 6px; }
#dock { flex: 1 1 0; min-width: 0; padding: 3px 8px; display: flex; align-items: center; }
#dock.is-idle { opacity: 0.4; filter: grayscale(0.6); } /* nothing to shoot: the match is over */
.powerbox { flex: 1; min-width: 0; display: flex; justify-content: center; }
.powermeter {
  position: relative;
  /* the art's own aspect ratio (960x132) -- height + aspect-ratio (not a
     stretched 100% 100% background) so "Shot Power" never gets squashed */
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 132;
  background: center / 100% 100% no-repeat url("assets/power-meter.png");
  border-radius: 8px;
}
.powermeter .seg { display: none; } /* segments now come from the art */
.powermeter.charging {
  animation: pmCharge 0.9s ease;
}
.powermeter.charging::after {
  content: "";
  position: absolute;
  inset: 6% 3%;
  border-radius: 5px;
  background: linear-gradient(90deg, #3fc46b, #ffd23f 45%, #ff6a2e 75%, #ec2f22);
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: pmSheen 0.9s ease;
  pointer-events: none;
}
@keyframes pmCharge {
  0%, 100% { box-shadow: 0 0 0 rgba(120, 200, 255, 0); }
  40% { box-shadow: 0 0 22px 2px rgba(120, 220, 255, 0.75), 0 0 40px rgba(255, 210, 90, 0.5); }
}
@keyframes pmSheen {
  0% { opacity: 0; filter: brightness(2); }
  35% { opacity: 0.7; }
  100% { opacity: 0; }
}
.powermeter__mask {
  position: absolute;
  top: 6%;
  bottom: 6%;
  right: 3%;
  left: 32%; /* JS moves this: left = 32% + power * 65% */
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(4, 10, 22, 0.35), rgba(4, 10, 22, 0.92) 45%);
  pointer-events: none;
}
/* ---- controls ---- */
#controls { flex: 1 1 0; min-width: 0; display: flex; gap: 6px; justify-content: center; }
/* Real "Play" button art the user supplied (previous upload attempt
   failed, so this was a CSS-recreated gold pill for a while -- swapped
   for the literal asset now that it came through). Same pattern as the
   Home screen's .gbtn--img buttons: strip the CSS chrome, size the image. */
#btn-play {
  flex: 1;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-play img {
  display: block;
  width: 100%;
  max-width: 140px;
  height: auto;
}
#btn-next { flex: 1; padding: 8px 10px; background: linear-gradient(180deg, #ffe382, var(--gold-deep)); color: #4a2a05; border-color: #fff2c0; font-weight: 700; }

/* ---- side buttons (icon + label) ---- */
#sidebtns { flex: none; display: flex; gap: 3px; }
.sidebtn {
  flex: none;
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  font-size: 9px;
  line-height: 11px;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
}
.sidebtn:hover:not(:disabled) { color: var(--ink); }
.sidebtn__ico {
  position: relative;
  width: 34px;
  height: 32px;
  background: center / contain no-repeat;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
.ico-undo { background-image: url("assets/btn-undo-v2.png"); }
/* the shot-count badge sits on the icon like a notification bubble, not as
   plain inline text floating over the artwork */
.ico-undo b {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  color: #4a2a05;
  background: linear-gradient(180deg, #ffe382, var(--gold-deep));
  border: 1.5px solid #fff2c0;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.ico-chat { background-image: url("assets/btn-chat.png"); }
/* unread-message dot -- shown while the opponent has sent something and the
   chat window hasn't been opened since (see game.js's MSG.CHAT handler) */
#chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff4b3e;
  border: 1.5px solid #fff2c0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  animation: chatBadgePop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes chatBadgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.ico-forfeit { background-image: url("assets/btn-forfeit.png"); }
.ico-sound { background-image: url("assets/btn-sound-on.png"); }
#btn-sound.snd-off .ico-sound { background-image: url("assets/btn-sound-off.png"); }
/* a bot isn't a real person -- no chat button for it (Solo Run already
   hides it the same way for its own reason: #app.is-solo, in solo.css) */
#app.is-practice #btn-chat { display: none; }

/* ---- chat: a floating popup, not an inline panel that pushes the page down ---- */
#chatbackdrop {
  position: fixed;
  inset: 0;
  z-index: 57;
  background: rgba(4, 10, 22, 0.5);
}
/* Blue glossy template the user supplied -- same colour/border/shine recipe
   already used for the Solo level card and set-complete card. */
#chatwrap {
  position: fixed;
  z-index: 58;
  left: 50%;
  bottom: max(12px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  width: min(94vw, 420px);
  max-height: min(64vh, 440px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, #0f6cf0 0%, #0a4bb8 55%, #06398f 100%);
  border: 3px solid #29b6ff;
  border-radius: 20px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 16px 40px rgba(0, 0, 0, 0.6);
}
.chatwrap__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  background: linear-gradient(180deg, #6fd0ff, #1d84ff 60%, #0f6cf0);
  border: 2px solid #073a8a;
  border-radius: 14px;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.6), 0 3px 0 #073a8a;
}
.chatwrap__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 #073a8a;
  -webkit-text-stroke: 0.6px #073a8a;
  paint-order: stroke fill;
  letter-spacing: 0.02em;
}
.chatwrap__ico { font-size: 16px; -webkit-text-stroke: 0; }
.chatwrap__close {
  position: absolute;
  right: -6px;
  top: -10px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: radial-gradient(circle at 32% 28%, #eaf7ff 0%, #6fc8ff 22%, #1d74e6 62%, #0a3a90 100%);
  border: 2px solid #052a66;
  box-shadow: 0 0 0 2px #4fd0ff, 0 3px 0 #041c49, 0 4px 8px rgba(0, 0, 0, 0.4);
}
#chatlog {
  list-style: none;
  margin: 0;
  padding: 10px;
  flex: 1;
  min-height: 60px;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(3, 20, 60, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
}
#chatlog li.me { color: #fff; }
#chatlog li.them { color: #ffd97a; }
#chatlog li.sys { color: #cfe8ff; font-style: italic; font-weight: 600; }
/* ---- emoji picker: a row of quick-tap reactions above the input, toggled
   by #btn-emoji -- tapping one inserts it into #chatinput at the cursor. ---- */
#emojipanel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  margin-bottom: 8px;
  max-height: 112px;
  overflow-y: auto;
  background: rgba(3, 20, 60, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
}
#emojipanel button {
  font-size: 22px;
  line-height: 1;
  padding: 4px 5px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#emojipanel button:hover, #emojipanel button:active { background: rgba(255, 255, 255, 0.15); }
/* ---- quick chat: one-tap friendly messages (quickchat.js); a bot only ever says these ---- */
#quickchat {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
#quickchat button {
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  padding: 7px 11px;
  color: #eef4ff;
  background: rgba(3, 20, 60, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  cursor: pointer;
}
#quickchat button:hover, #quickchat button:active { background: rgba(255, 255, 255, 0.18); }
#chatform { display: flex; gap: 8px; }
#btn-emoji { font-size: 20px; }
#chatinput {
  flex: 1;
  min-width: 0; /* an input's own minimum width pushed Send out of the chat window on a 320 px screen */
  font: inherit;
  color: #fff;
  background: rgba(3, 20, 60, 0.5);
  border: 2px solid #073a8a;
  border-radius: 999px;
  padding: 9px 14px;
}
#chatinput::placeholder { color: #a9c8f5; }
#chatform button {
  flex: 0 0 44px;
  padding: 0;
  color: #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #eaf7ff 0%, #6fc8ff 22%, #1d74e6 62%, #0a3a90 100%);
  border: 2px solid #052a66;
  box-shadow: 0 3px 0 #041c49, 0 4px 8px rgba(0, 0, 0, 0.4);
}

footer { display: none; text-align: center; padding-top: 2px; }
@media (min-height: 860px) { footer { display: block; } }
.muted { color: var(--muted); font-size: 11px; }

@media (max-width: 380px) {
  #btn-play { min-width: 150px; }
  .shoot-btn { flex-basis: 74px; width: 74px; height: 74px; }
}

/* Set by playables.js while the host (e.g. YouTube Playables) has paused the
   game -- blocks input without touching every animation loop individually. */
body.yt-paused { pointer-events: none; }

/* ---- a big hit (a combo) gives the board a short shake ---- */
#board.shake { animation: boardShake 0.28s linear; }
@keyframes boardShake {
  0%, 100% { transform: translate(0, 0); }
  14% { transform: translate(calc(var(--shake, 3px) * -1), calc(var(--shake, 3px) * 0.5)); }
  28% { transform: translate(var(--shake, 3px), calc(var(--shake, 3px) * -0.6)); }
  44% { transform: translate(calc(var(--shake, 3px) * -0.7), calc(var(--shake, 3px) * 0.4)); }
  62% { transform: translate(calc(var(--shake, 3px) * 0.5), 0); }
  80% { transform: translate(calc(var(--shake, 3px) * -0.25), calc(var(--shake, 3px) * 0.2)); }
}
