@font-face {
  font-family: Fraunces;
  src: url("../assets/fonts/fraunces.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Figtree;
  src: url("../assets/fonts/figtree.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --app-h: 100vh; /* JS sets this to visualViewport/innerHeight in px; never svh/dvh */
  --cream: #f6f0ea;
  --cream-deep: #ebe1d6;
  --tile: #e8ddd3;
  --grout: rgba(120, 92, 78, 0.11);
  --ink: #2c2622;
  --ink-soft: #5c514a;
  --blush: #c1958a;
  --blush-deep: #9a6e66;
  --amber: #c99a3a;
  --amber-bright: #e8b84a;
  --ottoman: #d4b0a6;
  --shadow: 0 18px 40px rgba(60, 40, 32, 0.18);
  --beat: 0.625s;
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: Figtree, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    linear-gradient(var(--grout) 1px, transparent 1px),
    linear-gradient(90deg, var(--grout) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center top;
  min-height: 100%;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px 16px 28px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.top {
  text-align: center;
  margin: 4px 0 14px;
}
.top h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3.1rem);
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.05;
  font-variation-settings: "SOFT" 50, "WONK" 0.4, "opsz" 48;
}
.tag {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.board-card {
  display: none;
  background: rgba(255, 250, 246, 0.86);
  border: 1px solid rgba(120, 92, 78, 0.12);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(60, 40, 32, 0.06);
}
.board-card h2 {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 10px;
}
.board-card ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}
.board-card li,
.end-board li {
  display: grid;
  grid-template-columns: 1.5em minmax(0, 1fr) auto;
  column-gap: 8px;
  row-gap: 1px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(120, 92, 78, 0.1);
  font-variant-numeric: tabular-nums;
}
.board-card li:last-child { border-bottom: 0; }
.board-card li::before,
.end-board li::before {
  counter-increment: rank;
  content: counter(rank);
  color: var(--blush-deep);
  font-weight: 600;
  grid-column: 1;
  grid-row: 1;
  width: auto;
  text-align: right;
}
.board-card .empty { color: var(--ink-soft); font-size: 0.92rem; padding: 6px 0; }

.hud {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 10px;
}
.stat-score .value {
  font-size: 1.85rem;
  letter-spacing: -0.03em;
}
.stat .label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stat .value {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.lives {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
  flex-wrap: wrap;
}
.lives-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-right: 2px;
}
.rule-line {
  margin: -4px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-align: left;
}
.life {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber-bright);
  box-shadow: inset 0 0 0 2px rgba(90, 60, 20, 0.15);
}
.life.gone {
  background: transparent;
  box-shadow: inset 0 0 0 2px rgba(92, 81, 74, 0.35);
}


.stage-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #d9cfc4;
}
.stage-art {
  position: absolute;
  inset: 0;
  transform-origin: 100% 100%;
  transform: scale(1.08);
  pointer-events: none;
}
.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.stage img#cat,
.stage .cat-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: 100% 100%;
  display: block;
  pointer-events: none;
}
.stage .cat-canvas { z-index: 1; }
.cat-motion.is-canvas img#cat { opacity: 0; }
.cat-motion {
  position: absolute;
  inset: 0;
  transform-origin: 50% 78%;
}
.cat-motion.dance-1,
.cat-motion.dance-2,
.cat-motion.fever-dance,
.cat-motion.is-breathe,
.cat-motion.clap-pop,
.cat-motion.clap-bounce { animation: none; transform: none; }
@keyframes catBreathe {
  0%, 100% { transform: none; }
  50% { transform: none; }
}

@keyframes bounce {
  0%, 100% { transform: none; }
}

@keyframes wiggle {
  0%, 100% { transform: none; }
}

@keyframes feverDance {
  0%, 100% { transform: none; }
}

.beat-ring {
  /* A halo around the cat that expands outward — not a thin arc dragging across the body. */
  position: absolute;
  left: 38%;
  top: 32%;
  width: 62%;
  height: 58%;
  border-radius: 50%;
  border: 6px solid rgba(232, 184, 109, 0);
  box-shadow: none;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transform-origin: 50% 55%;
}
.beat-ring.pulse {
  animation: ring 0.55s ease-out 1;
}
@keyframes ring {
  0% {
    opacity: 0.95;
    transform: scale(0.78);
    border-color: rgba(201, 140, 48, 0.95);
    box-shadow: 0 0 0 3px rgba(255, 248, 238, 0.7), 0 0 18px rgba(232, 184, 109, 0.55);
  }
  100% {
    opacity: 0;
    transform: scale(1.18);
    border-color: rgba(201, 140, 48, 0);
    box-shadow: 0 0 0 0 rgba(255, 248, 238, 0);
  }
}

.fever-wash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(232, 184, 74, 0.62), transparent 42%),
    radial-gradient(circle at 80% 20%, rgba(193, 149, 138, 0.58), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(255, 236, 180, 0.32), transparent 55%),
    radial-gradient(circle at 70% 80%, rgba(243, 210, 122, 0.5), transparent 40%),
    linear-gradient(180deg, rgba(255, 220, 140, 0.28), rgba(154, 110, 102, 0.22));
  mix-blend-mode: soft-light;
  animation: wash 0.7s ease-in-out infinite alternate;
}
@keyframes wash {
  from { filter: hue-rotate(-14deg) brightness(1.06) saturate(1.18); opacity: 0.82; }
  to { filter: hue-rotate(16deg) brightness(1.24) saturate(1.28); opacity: 1; }
}
body.fever {
  background-color: #f3e4c9;
  animation: bodyPulse 0.65s ease-in-out infinite alternate;
}
@keyframes bodyPulse {
  from { background-color: #f7e7c2; }
  to { background-color: #efc57a; }
}
body.fever .stage-wrap {
  box-shadow: 0 0 0 3px rgba(232, 184, 74, 0.55), 0 0 36px rgba(232, 184, 74, 0.45), var(--shadow);
  animation: feverGlow 0.7s ease-in-out infinite alternate;
}
body.fever .stage-wrap.shake {
  animation: feverShake 0.42s ease-out, feverGlow 0.7s ease-in-out infinite alternate;
}
@keyframes feverGlow {
  from { box-shadow: 0 0 0 3px rgba(232, 184, 74, 0.4), 0 0 22px rgba(232, 184, 74, 0.28), var(--shadow); }
  to { box-shadow: 0 0 0 5px rgba(255, 220, 140, 0.75), 0 0 48px rgba(232, 184, 74, 0.55), var(--shadow); }
}
@keyframes feverShake {
  0%, 100% { transform: none; }
}
.fever-flash {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 244, 210, 0.88), rgba(232, 184, 74, 0.45) 48%, transparent 72%);
  animation: feverFlash 0.38s ease-out forwards;
}
@keyframes feverFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
body.fever #streak {
  color: #8a5a10;
  display: inline-block;
  transform-origin: 50% 80%;
  animation: comboPulse 0.4s ease-in-out infinite alternate;
}
@keyframes comboPulse {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}
body.fever .beat-ring.pulse {
  animation: ringFever 0.5s ease-out 1;
}
@keyframes ringFever {
  0% {
    opacity: 1;
    transform: scale(0.76);
    border-color: rgba(232, 184, 74, 1);
    box-shadow: 0 0 0 3px rgba(255, 248, 238, 0.8), 0 0 22px rgba(232, 184, 74, 0.7);
  }
  100% {
    opacity: 0;
    transform: scale(1.24);
    border-color: rgba(232, 184, 74, 0);
    box-shadow: 0 0 0 0 rgba(255, 248, 238, 0);
  }
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.cheese {
  position: absolute;
  z-index: 5;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 6px 8px rgba(60, 40, 32, 0.28));
  animation: cheeseSpin 1.6s linear infinite;
}
.cheese img { width: 100%; height: 100%; display: block; pointer-events: none; }
@keyframes cheeseSpin {
  0% { transform: rotate(-8deg); }
  50% { transform: rotate(10deg); }
  100% { transform: rotate(-8deg); }
}

.toast {
  position: static;
  z-index: 6;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.05rem, 4.6vw, 1.55rem);
  color: #7a4e14;
  background: rgba(255, 247, 230, 0.92);
  padding: 6px 18px 7px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(60, 40, 32, 0.16);
  pointer-events: none;
  letter-spacing: -0.02em;
  width: max-content;
  max-width: min(92%, 100%);
  white-space: nowrap;
  box-sizing: border-box;
  line-height: 1.15;
}
.toast[hidden] { display: none !important; }
.toast.fever-toast {
  font-size: clamp(1.1rem, 5vw, 1.7rem);
  padding: 5px 20px 6px;
  color: #6b3d0c;
  background: rgba(255, 246, 214, 0.96);
  box-shadow: 0 8px 28px rgba(201, 154, 58, 0.38), 0 0 0 3px rgba(232, 184, 74, 0.45);
  animation: toastPop 0.42s cubic-bezier(0.2, 1.35, 0.3, 1);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
@keyframes toastPop {
  0% { transform: scale(0.62); }
  58% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.controls { text-align: center; margin-top: 14px; }
.clap-btn {
  appearance: none;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #faf4ee;
  background: linear-gradient(180deg, #b58379 0%, var(--blush-deep) 100%);
  border: 0;
  border-radius: 999px;
  min-width: min(100%, 280px);
  height: 58px;
  padding: 0 36px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 8px 0 #6f4a44, 0 12px 20px rgba(60, 40, 32, 0.2);
  transform: translateY(0);
  touch-action: manipulation;
}
.clap-btn:hover { filter: brightness(1.05); }
.clap-btn:active, .clap-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 4px 0 #6f4a44, 0 6px 12px rgba(60, 40, 32, 0.18);
}
.clap-btn:focus-visible, .primary:focus-visible, .ghost:focus-visible, .mute:focus-visible {
  outline: 3px solid var(--amber-bright);
  outline-offset: 3px;
}
.hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.hint[hidden] { display: none !important; }

footer .build {
  display: inline-block;
  margin-left: 0.55em;
  font-size: 0.72em;
  letter-spacing: 0.08em;
  color: #b5a396;
  vertical-align: middle;
}
footer {
  margin-top: 22px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.mute {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 246, 0.9);
  color: var(--ink-soft);
  box-shadow: 0 4px 14px rgba(60, 40, 32, 0.12);
  cursor: pointer;
  z-index: 20;
  display: grid;
  place-items: center;
}
.mute[aria-pressed="true"] { color: var(--blush-deep); }

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.hud, .controls {
  width: min(100%, 440px);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 52, 42, 0.34);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}
.overlay[hidden] { display: none; }
.panel {
  width: min(420px, 100%);
  background: #fbf7f3;
  border-radius: 24px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.panel-face {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  box-shadow: 0 8px 18px rgba(60, 40, 32, 0.16);
}
.panel h2 {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.9rem;
  margin: 0 0 10px;
  letter-spacing: -0.03em;
  font-weight: 600;
}
.panel p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.panel-note { font-size: 0.92rem; }
.panel-tagline {
  margin: 16px 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6b3d0c;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
#endPanel .panel-tagline { margin: 4px 0 12px; }
.primary, .ghost {
  appearance: none;
  font-family: Figtree, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  border: 0;
}
.primary {
  color: #faf4ee;
  background: var(--blush-deep);
  min-width: 160px;
}
.primary:hover { filter: brightness(1.06); }
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(120, 92, 78, 0.28);
}
.end-score {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
  color: var(--ink) !important;
  line-height: 1.35;
}
.end-score span {
  font-size: 1.7rem;
  font-weight: 600;
  display: inline-block;
  padding: 0 4px;
}
.end-sub { font-size: 0.92rem; }
.share-preview {
  width: min(200px, 70%);
  border-radius: 12px;
  margin: 6px auto 10px;
  display: block;
  box-shadow: 0 8px 20px rgba(60, 40, 32, 0.16);
  background: var(--cream-deep);
}
.end-board {
  max-height: 28vh;
  overflow: auto;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  text-align: left;
  font-size: 0.9rem;
}
#endPanel {
  max-height: min(92dvh, 900px);
  overflow-y: auto;
}
.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  position: sticky;
  bottom: 0;
  background: #fbf7f3;
  padding: 10px 0 0;
  z-index: 2;
}
#endPanel.is-arming .end-actions { pointer-events: none; }

@media (min-width: 880px) {
  .page { padding-top: 6px; padding-bottom: 2px; }
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px;
  }
  .board-card { display: block; position: sticky; top: 12px; padding: 14px 16px 12px; font-size: 0.92rem; }
  .stage-wrap { height: min(72dvh, calc(100dvh - 200px)); width: min(100%, calc(min(72dvh, calc(100dvh - 200px)) * 9 / 16)); aspect-ratio: 9 / 16; min-height: 0; max-height: calc(100dvh - 200px); }
  .top { margin: 0 0 4px; }
  .top h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
  .tag { margin: 0 0 2px; }
  .rule-line { display: none; }
  .controls { margin-top: 6px; }
  .clap-btn { height: 50px; font-size: 1.3rem; }
  .hint { margin-top: 4px; }
  footer { margin-top: 4px; }
}

@media (max-width: 879px) {
  html, body {
    height: var(--app-h);
    max-height: var(--app-h);
    overflow: hidden;
  }
  .page {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--app-h);
    max-height: var(--app-h);
    padding: 4px 10px 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .top { margin: 0 0 2px; flex: 0 0 auto; }
  .top h1 { font-size: 1.45rem; }
  .tag { display: none; }
  .layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .hud {
    width: 100%;
    grid-template-columns: 1.3fr 1fr 1fr auto;
    gap: 2px 8px;
    margin-bottom: 4px;
    align-items: center;
    flex: 0 0 auto;
    padding-right: 48px;
  }
  .stat .label { font-size: 0.58rem; }
  .stat .value, .stat-score .value { font-size: 1.15rem; }
  .rule-line { display: none; }
  .stage-wrap {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    height: var(--stage-h, auto);
    min-height: 0;
    max-height: 100%;
    margin: 0 auto;
    overflow: hidden;
  }
  .overlay {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: var(--app-h);
  }
  .controls {
    width: 100%;
    flex: 0 0 auto;
    margin-top: 8px;
    margin-bottom: 0;
  }
  .clap-btn { height: 50px; font-size: 1.25rem; min-width: min(100%, 240px); }
  .hint {
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 0.76rem;
    line-height: 1.35;
    min-height: 1.35em;
    padding: 0 10px;
  }
  footer { flex: 0 0 auto; margin-top: 8px; margin-bottom: 0; font-size: 0.75rem; line-height: 1.4; }
  .stage .callout-strip .title-banner,
.stage .callout-strip .toast,
.stage .callout-strip .cheese-cue {
  width: max-content;
  max-width: min(92%, 100%);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  white-space: nowrap;
}
.stage .track-wrap { top: 6px; height: 52px; }
  .stage .callout-strip { top: 60px; min-height: 0; }
  .stage .count-in { top: 60px; }
  .stage .judge { top: 60px; }
  .judge { font-size: clamp(0.78rem, 3.6vw, 1rem); padding: 2px 10px 3px; }
  .judge.is-subtle { font-size: 0.68rem; padding: 1px 7px 2px; }
  .title-banner { font-size: clamp(1.05rem, 5vw, 1.55rem); padding: 4px 12px 5px; }
}



@media (max-width: 879px) and (max-height: 720px) {
  .overlay { padding: 10px; align-content: center; }
  .panel { padding: 16px 16px 14px; }
  .panel-face { width: 64px; height: 64px; margin-bottom: 6px; }
  .panel h2 { font-size: 1.45rem; margin: 0 0 6px; }
  .panel p { margin: 0 0 8px; }
  .panel-tagline { margin: 10px 0 0; font-size: 0.88rem; }
}

@media (max-width: 879px) and (max-height: 560px) {
  .clap-btn { height: 46px; font-size: 1.15rem; }
  .hint { margin-top: 6px; font-size: 0.72rem; line-height: 1.35; }
  footer { margin-top: 6px; font-size: 0.7rem; }
}
/* Feedback strip and horizontal track sit ABOVE the stage so nothing covers the cat. */
.stage .callout-strip {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 68px;
  z-index: 20;
  min-height: 0;
  margin: 0;
  pointer-events: none;
}
.stage .track-wrap {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  z-index: 15;
  height: 56px;
  margin: 0;
  border-radius: 14px;
  background: rgba(44, 38, 34, 0.38);
  box-shadow: inset 0 0 0 2px rgba(255, 248, 238, 0.2), 0 6px 16px rgba(44, 38, 34, 0.22);
  overflow: hidden;
  pointer-events: none;
}
.callout-strip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 52px;
  margin: 0 0 6px;
  z-index: 8;
}
.track-wrap {
  position: relative;
  width: 100%;
  height: 76px;
  margin: 0 0 10px;
  border-radius: 16px;
  background: rgba(44, 38, 34, 0.08);
  box-shadow: inset 0 0 0 2px rgba(61, 40, 23, 0.12);
  overflow: hidden;
}
.lane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  display: block;
}
.cheese-cue[hidden] { display: none !important; }
.cheese-cue {
  position: static;
  z-index: 6;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.05rem, 4.6vw, 1.55rem);
  color: #7a4e14;
  background: rgba(255, 247, 230, 0.92);
  padding: 6px 18px 7px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(60, 40, 32, 0.16);
  pointer-events: none;
  letter-spacing: -0.02em;
  width: max-content;
  max-width: min(92%, 100%);
  white-space: nowrap;
  box-sizing: border-box;
  line-height: 1.15;
  text-align: center;
}

.pops {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
}
.hit-line { display: none !important; }

.judge[hidden] { display: none !important; }
.judge {
  position: absolute;
  left: 33.33%;
  top: 68px;
  right: auto;
  bottom: auto;
  transform: translateX(-110%);
  z-index: 19;
  width: max-content;
  max-width: none;
  white-space: nowrap;
  box-sizing: border-box;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 6.2vw, 2rem);
  letter-spacing: 0.08em;
  color: #3d2817;
  background: rgba(255, 247, 230, 0.96);
  padding: 4px 16px 6px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(61, 40, 23, 0.18);
  text-shadow: 0 1px 0 #fff8ee;
  pointer-events: none;
  opacity: 1;
  animation: judgePop 0.28s ease-out;
}
.judge.is-perfect { color: #2f6b3a; }
.judge.is-good { color: #3d2817; }
.judge.is-early,
.judge.is-late,
.judge.is-off { color: #8a5a22; }
.judge.is-miss { color: #a33a2a; }
.judge.is-subtle {
  font-family: Figtree, system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 1px 7px 2px;
  background: rgba(255, 247, 230, 0.78);
  box-shadow: 0 1px 4px rgba(61, 40, 23, 0.12);
  text-shadow: none;
  opacity: 0.92;
}
@keyframes judgePop {
  0% { transform: translateX(-110%) scale(1.14); }
  100% { transform: translateX(-110%) scale(1); }
}

.count-in[hidden] { display: none !important; }
.count-in {
  position: absolute;
  left: 0;
  right: 0;
  top: 72px;
  bottom: auto;
  transform: none;
  display: block;
  z-index: 19;
  pointer-events: none;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  letter-spacing: 0.08em;
  color: #6b3d0c;
  text-shadow: 0 1px 0 #fff8ee;
  text-align: center;
}
.count-in span {
  display: inline-block;
  background: #fff7e6;
  padding: 4px 16px 6px;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(61, 40, 23, 0.2), 0 0 0 3px rgba(232, 184, 109, 0.55);
  width: max-content;
  max-width: min(92%, 100%);
  box-sizing: border-box;
  white-space: nowrap;
  line-height: 1.15;
}
.count-in.is-go span {
  background: #fff7e6;
  color: #6b3d0c;
  font-weight: 800;
  padding: 6px 20px 8px;
  box-shadow: 0 8px 20px rgba(61, 40, 23, 0.28), 0 0 0 3px #e8b86d;
}
.count-in.is-ready,
.count-in.is-set { font-size: clamp(1.5rem, 7vw, 2.2rem); letter-spacing: 0.12em; }
.count-in.is-go { font-size: clamp(1.9rem, 8.5vw, 2.8rem); letter-spacing: 0.08em; }
.count-in span { animation: countPop 0.28s ease; }
@keyframes countPop {
  /* Start solid so GO! is never a transparent flash over a note. */
  0% { transform: scale(0.82); opacity: 1; }
  40% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.round-card[hidden] { display: none !important; }
.round-card {
  position: static;
  inset: auto;
  display: grid;
  place-content: center;
  place-items: center;
  gap: 2px;
  z-index: 9;
  pointer-events: none;
  background: transparent;
  color: #6b3d0c;
  text-align: center;
  text-shadow: none;
}
.round-card.is-small {
  background: transparent;
  place-content: center;
  padding-top: 0;
}
.round-card.is-small .round-num {
  font-size: clamp(1.15rem, 5.2vw, 1.85rem);
  letter-spacing: 0.12em;
  background: rgba(255, 247, 230, 0.95);
  color: #6b3d0c;
  text-shadow: 0 1px 0 #fff8ee;
  padding: 7px 18px 8px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(61, 40, 23, 0.2), 0 0 0 3px rgba(232, 184, 109, 0.45);
}
.round-kicker {
  font-family: Figtree, sans-serif;
  font-size: clamp(0.85rem, 3.2vw, 1.1rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.9;
}
.round-num {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(4.2rem, 22vw, 6.4rem);
  letter-spacing: 0.02em;
  line-height: 0.95;
}
.round-tip {
  margin-top: 8px;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.15rem, 5vw, 1.7rem);
  letter-spacing: 0.04em;
  background: rgba(255, 247, 230, 0.94);
  color: #3d2817;
  text-shadow: none;
  padding: 6px 16px 8px;
  border-radius: 999px;
}
.round-tip:empty { display: none; }

.cat-motion.clap-pop { animation: none; transform: none; }
@keyframes clapPop {
  0%, 100% { transform: none; }
}
.clap-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: rgba(255, 248, 238, 0.28);
  opacity: 0;
}
.clap-flash.on { animation: clapFlash 0.16s ease-out; }
@keyframes clapFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
#board li .who,
.end-board li .who {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
#board li .score,
.end-board li .score {
  grid-column: 3;
  grid-row: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#board li .me,
.end-board li .me { color: #8a5a22; }
#board li .meta,
.end-board li .meta {
  grid-column: 2 / -1;
  grid-row: 2;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
}

/* v4: scoring pops, cheese drop, celebrations, share */
.hud-flags {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
  margin-bottom: 0;
  align-self: center;
}
.saver-mark {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #8a5a12;
  background: rgba(255, 247, 230, 0.94);
  border: 1px solid rgba(201, 154, 58, 0.75);
  box-shadow: 0 2px 8px rgba(201, 154, 58, 0.18);
}
.saver-mark[hidden] { display: none !important; }
.mult-badge {
  align-self: center;
  font-family: Figtree, system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.68rem;
  color: #6b3d0c;
  background: rgba(255, 247, 230, 0.94);
  border: 1px solid rgba(201, 154, 58, 0.7);
  border-radius: 999px;
  padding: 3px 8px 4px;
  margin-bottom: 0;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  box-shadow: 0 2px 8px rgba(201, 154, 58, 0.18);
  white-space: nowrap;
}
.mult-badge[hidden] { display: none !important; }
.mult-badge.is-pop { animation: multPop 0.38s cubic-bezier(0.2, 1.4, 0.3, 1); }
@keyframes multPop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.hand-spark,
.hand-spark.on,
.hand-spark[hidden] { display: none !important; }
.beat-ring[hidden] { display: none !important; }
@keyframes handSpark {
  0% { opacity: 1; transform: scale(0.45); }
  55% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.25); }
}

.cheese-drop {
  position: absolute;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(60, 40, 32, 0.35));
  transform: rotate(-8deg);
}
.cheese-drop[hidden] { display: none !important; }

.pops {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  overflow: hidden;
}
.score-pop {
  position: absolute;
  left: 38%;
  right: auto;
  top: 20%;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffd978;
  -webkit-text-stroke: 1.2px #5a2e08;
  paint-order: stroke fill;
  text-shadow:
    0 1px 0 #3d2817,
    0 2px 6px rgba(61, 40, 23, 0.4);
  animation: scorePopHit 0.72s ease-out forwards;
  animation-delay: var(--pop-delay, 0ms);
  white-space: nowrap;
  letter-spacing: 0.02em;
  transform: none;
  pointer-events: none;
  text-align: left;
  width: max-content;
  max-width: 52%;
  box-sizing: border-box;
}
.score-pop.is-hit { font-size: 1.05rem; }
.score-pop.is-big { font-size: 2.35rem; color: #ffe9a0; }
.score-pop.is-milestone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: clamp(1.05rem, 4.4vw, 1.35rem);
  font-weight: 800;
  color: #ffe9a0;
  -webkit-text-stroke: 1.1px #5a2e08;
  text-shadow:
    0 1px 0 #3d2817,
    0 2px 6px rgba(61, 40, 23, 0.45);
  animation: scorePopHit 0.8s ease-out forwards;
  white-space: nowrap;
  width: max-content;
  max-width: 56%;
  box-sizing: border-box;
  text-align: left;
}
.score-pop.is-milestone .pop-label {
  white-space: nowrap;
  width: max-content;
  max-width: 100%;
  font-size: clamp(0.62rem, 2.8vw, 0.82rem);
  letter-spacing: 0.04em;
  line-height: 1.15;
  -webkit-text-stroke: 0.6px #5a2e08;
}
.score-pop.is-streak-5 { font-size: clamp(1.05rem, 4.4vw, 1.35rem); color: #ffe9a0; }
.score-pop.is-streak-10 {
  font-size: clamp(1.1rem, 4.8vw, 1.45rem);
  color: #fff1c2;
  text-shadow:
    0 0 0 3px #5a2e08,
    0 2px 0 #3d2817,
    0 0 12px rgba(232, 184, 74, 0.55),
    0 3px 10px rgba(61, 40, 23, 0.5);
  animation: scorePop 0.8s ease-out forwards;
}
.score-pop.is-streak-15 {
  font-size: clamp(1.15rem, 5vw, 1.5rem);
  color: #fff6d8;
  text-shadow:
    0 0 0 3px #5a2e08,
    0 2px 0 #3d2817,
    0 0 16px rgba(243, 210, 122, 0.7),
    0 0 4px rgba(232, 184, 109, 0.9),
    0 3px 12px rgba(61, 40, 23, 0.5);
  animation: scorePopBurst 0.88s ease-out forwards;
}
.score-pop .pop-label {
  font-family: Figtree, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff6d8;
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 0 #3d2817, 0 2px 6px rgba(61, 40, 23, 0.55);
  line-height: 1.15;
  white-space: normal;
  max-width: 100%;
}
.score-pop.is-streak-10 .pop-label { font-size: 0.78rem; color: #fff8e4; }
.score-pop.is-saved { font-size: 1.15rem; }
.score-pop.is-saved .pop-label {
  font-size: 1.15rem;
  color: #fff8e4;
  font-weight: 800;
  letter-spacing: 0.06em;
  -webkit-text-stroke: 1.4px #5a2e08;
}
.score-pop.is-streak-15 .pop-label { font-size: 0.82rem; color: #fff8e4; }
.score-pop.is-cheese {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  font-size: 1.7rem;
  color: #ffe7a3;
  -webkit-text-stroke: 1.6px #5a2e08;
  animation: scorePop 0.7s ease-out forwards;
  text-align: left;
}
.score-pop.is-cheese .pop-label {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: #fff3c4;
}
.score-pop .pop-burst {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.score-pop .pop-spark {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: #f3d27a;
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(243, 210, 122, 0.85), 0 0 0 1px rgba(90, 46, 8, 0.25);
  transform: rotate(var(--a, 0deg)) translateY(-6px);
  animation: popSpark 0.62s ease-out forwards;
}
.score-pop .pop-spark:nth-child(2n) { background: #fff1c4; width: 5px; height: 5px; }
.score-pop .pop-spark:nth-child(3n) { background: #e8b84a; border-radius: 50%; }
@keyframes scorePopHit {
  0% { opacity: 1; transform: translate(0, 0) scale(1.06); }
  18% { opacity: 1; transform: translate(0, -6px) scale(1); }
  100% { opacity: 0; transform: translate(0, -22px) scale(1); }
}
@keyframes scorePop {
  0% { opacity: 1; transform: translate(0, 0) scale(0.86); }
  35% { opacity: 1; transform: translate(0, -12px) scale(1.06); }
  100% { opacity: 0; transform: translate(0, -22px) scale(1); }
}
@keyframes scorePopBurst {
  0% { opacity: 1; transform: translate(0, 0) scale(0.8); }
  28% { opacity: 1; transform: translate(0, -10px) scale(1.08); }
  100% { opacity: 0; transform: translate(0, -20px) scale(1); }
}
@keyframes popSpark {
  0% { opacity: 1; transform: rotate(var(--a, 0deg)) translateY(-4px) scale(0.6); }
  50% { opacity: 1; transform: rotate(var(--a, 0deg)) translateY(-16px) scale(1); }
  100% { opacity: 0; transform: rotate(var(--a, 0deg)) translateY(-24px) scale(0.7); }
}

.title-banner {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  z-index: 13;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.05rem, 4.8vw, 1.7rem);
  letter-spacing: 0.04em;
  color: #3d2817;
  background: rgba(255, 247, 230, 0.96);
  padding: 6px 18px 7px;
  border-radius: 16px;
  width: max-content;
  max-width: min(92%, 100%);
  box-sizing: border-box;
  line-height: 1.15;
  box-shadow: 0 6px 18px rgba(61, 40, 23, 0.18), 0 0 0 3px rgba(232, 184, 109, 0.45);
  text-shadow: 0 1px 0 #fff8ee;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}
.title-banner[hidden] { display: none !important; }
.title-banner.is-perfect { color: #2f6b3a; animation: titlePulse 0.55s ease-out; }
.title-banner.is-great { color: #6b3d0c; animation: titlePop 0.4s cubic-bezier(0.2, 1.3, 0.3, 1); }
.title-banner.is-clear { color: #3d2817; }
.title-banner.is-amazing { color: #6b3d0c; font-size: clamp(1.45rem, 6vw, 2.3rem); }
@keyframes titlePop {
  0% { transform: scale(0.72); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes titlePulse {
  0% { transform: scale(0.7); }
  40% { transform: scale(1.14); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.stage-wrap.punch-in {
  transform: none;
  transition: none;
}
.cat-motion.clap-bounce { animation: none; transform: none; }
@keyframes clapBounce {
  0%, 100% { transform: none; }
}

.end-score {
  font-size: 1.2rem !important;
}
.end-actions {
  margin: 8px 0 12px;
}


/* v4.1: merlin arc, wizard hat, perfect-game banner */
.merlin-arc {
  position: absolute;
  left: 0;
  top: 18%;
  width: 100%;
  height: 22%;
  z-index: 14;
  pointer-events: none;
  overflow: visible;
  display: none;
}
.merlin-arc.is-on { display: block; }
.merlin-text {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  filter: drop-shadow(0 3px 0 #fff8ee);
}
.title-banner.is-perfect-game {
  color: #6b3d0c;
  font-size: clamp(1.05rem, 5vw, 1.8rem);
  animation: titlePulse 0.55s ease-out;
}
.title-banner.is-merlin {
  color: #6b3d0c;
  font-size: clamp(0.82rem, 3.7vw, 1.25rem);
  letter-spacing: 0.03em;
  padding: 6px 16px 7px;
  animation: titlePulse 0.55s ease-out;
}

.wizard-hat {
  position: absolute;
  width: 44%;
  height: auto;
  left: 73.2%;
  top: 36%;
  transform: translate(-50%, -70%);
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(20, 12, 40, 0.45));
}
.wizard-hat[hidden] { display: none !important; }

.debug-hud[hidden] { display: none !important; }
.debug-hud {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 20;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.35;
  color: #fff8ee;
  background: rgba(44, 38, 34, 0.72);
  border-radius: 8px;
  padding: 6px 8px;
  text-shadow: 0 1px 0 #3d2817;
  white-space: nowrap;
  overflow: hidden;
}

.stage.is-celebrate .track-wrap { opacity: 0; }
.stage.is-celebrate .callout-strip .toast,
.stage.is-celebrate .judge,
.stage.is-celebrate .count-in { display: none !important; }

.end-ack[hidden] { display: none !important; }
.end-ack {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 14%;
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  pointer-events: none;
  text-align: center;
}
.end-ack-acc {
  font-family: Figtree, system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #6b3d0c;
  background: #fff7e6;
  padding: 2px 10px 3px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(61, 40, 23, 0.14);
  line-height: 1.2;
}
.end-ack-acc:empty { display: none; }
.end-accuracy {
  margin: -4px 0 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b3d0c;
  letter-spacing: 0.01em;
}
.end-accuracy[hidden] { display: none !important; }
.end-ack-label {
  display: inline-block;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #3d2817;
  background: #fff7e6;
  padding: 8px 18px 10px;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(61, 40, 23, 0.22), 0 0 0 3px #e8b86d;
  text-shadow: 0 1px 0 #fff8ee;
  animation: endAckIn 0.35s cubic-bezier(0.2, 1.3, 0.3, 1);
  max-width: 100%;
}
.end-ack-label {
  white-space: nowrap;
  width: max-content;
  max-width: min(92vw, 100%);
  box-sizing: border-box;
  line-height: 1.15;
}
.end-ack.is-clear .end-ack-label {
  font-size: clamp(1.05rem, 5.4vw, 1.7rem);
}
.end-ack.is-great .end-ack-label {
  font-size: clamp(1.1rem, 5.8vw, 1.85rem);
  color: #6b3d0c;
}
.end-ack.is-perfect .end-ack-label,
.end-ack.is-amazing .end-ack-label {
  font-size: clamp(1.1rem, 5.8vw, 1.85rem);
  color: #5a2e08;
  padding: 8px 18px 10px;
  box-shadow: 0 10px 28px rgba(61, 40, 23, 0.26), 0 0 0 3px #e8b86d, 0 0 18px rgba(232, 184, 74, 0.45);
}
@keyframes endAckIn {
  0% { transform: scale(0.78); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.gold-burst[hidden] { display: none !important; }
.gold-burst {
  position: absolute;
  left: 64%;
  top: 52%;
  width: 0;
  height: 0;
  z-index: 17;
  pointer-events: none;
}
.gold-burst .shard {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: #f3d27a;
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(243, 210, 122, 0.85), 0 0 0 1px rgba(90, 46, 8, 0.25);
  transform: rotate(var(--a, 0deg)) translateY(-6px);
  animation: goldBurst 0.7s ease-out forwards;
}
.gold-burst .shard:nth-child(2n) { background: #fff1c4; width: 7px; height: 7px; border-radius: 50%; }
.gold-burst .shard:nth-child(3n) { background: #e8b84a; width: 12px; height: 5px; }
@keyframes goldBurst {
  0% { opacity: 1; transform: rotate(var(--a, 0deg)) translateY(-4px) scale(0.5); }
  45% { opacity: 1; transform: rotate(var(--a, 0deg)) translateY(-36px) scale(1.1); }
  100% { opacity: 0; transform: rotate(var(--a, 0deg)) translateY(-58px) scale(0.7); }
}
