:root {
  color-scheme: light;
  --ink: #142017;
  --muted: #52665a;
  --line: rgba(20, 32, 23, 0.14);
  --panel: rgba(255, 255, 255, 0.92);
  --shadow: 0 20px 54px rgba(20, 32, 30, 0.22);
  --success: #12a856;
  --danger: #f04f5f;
  --warning: #ffcf33;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top, #fff7b8, transparent 35%),
    radial-gradient(circle at 12% 88%, rgba(255, 255, 255, 0.72), transparent 25%),
    linear-gradient(135deg, #89f7fe 0%, #66a6ff 45%, #fbc2eb 100%);
  color: var(--ink);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

.game-viewport {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: linear-gradient(135deg, #bff3ff, #fff6c7, #d8d1ff);
}

.game-root {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  border-radius: 0;
  transform: none;
  transform-origin: center center;

  --safe-pad: clamp(8px, 1.4vmin, 24px);
  --gap: clamp(8px, 1.3vmin, 20px);
  --side-col: clamp(210px, 19vw, 330px);
  --top-row: clamp(44px, 7vh, 76px);
  --callout-h: clamp(74px, 12vh, 118px);
  --title-font: clamp(28px, 4.2vmin, 58px);
  --big-font: clamp(30px, 4.8vmin, 66px);
  --mid-font: clamp(20px, 2.8vmin, 38px);
  --small-font: clamp(14px, 1.8vmin, 24px);

  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 210, 0.95), transparent 33%),
    linear-gradient(135deg, #c7f5ff 0%, #fff8c9 48%, #d9d0ff 100%);
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 2px solid rgba(20, 32, 23, 0.14);
  border-radius: 12px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(28, 139, 255, 0.26);
  outline-offset: 3px;
}

button.primary {
  border-color: #106e43;
  background: #13804d;
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  transition: gap 240ms ease;
}

.game-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(470px, 1.25fr);
  gap: 14px;
  border: 4px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 14px 152px 12px 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 30px rgba(20, 32, 30, 0.14);
  backdrop-filter: blur(12px);
  transition: transform 440ms cubic-bezier(.2, 1, .2, 1), opacity 240ms ease, max-height 420ms ease, padding 420ms ease, margin 420ms ease;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 12px;
  background: #ffcf33;
  color: #432900;
  font-size: 15px;
  font-weight: 1000;
}

.brand-block h1 {
  margin: 5px 0 0;
  font-size: clamp(32px, 3.4vw, 54px);
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.72);
}

.brand-block p {
  margin: 8px 0 0;
  color: #234333;
  font-size: 19px;
  font-weight: 1000;
}

.round-board {
  display: grid;
  grid-template-columns: 0.7fr 0.8fr 1.6fr;
  gap: 10px;
  align-items: stretch;
}

.round-board > div {
  min-height: 78px;
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
}

.round-board span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 1000;
}

.round-board strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.earth-panel {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 6px 10px;
}

.earth-panel img {
  grid-row: 1 / 3;
  width: 58px;
  height: 58px;
}

.earth-panel .earth-bar {
  grid-column: 2 / -1;
}

.earth-panel.sparkle {
  animation: earthSparkle 520ms ease;
}

.earth-panel.shake {
  animation: earthShake 520ms ease;
}

.earth-bar {
  height: 16px;
  overflow: hidden;
  border: 3px solid rgba(15, 98, 68, 0.22);
  border-radius: 999px;
  background: #dce8df;
}

.earth-bar div {
  width: 70%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #29c76f, #18a4a8, #64c955);
  transition: width 180ms ease;
}

.score-ribbon {
  grid-column: 1 / -1;
  border-radius: 999px;
  padding: 8px 14px;
  background: #172018;
  color: #fff;
  font-size: 18px;
  font-weight: 1000;
  text-align: center;
  transition: transform 360ms ease, opacity 220ms ease;
}

.admin-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 116px;
  min-height: 46px;
  border: 3px solid rgba(20, 32, 23, 0.16);
  border-radius: 18px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(20, 32, 26, 0.18);
  color: #172018;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  transition: opacity 180ms ease, transform 180ms ease;
}

body.playing .admin-toggle,
body.state-playing .admin-toggle {
  opacity: 0.42;
  transform: scale(0.92);
}

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 6px solid rgba(255, 255, 255, 0.76);
  border-radius: 34px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.62)),
    url("./assets/svg/stage-bg.svg") center / cover no-repeat;
  box-shadow: var(--shadow);
  transition: min-height 420ms cubic-bezier(.2, 1, .2, 1), transform 420ms cubic-bezier(.2, 1.2, .3, 1), border-radius 420ms ease;
}

.stage-lights {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 16%, rgba(255, 245, 128, 0.62), transparent 18%),
    radial-gradient(circle at 76% 17%, rgba(255, 111, 175, 0.35), transparent 20%),
    repeating-linear-gradient(90deg, transparent 0 56px, rgba(255, 255, 255, 0.11) 56px 60px);
  pointer-events: none;
  mix-blend-mode: screen;
}

.stage-title {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 7;
  display: grid;
  justify-items: center;
  transform: translateX(-50%);
  color: #173326;
  text-shadow: 0 3px 0 #fff;
  font-weight: 1000;
  transition: transform 320ms ease, opacity 220ms ease;
}

.stage-title span {
  font-size: clamp(30px, 4vw, 62px);
  line-height: 1;
}

.stage-title strong {
  margin-top: 6px;
  border: 4px solid #172018;
  border-radius: 999px;
  padding: 6px 18px;
  background: #ffcf33;
  color: #312300;
  font-size: clamp(16px, 1.6vw, 22px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
}

.round-dots {
  position: absolute;
  top: 22px;
  left: 24px;
  z-index: 8;
  display: flex;
  gap: 8px;
  border: 3px solid #172018;
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
}

.round-dots span {
  color: #a8b4ad;
  font-size: 24px;
  line-height: 1;
}

.round-dots span.done,
.round-dots span.current {
  color: #ffcf33;
  text-shadow: 0 2px 0 #172018;
}

.round-dots span.current {
  animation: dotPulse 500ms ease-in-out infinite alternate;
}

.stage-earth-gauge {
  position: absolute;
  top: 20px;
  right: 154px;
  z-index: 8;
  display: grid;
  grid-template-columns: 54px minmax(126px, 180px);
  align-items: center;
  gap: 8px;
  border: 3px solid #172018;
  border-radius: 22px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
}

.stage-earth-gauge img {
  width: 54px;
  height: 54px;
}

.stage-earth-gauge span,
.stage-earth-gauge strong {
  font-size: 20px;
  font-weight: 1000;
}

.earth-bar.mini {
  height: 12px;
  margin-top: 4px;
}

.player-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
}

body.state-title .game-stage,
body.state-ready .game-stage {
  display: grid;
  grid-template-rows: 176px 210px minmax(0, 1fr);
  align-content: start;
  height: 100%;
  min-height: 0;
  padding: 84px 28px 18px;
}

body.state-title .player-grid,
body.state-ready .player-grid {
  grid-row: 2;
  position: relative;
  inset: auto;
  z-index: 7;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
  justify-items: stretch;
  width: 94%;
  margin: 18px auto 0;
}

body.state-title .player-station,
body.state-ready .player-station {
  position: relative;
  inset: auto;
  width: auto;
  height: 210px;
  min-height: 0;
  padding: 10px;
  transform: none;
}

body.state-title .station-foot,
body.state-ready .station-foot {
  display: none;
}

body.state-title .station-head h2,
body.state-ready .station-head h2 {
  font-size: clamp(24px, 2.2vw, 34px);
}

body.state-title .runner-chip,
body.state-ready .runner-chip {
  margin: 6px 0;
  font-size: clamp(18px, 1.8vw, 24px);
}

body.state-title .character-wrap,
body.state-ready .character-wrap {
  grid-template-columns: 82px 1fr;
}

body.state-title .character,
body.state-ready .character {
  width: 82px;
  height: 82px;
}

body.state-title .character img,
body.state-ready .character img {
  width: 76px;
  height: 76px;
}

body.state-title .held-item span,
body.state-ready .held-item span {
  font-size: clamp(48px, 4vw, 64px);
}

body.state-title .held-item b,
body.state-ready .held-item b {
  font-size: clamp(17px, 1.4vw, 22px);
}

body.state-title .rhythm-arena,
body.state-ready .rhythm-arena {
  grid-row: 1;
  position: relative;
  top: auto;
  left: auto;
  z-index: 5;
  width: min(82%, 980px);
  height: 176px;
  margin: 10px auto 0;
  transform: none;
}

body.state-title .beat-ring,
body.state-ready .beat-ring {
  top: 0;
  width: 106px;
  height: 106px;
  border-width: 7px;
}

body.state-title .beat-ring span,
body.state-ready .beat-ring span {
  font-size: 22px;
}

body.state-title .music-notes,
body.state-ready .music-notes {
  top: -8px;
  font-size: 24px;
}

body.state-title .flying-trash,
body.state-ready .flying-trash {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  font-size: 42px;
}

body.state-title .rhythm-line,
body.state-ready .rhythm-line {
  bottom: 0;
  height: 92px;
  border-width: 4px;
}

body.state-title .stage-bin,
body.state-ready .stage-bin {
  width: 96px;
  height: 68px;
  border-width: 4px;
  border-radius: 18px;
}

body.state-title .stage-bin img,
body.state-ready .stage-bin img {
  width: 46px;
  height: 46px;
}

body.state-title .drop-marker span,
body.state-ready .drop-marker span {
  font-size: 30px;
}

body.state-title .stage-callout,
body.state-ready .stage-callout {
  grid-row: 3;
  position: relative;
  right: auto;
  bottom: auto;
  left: auto;
  width: min(980px, 86%);
  margin: 10px auto 0;
  padding: 8px 14px;
}

body.state-title .callout-main,
body.state-ready .callout-main {
  font-size: clamp(24px, 3vw, 44px);
}

.player-station {
  position: absolute;
  width: clamp(245px, 21vw, 330px);
  min-height: 228px;
  border: 6px solid var(--team-color);
  border-radius: 32px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.2), inset 0 -8px 0 rgba(0, 0, 0, 0.05);
  transform-origin: center;
  transition: transform 170ms ease, box-shadow 170ms ease, filter 170ms ease, opacity 170ms ease;
  animation: idleBob 1.5s ease-in-out infinite alternate;
}

body.state-playing .player-grid {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

body.state-playing .player-station {
  position: absolute;
  width: 250px;
  height: 250px;
  min-height: 0;
  pointer-events: auto;
}

body.state-playing .player-station[data-team="A"] {
  top: 120px !important;
  left: 28px !important;
  right: auto !important;
  bottom: auto !important;
}

body.state-playing .player-station[data-team="B"] {
  top: 120px !important;
  right: 28px !important;
  bottom: auto !important;
  left: auto !important;
}

body.state-playing .player-station[data-team="C"] {
  bottom: 28px !important;
  left: 28px !important;
  top: auto !important;
  right: auto !important;
}

body.state-playing .player-station[data-team="D"] {
  right: 28px !important;
  bottom: 28px !important;
  top: auto !important;
  left: auto !important;
}

.player-station.top-left {
  top: 92px;
  left: 28px;
}

.player-station.top-right {
  top: 92px;
  right: 28px;
}

.player-station.bottom-left {
  bottom: 26px;
  left: 28px;
}

.player-station.bottom-right {
  right: 28px;
  bottom: 26px;
}

body.state-title .player-station.top-left,
body.state-title .player-station.top-right,
body.state-title .player-station.bottom-left,
body.state-title .player-station.bottom-right,
body.state-ready .player-station.top-left,
body.state-ready .player-station.top-right,
body.state-ready .player-station.bottom-left,
body.state-ready .player-station.bottom-right {
  inset: auto;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
}

.player-station.ready {
  box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.74), 0 0 28px var(--team-color), 0 14px 28px rgba(0, 0, 0, 0.18);
  animation: readyBounce 560ms ease-in-out infinite alternate;
}

.player-station.active {
  z-index: 9;
  transform: none;
  box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.86), 0 0 44px var(--team-color), 0 22px 46px rgba(0, 0, 0, 0.28);
  animation: activePulse 0.48s infinite alternate;
}

.player-station.success,
.player-station.effect-success,
.player-station.effect-perfect {
  animation: stationJump 620ms cubic-bezier(.2, 1.4, .3, 1);
}

.player-station.miss {
  animation: stationOops 520ms ease;
}

.player-station.penalty,
.player-station.effect-penalty {
  animation: stationPenalty 650ms ease;
}

.station-head,
.station-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.station-head h2 {
  margin: 0;
  color: #18251d;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1;
  text-shadow: 0 3px 0 #fff;
}

.mini-score,
.runner-chip,
.combo-chip,
.station-status {
  border-radius: 999px;
  padding: 6px 11px;
  background: #172018;
  color: #fff;
  font-size: 14px;
  font-weight: 1000;
}

.runner-chip {
  display: inline-block;
  margin: 8px 0;
  background: var(--team-color);
  color: #102018;
  font-size: clamp(22px, 2.4vw, 34px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
}

.student-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35em 0.75em;
  font-weight: 1000;
  overflow: visible;
  isolation: isolate;
}

.student-focus-ring {
  position: absolute;
  inset: -18px;
  z-index: -1;
  border: 5px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow:
    0 0 16px rgba(255, 255, 160, 0.95),
    0 0 32px var(--team-color, rgba(255, 220, 80, 0.9));
  opacity: 0;
  transform: scale(1.65);
  pointer-events: none;
}

.student-badge.runner-changed {
  animation: studentBadgePop 850ms cubic-bezier(.2, 1.3, .3, 1) both;
}

.student-badge.runner-changed .student-focus-ring {
  animation: studentRingFocus 850ms cubic-bezier(.2, 1.3, .3, 1) both;
}

.character-wrap {
  display: grid;
  grid-template-columns: 122px 1fr;
  align-items: center;
  gap: 12px;
}

.character {
  display: grid;
  place-items: center;
  width: 122px;
  height: 122px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--team-color);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.2);
}

.character img {
  width: 112px;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.11));
}

.player-station.active .character {
  animation: characterPop 0.36s infinite alternate;
}

.held-item {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.held-item span {
  font-size: clamp(70px, 7vw, 104px);
  line-height: 0.9;
  filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.13));
}

.held-item b {
  max-width: 100%;
  overflow: hidden;
  color: #172018;
  font-size: clamp(22px, 2vw, 32px);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.held-item em {
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
  font-weight: 1000;
}

.station-foot {
  margin-top: 10px;
}

.combo-chip {
  background: #ffcf33;
  color: #312300;
}

.station-status {
  background: #edf5ef;
  color: #26372e;
  font-size: 16px;
}

.player-station.active .station-status {
  background: #ff3d7f;
  color: #fff;
  animation: nowBadge 360ms ease-in-out infinite alternate;
}

.rhythm-arena {
  position: absolute;
  top: 148px;
  left: 50%;
  z-index: 5;
  width: min(58vw, 820px);
  height: 390px;
  transform: translateX(-50%);
  pointer-events: none;
}

.beat-ticks {
  position: absolute;
  top: 6px;
  left: 50%;
  display: flex;
  gap: 18px;
  transform: translateX(-50%);
}

.beat-ticks span {
  width: 14px;
  height: 32px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  animation: tickPulse 0.5s ease-in-out infinite;
}

.beat-ticks span:nth-child(2n) {
  animation-delay: 0.25s;
  background: #ffcf33;
}

.beat-ring {
  position: absolute;
  top: 36px;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(174px, 16vw, 235px);
  height: clamp(174px, 16vw, 235px);
  border: 12px solid rgba(255, 207, 51, 0.94);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.96), rgba(57, 205, 136, 0.48));
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.5), 0 18px 42px rgba(0, 0, 0, 0.22);
  transform: translateX(-50%);
  animation: beatPulse 0.5s ease-in-out infinite;
  cursor: pointer;
}

.beat-ring.hit-window {
  border-color: rgba(255, 207, 51, 0.94);
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.5), 0 18px 42px rgba(0, 0, 0, 0.22);
}

.beat-ring span {
  color: #173326;
  font-size: clamp(30px, 4vw, 56px);
  font-weight: 1000;
  text-shadow: 0 3px 0 #fff;
}

.music-notes {
  position: absolute;
  top: 0;
  left: 50%;
  min-width: 360px;
  transform: translateX(-50%);
  color: #ff3d7f;
  font-size: clamp(30px, 4vw, 56px);
  font-weight: 1000;
  letter-spacing: 22px;
  text-align: center;
  text-shadow: 0 4px 0 #fff;
  animation: notesDance 0.75s ease-in-out infinite alternate;
}

.flying-trash {
  position: absolute;
  z-index: 8;
  display: grid;
  place-items: center;
  width: clamp(94px, 8vw, 132px);
  height: clamp(94px, 8vw, 132px);
  border: 7px solid #fff;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.24);
  font-size: clamp(62px, 6vw, 96px);
  transition: left 220ms ease, right 220ms ease, top 220ms ease, bottom 220ms ease, transform 220ms ease;
}

.flying-trash.from-A {
  top: 82px;
  left: 42px;
}

.flying-trash.from-B {
  top: 82px;
  right: 42px;
}

.flying-trash.from-C {
  bottom: 86px;
  left: 42px;
}

.flying-trash.from-D {
  right: 42px;
  bottom: 86px;
}

.flying-trash.active {
  top: 118px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%) scale(1.23) rotate(-8deg);
  animation: trashFly 0.38s ease-in-out infinite alternate;
}

.flying-trash.success,
.flying-trash.manual {
  animation: trashScore 0.52s ease;
}

.flying-trash.miss {
  animation: trashDrop 0.56s ease;
}

.flying-trash.penalty {
  animation: trashPenalty 0.6s ease;
}

.rhythm-line {
  position: absolute;
  right: 0;
  bottom: 34px;
  left: 0;
  height: 134px;
  overflow: hidden;
  border: 7px solid rgba(23, 32, 24, 0.18);
  border-radius: 34px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.34) 0 28px, rgba(255, 255, 255, 0.1) 28px 56px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(132, 245, 202, 0.64));
  box-shadow: inset 0 -12px 0 rgba(0, 0, 0, 0.06), 0 18px 36px rgba(0, 0, 0, 0.17);
}

.stage-bins {
  position: absolute;
  top: 15px;
  left: 0;
  display: flex;
  gap: 14px;
  will-change: transform;
}

.stage-bin {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  width: 124px;
  height: 98px;
  border: 5px solid #173326;
  border-radius: 24px;
  background: #fff;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.06), 0 8px 0 rgba(0, 0, 0, 0.13);
  font-weight: 1000;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.stage-bin img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.stage-bin b {
  color: #172018;
  font-size: 15px;
}

.stage-bin.at-drop-zone {
  transform: translateY(-4px);
}

body.state-hint-mode .stage-bin.hint-mode-bin {
  border-color: #ff3d7f;
  background: #fff7bd;
  box-shadow: 0 0 0 7px rgba(255, 61, 127, 0.18), 0 8px 0 rgba(0, 0, 0, 0.13);
  transform: translateY(-9px) scale(1.04);
}

.drop-marker {
  position: absolute;
  left: 50%;
  bottom: -1px;
  display: grid;
  justify-items: center;
  transform: translateX(-50%);
  color: #ff3d7f;
  font-weight: 1000;
  text-shadow: 0 3px 0 #fff;
}

.drop-marker span {
  font-size: 44px;
  line-height: 0.8;
  animation: dropZonePulse 0.35s ease-in-out infinite alternate;
}

.drop-marker b {
  font-size: 17px;
}

.stage-callout {
  position: absolute;
  right: 19%;
  bottom: 26px;
  left: 19%;
  z-index: 12;
  display: grid;
  gap: 5px;
  justify-items: center;
  border: 6px solid #172018;
  border-radius: 34px;
  padding: 14px 18px;
  background: #fff;
  box-shadow: 0 14px 0 rgba(0, 0, 0, 0.13);
}

.callout-main {
  font-size: clamp(34px, 4.4vw, 72px);
  font-weight: 1000;
  line-height: 1.04;
  text-align: center;
}

.callout-sub {
  color: #465a50;
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 1000;
  text-align: center;
}

.learning-bubble {
  position: absolute;
  left: 50%;
  bottom: 142px;
  z-index: 18;
  max-width: min(880px, 78vw);
  border: 5px solid #173326;
  border-radius: 28px;
  padding: 14px 20px;
  background: #fff7bd;
  box-shadow: 0 14px 0 rgba(0, 0, 0, 0.13);
  transform: translateX(-50%);
  color: #24352c;
  font-size: clamp(20px, 2vw, 32px);
  font-weight: 1000;
  text-align: center;
  animation: bubblePop 0.25s ease;
}

.big-judgement {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  color: #fff;
  font-size: clamp(64px, 9vw, 142px);
  font-weight: 1000;
  text-align: center;
  text-shadow: 0 9px 0 rgba(0, 0, 0, 0.2), 0 0 28px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.big-judgement.show {
  display: grid;
  animation: judgementPop 0.82s ease-out forwards;
}

.big-judgement.perfect {
  color: #ffea4d;
}

.big-judgement.good {
  color: #64f29c;
}

.big-judgement.ok {
  color: #7dd7ff;
}

.big-judgement.miss {
  color: #ff5f6f;
}

.big-judgement.penalty {
  color: #b8c2cc;
}

.penalty-dust {
  position: absolute;
  left: 50%;
  top: 98px;
  z-index: 25;
  width: min(310px, 28vw);
  transform: translateX(-50%);
  animation: dustPop 900ms ease forwards;
}

.penalty-dust img {
  width: 100%;
}

body.playing .game-shell,
body.state-playing .game-shell {
  grid-template-rows: 0 1fr;
  gap: 0;
}

body.playing .game-header,
body.state-playing .game-header {
  max-height: 0;
  margin: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  transform: translateY(-130%);
  pointer-events: none;
}

body.playing .score-ribbon,
body.state-playing .score-ribbon {
  opacity: 0;
  transform: translateY(-140%);
  pointer-events: none;
}

body.state-playing .mini-score {
  display: none;
}

body.playing .game-stage,
body.state-playing .game-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border-radius: 30px;
  transform: scale(1);
}

body.playing .stage-title,
body.state-playing .stage-title {
  transform: translateX(-50%) translateY(-130%);
  opacity: 0;
  pointer-events: none;
}

body.playing .stage-earth-gauge,
body.state-playing .stage-earth-gauge {
  transform: scale(1.04);
  box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.45), 0 10px 0 rgba(0, 0, 0, 0.1);
}

body.stage-summary .game-stage {
  transform: scale(0.965);
  filter: saturate(0.95);
}

body.state-playing .rhythm-arena {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 720px;
  height: 460px;
  transform: translate(-50%, -50%);
}

body.state-summary .player-grid {
  opacity: 0.25;
  transform: scale(0.9);
}

body.stage-level-3:not(.state-hint-mode) .stage-bin b,
body.stage-level-4:not(.state-hint-mode) .stage-bin b {
  height: 0;
  overflow: hidden;
  opacity: 0;
}

body.stage-level-4 .held-item b {
  max-width: 8ch;
}

.admin-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(13, 20, 16, 0.34);
}

.admin-backdrop.open {
  display: block;
}

.admin-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 3000;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  width: min(540px, 92vw);
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding: 14px;
  background: #f7faf8;
  box-shadow: -18px 0 38px rgba(14, 24, 18, 0.24);
  transform: translateX(100%);
  transition: transform 180ms ease;
  pointer-events: auto;
}

.admin-panel.open {
  transform: translateX(0);
}

.admin-panel-header {
  position: sticky;
  top: -14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -14px -14px 0;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}

.admin-panel-header h2,
.admin-panel-header p,
.admin-section h3 {
  margin: 0;
}

.admin-panel-header h2 {
  font-size: 26px;
}

.admin-panel-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#adminCloseButton {
  min-width: 62px;
}

.admin-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.admin-section + .admin-section {
  margin-top: 10px;
}

.admin-section h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-facts {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.admin-facts div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  padding: 7px 9px;
  background: #f1f6f3;
}

.admin-facts.compact {
  margin-bottom: 0;
}

.admin-facts dt {
  color: var(--muted);
  font-weight: 900;
}

.admin-facts dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

#connectionStatus.connected {
  color: #0e7a40;
}

#connectionStatus.error,
#serialSupportLabel.error {
  color: var(--danger);
}

.last-line,
.admin-note {
  margin-top: 8px;
  border-radius: 10px;
  padding: 8px 9px;
  background: #f1f6f3;
  color: #4e5e55;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.toggle-row,
.range-row,
.number-row {
  display: grid;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 900;
}

.toggle-row {
  grid-template-columns: auto 1fr;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

.range-row {
  grid-template-columns: auto 1fr auto;
}

.range-row input {
  width: 100%;
}

.number-row {
  grid-template-columns: 1fr 110px;
}

.number-row input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 8px;
}

.student-sim {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.student-sim label {
  color: var(--muted);
  font-weight: 900;
}

.student-sim select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 8px;
  background: #fff;
}

.log-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.log-tabs button {
  min-height: 36px;
  padding: 0 6px;
  font-size: 12px;
}

.log-tabs button.active {
  border-color: #172018;
  background: #172018;
  color: #fff;
}

.admin-log {
  display: grid;
  gap: 5px;
  max-height: 230px;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
  color: #4e5d55;
  font-size: 13px;
  font-weight: 800;
}

.csv-preview {
  display: block;
  min-height: 160px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101814;
  color: #d8f3e2;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  white-space: pre;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 29, 22, 0.42);
}

.countdown-card,
.summary-card {
  border: 6px solid #fff;
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.countdown-card {
  min-width: min(480px, 86vw);
  padding: 34px 42px;
  text-align: center;
  animation: stageZoomIn 500ms cubic-bezier(.2, 1.4, .3, 1) both;
}

.countdown-card span {
  display: block;
  color: var(--muted);
  font-size: 34px;
  font-weight: 1000;
}

.countdown-card strong {
  display: block;
  min-width: 160px;
  color: #172018;
  font-size: clamp(110px, 14vw, 190px);
  line-height: 0.95;
}

.summary-card {
  width: min(780px, 90vw);
  padding: 30px;
  animation: resultBoardIn 620ms cubic-bezier(.2, 1.25, .3, 1) both;
}

.summary-card h2 {
  margin: 0 0 16px;
  font-size: clamp(38px, 6vw, 74px);
  text-align: center;
}

.summary-score {
  display: grid;
  gap: 12px;
}

.summary-team {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 4px solid #172018;
  border-radius: 18px;
  padding: 12px 16px;
  background: #fff7bd;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.12);
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 1000;
  opacity: 0;
  transform: translateY(-16px);
  animation: scoreReveal 460ms ease forwards;
  animation-delay: var(--delay);
}

.summary-team strong {
  color: #0f7a45;
}

.winner-line {
  margin-top: 12px;
  border-radius: 999px;
  padding: 12px 16px;
  background: #172018;
  color: #fff;
  font-size: clamp(26px, 3.5vw, 46px);
  font-weight: 1000;
  text-align: center;
}

.esg-summary {
  margin: 18px 0;
  padding: 12px 0;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}

.esg-summary p,
.summary-help {
  margin: 8px 0;
  font-size: 18px;
  font-weight: 900;
}

.summary-help {
  color: var(--muted);
  text-align: center;
}

body.teacher-buddy .game-stage {
  animation: buddyFlash 650ms ease;
}

body.effect-perfect .game-stage::after,
body.effect-success .game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(circle at 35% 36%, rgba(255, 234, 77, 0.5), transparent 10%),
    radial-gradient(circle at 65% 60%, rgba(255, 111, 175, 0.4), transparent 12%);
  pointer-events: none;
  animation: sparkleBurst 700ms ease forwards;
}

body.tv-mode .player-station {
  transform: scale(1.06);
}

body.tv-mode .callout-main {
  font-size: clamp(42px, 5.4vw, 82px);
}

body.tv-mode .character {
  width: 138px;
  height: 138px;
}

body.tv-mode .character img {
  width: 128px;
  height: 128px;
}

@keyframes idleBob {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

@keyframes readyBounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-7px) scale(1.02); }
}

@keyframes activePulse {
  from { filter: saturate(1.12) brightness(1); }
  to { filter: saturate(1.45) brightness(1.08); }
}

@keyframes characterPop {
  from { transform: scale(1) rotate(-2deg); }
  to { transform: scale(1.11) rotate(3deg); }
}

@keyframes stationJump {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-24px) scale(1.08); }
}

@keyframes stationOops {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px) rotate(-2deg); }
  75% { transform: translateX(10px) rotate(2deg); }
}

@keyframes stationPenalty {
  0%, 100% { transform: translateX(0) scale(1); filter: grayscale(0); }
  24% { transform: translateX(-14px) rotate(-4deg); filter: grayscale(.3); }
  52% { transform: translateX(14px) rotate(4deg); filter: grayscale(.3); }
}

@keyframes beatPulse {
  0%, 100% { transform: translateX(-50%) scale(0.9); }
  50% { transform: translateX(-50%) scale(1.09); }
}

@keyframes tickPulse {
  0%, 100% { transform: scaleY(.55); opacity: .45; }
  50% { transform: scaleY(1.08); opacity: 1; }
}

@keyframes notesDance {
  from { transform: translateX(-50%) translateY(0); }
  to { transform: translateX(-50%) translateY(-10px); }
}

@keyframes trashFly {
  from { filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.14)); }
  to { filter: drop-shadow(0 20px 0 rgba(0, 0, 0, 0.08)); }
}

@keyframes trashScore {
  0% { transform: translateX(-50%) scale(1.22); }
  60% { transform: translateX(-50%) translateY(78px) scale(0.35) rotate(18deg); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes trashDrop {
  0% { transform: translateX(-50%) scale(1.1); }
  65% { transform: translateX(-20%) translateY(112px) rotate(22deg); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes trashPenalty {
  0%, 100% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-70%) translateY(20px) rotate(-28deg); }
  75% { transform: translateX(-30%) translateY(60px) rotate(24deg); }
}

@keyframes bubblePop {
  from { transform: translateX(-50%) scale(0.88); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes judgementPop {
  0% { transform: scale(0.55) rotate(-3deg); opacity: 0; }
  18% { transform: scale(1.08) rotate(1deg); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

@keyframes nowBadge {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

@keyframes dropZonePulse {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-5px) scale(1.2); }
}

@keyframes dotPulse {
  from { transform: scale(1); }
  to { transform: scale(1.22); }
}

@keyframes dustPop {
  0% { transform: translateX(-50%) scale(.4) rotate(-8deg); opacity: 0; }
  25% { transform: translateX(-50%) scale(1.08) rotate(4deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.15) translateY(-18px); opacity: 0; }
}

@keyframes sparkleBurst {
  0% { opacity: 0; transform: scale(.8); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.15); }
}

@keyframes earthSparkle {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(54, 218, 126, .18); }
}

@keyframes earthShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes stageZoomIn {
  from { transform: scale(.82); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes resultBoardIn {
  from { transform: translateY(-90px) scale(.94); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes scoreReveal {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes buddyFlash {
  0% { box-shadow: 0 0 0 0 rgba(255, 207, 68, 0.8); }
  100% { box-shadow: 0 0 0 26px rgba(255, 207, 68, 0); }
}

@keyframes studentRingFocus {
  0% {
    opacity: 0;
    transform: scale(1.9);
    filter: blur(2px);
  }

  18% {
    opacity: 1;
  }

  65% {
    opacity: 0.95;
    transform: scale(1.05);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: scale(0.72);
    filter: blur(4px);
  }
}

@keyframes studentBadgePop {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.18);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes activeGlow {
  from {
    filter: saturate(1.05);
    box-shadow:
      0 0 0 6px rgba(255, 255, 255, 0.62),
      0 0 22px var(--team-color),
      inset 0 -8px 0 rgba(0, 0, 0, 0.05);
  }

  to {
    filter: saturate(1.24);
    box-shadow:
      0 0 0 10px rgba(255, 255, 255, 0.82),
      0 0 38px var(--team-color),
      inset 0 -8px 0 rgba(0, 0, 0, 0.05);
  }
}

@keyframes avatarBounce {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-8px);
  }
}

@media (max-width: 1100px) {
  .game-header {
    grid-template-columns: 1fr;
  }

  .round-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-stage {
    min-height: 0;
  }

  .rhythm-arena {
    top: 285px;
    width: 88vw;
  }

  .player-station {
    width: 270px;
  }

  .player-station.top-left,
  .player-station.top-right {
    top: 96px;
  }

  .player-station.bottom-left,
  .player-station.bottom-right {
    bottom: 115px;
  }

  .stage-callout {
    right: 7%;
    left: 7%;
  }

  body.state-title .player-grid,
  body.state-ready .player-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    width: min(92vw, 880px);
  }
}

@media (max-width: 720px) {
  .game-shell {
    padding: 8px;
  }

  .game-header {
    grid-template-columns: 1fr;
    padding: 64px 10px 10px;
  }

  .round-board {
    grid-template-columns: 1fr;
  }

  .game-stage {
    min-height: 1240px;
  }

  .stage-title {
    top: 72px;
  }

  .round-dots {
    top: 16px;
    left: 16px;
  }

  .stage-earth-gauge {
    top: 14px;
    right: 14px;
    grid-template-columns: 44px 120px;
  }

  .stage-earth-gauge img {
    width: 44px;
    height: 44px;
  }

  .player-station {
    right: auto !important;
    left: 50% !important;
    width: min(330px, 90vw);
    transform: translateX(-50%);
  }

  body.state-title .player-station,
  body.state-ready .player-station {
    right: auto !important;
    left: auto !important;
    width: auto;
    transform: none;
  }

  body.state-title .player-grid,
  body.state-ready .player-grid {
    grid-template-columns: 1fr;
    width: min(90vw, 360px);
  }

  .player-station.top-left {
    top: 156px;
  }

  .player-station.top-right {
    top: 400px;
  }

  .player-station.bottom-left {
    top: 812px;
    bottom: auto;
  }

  .player-station.bottom-right {
    top: 1052px;
    bottom: auto;
  }

  body.state-title .player-station.top-left,
  body.state-title .player-station.top-right,
  body.state-title .player-station.bottom-left,
  body.state-title .player-station.bottom-right,
  body.state-ready .player-station.top-left,
  body.state-ready .player-station.top-right,
  body.state-ready .player-station.bottom-left,
  body.state-ready .player-station.bottom-right {
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none;
  }

  .rhythm-arena {
    top: 632px;
    width: 94vw;
    height: 290px;
  }

  .beat-ring {
    width: 126px;
    height: 126px;
  }

  .music-notes {
    min-width: 260px;
    letter-spacing: 12px;
  }

  .stage-callout {
    right: 4%;
    bottom: 16px;
    left: 4%;
  }

  .admin-actions.grid,
  .student-sim,
  .log-tabs,
  .range-row,
  .number-row {
    grid-template-columns: 1fr;
  }
}

/* Final viewport lock: the game is designed on a 1600x900 stage and scaled as one unit. */
html,
body,
#app {
  overflow: hidden !important;
}

.game-shell,
.game-stage {
  min-height: 0 !important;
}

body.state-title .game-stage,
body.state-ready .game-stage {
  position: relative !important;
  display: grid !important;
  grid-template-rows: 176px 210px minmax(0, 1fr) !important;
  height: 100% !important;
  padding: 84px 28px 18px !important;
}

body.state-title .player-grid,
body.state-ready .player-grid {
  position: relative !important;
  grid-row: 2 !important;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 18px !important;
  width: 94% !important;
  margin: 18px auto 0 !important;
  inset: auto !important;
}

body.state-title .player-station,
body.state-ready .player-station {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: auto !important;
  height: 210px !important;
  min-height: 0 !important;
  transform: none !important;
}

body.state-title .rhythm-arena,
body.state-ready .rhythm-arena {
  position: relative !important;
  grid-row: 1 !important;
  top: auto !important;
  left: auto !important;
  width: 980px !important;
  max-width: 82% !important;
  height: 176px !important;
  margin: 10px auto 0 !important;
  transform: none !important;
}

body.state-title .stage-callout,
body.state-ready .stage-callout {
  position: relative !important;
  grid-row: 3 !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: min(980px, 86%) !important;
  margin: 10px auto 0 !important;
  transform: none !important;
}

body.state-playing .game-stage {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
}

body.state-playing .player-grid {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
}

body.state-playing .player-station {
  position: absolute !important;
  width: 250px !important;
  height: 250px !important;
  min-height: 0 !important;
  transform: none;
}

body.state-playing .player-station.active {
  transform: none !important;
}

body.state-playing .player-station[data-team="A"] {
  top: 120px !important;
  right: auto !important;
  bottom: auto !important;
  left: 28px !important;
}

body.state-playing .player-station[data-team="B"] {
  top: 120px !important;
  right: 28px !important;
  bottom: auto !important;
  left: auto !important;
}

body.state-playing .player-station[data-team="C"] {
  top: auto !important;
  right: auto !important;
  bottom: 28px !important;
  left: 28px !important;
}

body.state-playing .player-station[data-team="D"] {
  top: auto !important;
  right: 28px !important;
  bottom: 28px !important;
  left: auto !important;
}

body.state-playing .rhythm-arena {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 720px !important;
  height: 460px !important;
  transform: translate(-50%, -50%) !important;
}

body.state-playing .stage-callout {
  right: auto !important;
  bottom: 34px !important;
  left: 50% !important;
  width: 720px !important;
  transform: translateX(-50%) !important;
}

/* Grid board redesign: no player station uses absolute coordinates in any state. */
.game-stage.stage-grid {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: grid !important;
  box-sizing: border-box;
  padding: 24px !important;
  gap: 16px 18px !important;
}

body.state-title .game-shell,
body.state-ready .game-shell,
body.state-paused .game-shell,
body.state-summary .game-shell {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  gap: 10px !important;
}

body.state-playing .game-shell {
  display: block !important;
}

body.state-title .game-stage.stage-grid,
body.state-ready .game-stage.stage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-template-rows: 64px 146px 190px 76px !important;
  gap: 12px 18px !important;
  padding: 18px 24px !important;
  grid-template-areas:
    "rounds centerTop centerTop earth"
    "rhythm rhythm rhythm rhythm"
    "teamA teamB teamC teamD"
    "callout callout callout callout" !important;
}

body.state-playing .game-stage.stage-grid,
body.state-paused .game-stage.stage-grid {
  position: absolute !important;
  inset: 0 !important;
  grid-template-columns: 300px minmax(0, 1fr) 300px !important;
  grid-template-rows: 74px minmax(0, 1fr) minmax(0, 1fr) 78px 116px !important;
  grid-template-areas:
    "rounds centerTop earth"
    "teamA rhythm teamB"
    "teamC rhythm teamD"
    "feedback feedback feedback"
    "callout callout callout" !important;
}

body.state-summary .game-stage.stage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-template-rows: 74px 210px 1fr 100px !important;
  grid-template-areas:
    "rounds centerTop centerTop earth"
    "teamA teamB teamC teamD"
    "feedback feedback feedback feedback"
    "callout callout callout callout" !important;
}

.team-slot {
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.team-slot-a {
  grid-area: teamA;
}

.team-slot-b {
  grid-area: teamB;
}

.team-slot-c {
  grid-area: teamC;
}

.team-slot-d {
  grid-area: teamD;
}

.player-grid {
  display: none !important;
}

.stage-title {
  grid-area: centerTop !important;
  position: relative !important;
  inset: auto !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  z-index: 6;
  align-self: center;
  justify-self: center;
}

.round-dots {
  grid-area: rounds !important;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  align-self: center;
  justify-self: start;
  z-index: 7;
}

.stage-earth-gauge {
  grid-area: earth !important;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  align-self: center;
  justify-self: end;
  z-index: 7;
}

.player-station,
body.state-title .player-station,
body.state-ready .player-station,
body.state-playing .player-station,
body.state-paused .player-station,
body.state-summary .player-station {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box;
  overflow: hidden;
  transform: none !important;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: 14px;
  border-radius: 28px;
  z-index: 5;
  pointer-events: auto;
}

.player-station[data-team="A"] {
  grid-area: teamA;
}

.player-station[data-team="B"] {
  grid-area: teamB;
}

.player-station[data-team="C"] {
  grid-area: teamC;
}

.player-station[data-team="D"] {
  grid-area: teamD;
}

.player-station.active,
body.state-playing .player-station.active {
  transform: none !important;
  box-shadow:
    0 0 0 8px rgba(255, 255, 255, 0.75),
    0 0 32px var(--team-color),
    inset 0 -8px 0 rgba(0, 0, 0, 0.05) !important;
  animation: activeGlow 0.6s infinite alternate !important;
}

.player-station.active .character {
  animation: avatarBounce 0.5s infinite alternate;
}

.station-head h2 {
  font-size: 30px !important;
}

.station-head,
.station-foot {
  min-width: 0;
}

.mini-score,
.combo-chip,
.held-item em {
  display: none !important;
}

.runner-chip {
  width: fit-content;
  max-width: 100%;
  margin: 2px 0 !important;
  font-size: 26px !important;
}

.character-wrap {
  min-height: 0;
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) !important;
  gap: 10px;
}

.character {
  width: 90px !important;
  height: 90px !important;
}

.character img {
  width: 82px !important;
  height: 82px !important;
}

.held-item {
  min-width: 0;
  align-self: center;
}

.held-item span {
  font-size: 62px !important;
}

.held-item b {
  max-width: 100%;
  color: #172018;
  font-size: 28px !important;
  line-height: 1.08;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-status {
  justify-self: start;
  font-size: 18px !important;
  padding: 7px 12px;
}

.rhythm-zone {
  grid-area: rhythm !important;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
  min-height: 0;
  transform: none !important;
  z-index: 4;
  display: grid !important;
  grid-template-rows: 54px minmax(0, 1fr) 132px 72px;
  gap: 10px;
  align-items: center;
  justify-items: center;
  overflow: hidden !important;
}

.beat-ticks,
.music-notes {
  grid-row: 1;
  grid-column: 1;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  align-self: center;
  justify-self: center;
}

.beat-ring,
.flying-trash,
.penalty-dust {
  grid-row: 2;
  grid-column: 1;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  align-self: center;
  justify-self: center;
}

.beat-ring {
  width: 210px !important;
  height: 210px !important;
}

.flying-trash {
  width: 120px !important;
  height: 120px !important;
  max-width: 120px;
  max-height: 120px;
  font-size: 82px !important;
  z-index: 9;
}

.rhythm-line {
  grid-row: 3;
  grid-column: 1;
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100%;
  height: 132px !important;
  align-self: stretch;
  justify-self: stretch;
}

.big-judgement {
  grid-row: 4;
  grid-column: 1;
  position: relative !important;
  inset: auto !important;
  width: 100%;
  height: 100%;
  font-size: 46px !important;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.feedback-zone,
.learning-bubble.feedback-zone {
  grid-area: feedback !important;
  position: relative !important;
  inset: auto !important;
  left: auto !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0;
  box-sizing: border-box;
  transform: none !important;
  z-index: 8;
  align-self: stretch;
  justify-self: stretch;
  padding: 10px 18px !important;
  border-radius: 22px !important;
  font-size: 24px !important;
  line-height: 1.22 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden !important;
}

body.state-title .feedback-zone,
body.state-ready .feedback-zone,
body.state-summary .feedback-zone {
  display: none !important;
}

.callout-zone,
.stage-callout.callout-zone,
body.state-playing .stage-callout.callout-zone {
  grid-area: callout !important;
  position: relative !important;
  inset: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  box-sizing: border-box;
  transform: none !important;
  z-index: 7;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 10px 18px !important;
  overflow: hidden !important;
}

.callout-main {
  width: min(900px, 92%);
  max-height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 42px !important;
  line-height: 1.05;
}

.callout-sub {
  max-width: 1040px;
  overflow: hidden;
  font-size: 21px !important;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.state-playing .stage-title {
  opacity: 1 !important;
  pointer-events: none;
}

body.state-playing .stage-title span {
  font-size: 34px !important;
}

body.state-playing .stage-title strong {
  display: none;
}

body.state-title .stage-title span,
body.state-ready .stage-title span {
  font-size: 44px !important;
}

body.state-title .station-foot,
body.state-ready .station-foot {
  display: none !important;
}

body.state-title .character-wrap,
body.state-ready .character-wrap {
  grid-template-columns: 74px minmax(0, 1fr) !important;
  gap: 8px;
}

body.state-title .character,
body.state-ready .character {
  width: 70px !important;
  height: 70px !important;
}

body.state-title .character img,
body.state-ready .character img {
  width: 64px !important;
  height: 64px !important;
}

body.state-title .held-item span,
body.state-ready .held-item span {
  font-size: 46px !important;
}

body.state-title .held-item b,
body.state-ready .held-item b {
  font-size: 22px !important;
}

body.state-title .callout-sub,
body.state-ready .callout-sub {
  display: none !important;
}

body.state-title .callout-main,
body.state-ready .callout-main {
  max-height: none;
  font-size: 34px !important;
}

/* Explicit grid placement wins over older state-specific row overrides. */
body.state-title .round-dots,
body.state-ready .round-dots,
body.state-summary .round-dots {
  grid-row: 1 !important;
  grid-column: 1 !important;
}

body.state-title .stage-title,
body.state-ready .stage-title,
body.state-summary .stage-title {
  grid-row: 1 !important;
  grid-column: 2 / 4 !important;
}

body.state-title .stage-earth-gauge,
body.state-ready .stage-earth-gauge,
body.state-summary .stage-earth-gauge {
  grid-row: 1 !important;
  grid-column: 4 !important;
}

body.state-title .rhythm-zone,
body.state-ready .rhythm-zone {
  grid-row: 2 !important;
  grid-column: 1 / -1 !important;
}

body.state-title .team-slot-a,
body.state-ready .team-slot-a,
body.state-summary .team-slot-a {
  grid-row: 3 !important;
  grid-column: 1 !important;
}

body.state-title .team-slot-b,
body.state-ready .team-slot-b,
body.state-summary .team-slot-b {
  grid-row: 3 !important;
  grid-column: 2 !important;
}

body.state-title .team-slot-c,
body.state-ready .team-slot-c,
body.state-summary .team-slot-c {
  grid-row: 3 !important;
  grid-column: 3 !important;
}

body.state-title .team-slot-d,
body.state-ready .team-slot-d,
body.state-summary .team-slot-d {
  grid-row: 3 !important;
  grid-column: 4 !important;
}

body.state-title .callout-zone,
body.state-ready .callout-zone {
  grid-row: 4 !important;
  grid-column: 1 / -1 !important;
}

body.state-playing .round-dots,
body.state-paused .round-dots {
  grid-row: 1 !important;
  grid-column: 1 !important;
}

body.state-playing .stage-title,
body.state-paused .stage-title {
  grid-row: 1 !important;
  grid-column: 2 !important;
}

body.state-playing .stage-earth-gauge,
body.state-paused .stage-earth-gauge {
  grid-row: 1 !important;
  grid-column: 3 !important;
}

body.state-playing .team-slot-a,
body.state-paused .team-slot-a {
  grid-row: 2 !important;
  grid-column: 1 !important;
}

body.state-playing .team-slot-b,
body.state-paused .team-slot-b {
  grid-row: 2 !important;
  grid-column: 3 !important;
}

body.state-playing .team-slot-c,
body.state-paused .team-slot-c {
  grid-row: 3 !important;
  grid-column: 1 !important;
}

body.state-playing .team-slot-d,
body.state-paused .team-slot-d {
  grid-row: 3 !important;
  grid-column: 3 !important;
}

body.state-playing .rhythm-zone,
body.state-paused .rhythm-zone {
  grid-row: 2 / 4 !important;
  grid-column: 2 !important;
}

body.state-playing .feedback-zone,
body.state-paused .feedback-zone {
  grid-row: 4 !important;
  grid-column: 1 / -1 !important;
}

body.state-playing .callout-zone,
body.state-paused .callout-zone {
  grid-row: 5 !important;
  grid-column: 1 / -1 !important;
}

body.state-playing .team-slot .player-station[data-team],
body.state-paused .team-slot .player-station[data-team],
body.state-title .team-slot .player-station[data-team],
body.state-ready .team-slot .player-station[data-team],
body.state-summary .team-slot .player-station[data-team] {
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
}

body.state-playing .rhythm-arena.rhythm-zone,
body.state-paused .rhythm-arena.rhythm-zone {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  height: auto !important;
  max-height: none !important;
  transform: none !important;
  justify-self: stretch;
  align-self: stretch;
}

body.state-title .rhythm-arena.rhythm-zone,
body.state-ready .rhythm-arena.rhythm-zone {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
}

/* Responsive stabilization pass: no fixed 16:9 board, no absolute team layout. */
html,
body,
#app,
.game-viewport,
.game-root {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.game-root {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  border-radius: 0 !important;
  aspect-ratio: auto !important;
  --safe-pad: clamp(8px, 1.4vmin, 24px);
  --gap: clamp(8px, 1.3vmin, 20px);
  --side-col: clamp(210px, 19vw, 330px);
  --top-row: clamp(44px, 7vh, 76px);
  --callout-h: clamp(74px, 12vh, 118px);
  --title-font: clamp(28px, 4.2vmin, 58px);
  --big-font: clamp(30px, 4.8vmin, 66px);
  --mid-font: clamp(20px, 2.8vmin, 38px);
  --small-font: clamp(14px, 1.8vmin, 24px);
  --admin-reserve: clamp(118px, 11vw, 168px);
}

.game-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: var(--safe-pad);
  display: grid !important;
  grid-template-rows: clamp(58px, 10vh, 104px) minmax(0, 1fr) !important;
  gap: var(--gap);
  overflow: hidden;
}

.lobby-header {
  min-height: 0 !important;
  height: 100% !important;
  width: calc(100% - var(--admin-reserve)) !important;
  justify-self: start !important;
  padding:
    clamp(8px, 1.1vmin, 16px)
    clamp(12px, 1.7vmin, 24px)
    clamp(8px, 1.1vmin, 16px)
    clamp(12px, 1.7vmin, 24px) !important;
  overflow: hidden;
  transition: transform 360ms ease, opacity 260ms ease;
}

.lobby-header h1 {
  font-size: clamp(24px, 3.5vmin, 44px) !important;
  line-height: 1 !important;
}

.lobby-header .eyebrow,
.lobby-header p,
.round-board span,
.score-ribbon {
  font-size: clamp(12px, 1.5vmin, 18px) !important;
}

body.state-playing .game-shell {
  display: block !important;
  padding: 0 !important;
}

body.state-playing .lobby-header {
  transform: translateY(-130%) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.state-playing .score-ribbon,
body.state-playing .round-board {
  opacity: 0 !important;
  pointer-events: none !important;
}

.game-stage.stage-grid {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  display: grid !important;
  gap: var(--gap) !important;
  padding: var(--safe-pad) !important;
  overflow: hidden !important;
  position: relative !important;
}

body.state-title .game-stage.stage-grid,
body.state-ready .game-stage.stage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-template-rows: clamp(82px, 15vh, 138px) minmax(0, 1fr) var(--callout-h) !important;
  grid-template-areas:
    "header header header header"
    "teamA teamB teamC teamD"
    "callout callout callout callout" !important;
}

body.state-playing .game-stage.stage-grid,
body.state-paused .game-stage.stage-grid {
  position: absolute !important;
  inset: 0 !important;
  grid-template-columns: var(--side-col) minmax(0, 1fr) var(--side-col) !important;
  grid-template-rows: var(--top-row) minmax(0, 1fr) minmax(0, 1fr) var(--callout-h) !important;
  grid-template-areas:
    "rounds rhythmTop earth"
    "teamA rhythm teamB"
    "teamC rhythm teamD"
    "callout callout callout" !important;
}

body.state-summary .game-stage.stage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-template-rows: clamp(66px, 10vh, 92px) minmax(0, 1fr) var(--callout-h) !important;
  grid-template-areas:
    "header header header header"
    "teamA teamB teamC teamD"
    "callout callout callout callout" !important;
}

@media (max-aspect-ratio: 4 / 3) {
  body.state-title .game-stage.stage-grid,
  body.state-ready .game-stage.stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: clamp(58px, 12vh, 104px) minmax(0, 1fr) minmax(0, 1fr) var(--callout-h) !important;
    grid-template-areas:
      "header header"
      "teamA teamB"
      "teamC teamD"
      "callout callout" !important;
  }

  .game-root {
    --side-col: clamp(170px, 21vw, 230px);
    --callout-h: clamp(64px, 10vh, 96px);
  }
}

.stage-title {
  grid-area: header !important;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

body.state-playing .stage-title,
body.state-paused .stage-title {
  grid-area: rhythmTop !important;
}

body.state-title .round-dots,
body.state-title .stage-earth-gauge,
body.state-ready .round-dots,
body.state-ready .stage-earth-gauge,
body.state-summary .round-dots,
body.state-summary .stage-earth-gauge {
  display: none !important;
}

body.state-playing .round-dots,
body.state-paused .round-dots {
  display: flex !important;
  grid-area: rounds !important;
  align-self: center !important;
  justify-self: start !important;
}

body.state-playing .stage-earth-gauge,
body.state-paused .stage-earth-gauge {
  display: flex !important;
  grid-area: earth !important;
  align-self: center !important;
  justify-self: end !important;
  max-width: 100%;
  margin-right: var(--admin-reserve);
  transform: none !important;
}

.team-slot {
  min-width: 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}

.team-slot-a { grid-area: teamA !important; }
.team-slot-b { grid-area: teamB !important; }
.team-slot-c { grid-area: teamC !important; }
.team-slot-d { grid-area: teamD !important; }

.player-station,
body.tv-mode .player-station,
body.state-playing .player-station,
body.state-paused .player-station,
body.state-title .player-station,
body.state-ready .player-station,
body.state-summary .player-station {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  transform: none !important;
  border-radius: clamp(16px, 2vmin, 28px) !important;
  border-width: clamp(4px, 0.7vmin, 7px) !important;
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) auto !important;
  gap: clamp(3px, 0.7vmin, 8px) !important;
  padding: clamp(8px, 1.3vmin, 16px) !important;
}

body.state-title .player-station,
body.state-ready .player-station {
  grid-template-rows: auto auto minmax(0, 1fr) auto !important;
  align-content: stretch !important;
  background: rgba(255, 255, 255, 0.96) !important;
}

body.state-title .station-head,
body.state-ready .station-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  min-width: 0 !important;
}

body.state-title .runner-chip,
body.state-ready .runner-chip,
body.state-title .student-badge,
body.state-ready .student-badge {
  display: inline-flex !important;
}

body.state-title .character-wrap,
body.state-ready .character-wrap {
  display: grid !important;
  align-items: center !important;
  min-height: 0 !important;
}

body.state-title .held-item,
body.state-ready .held-item {
  display: grid !important;
  min-width: 0 !important;
}

body.state-title .held-item span,
body.state-ready .held-item span,
body.state-title .held-item b,
body.state-ready .held-item b {
  display: block !important;
}

body.state-title .station-status,
body.state-ready .station-status {
  display: inline-flex !important;
}

body.state-title .station-foot,
body.state-ready .station-foot {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

body.state-title .combo-chip,
body.state-ready .combo-chip {
  display: none !important;
}

.player-station.active,
body.state-playing .player-station.active,
body.tv-mode .player-station.active {
  transform: none !important;
  box-shadow:
    0 0 0 clamp(4px, 0.8vmin, 9px) rgba(255, 255, 255, 0.75),
    0 0 clamp(16px, 3vmin, 36px) var(--team-color),
    inset 0 -8px 0 rgba(0, 0, 0, 0.05) !important;
}

.player-station.active .character {
  animation: avatarBounce 0.5s infinite alternate;
}

.station-head h2,
.team-title {
  font-size: clamp(22px, 3vmin, 42px) !important;
  line-height: 1 !important;
}

.runner-chip,
.student-badge {
  font-size: clamp(18px, 2.6vmin, 36px) !important;
}

.character-wrap {
  grid-template-columns: clamp(54px, 7vmin, 96px) minmax(0, 1fr) !important;
  gap: clamp(6px, 1vmin, 12px) !important;
  min-height: 0 !important;
}

.character,
.team-avatar {
  width: clamp(54px, 7vmin, 96px) !important;
  height: clamp(54px, 7vmin, 96px) !important;
}

.character img {
  width: 92% !important;
  height: 92% !important;
}

.held-item span,
.trash-icon {
  font-size: clamp(42px, 6vmin, 86px) !important;
  line-height: 1 !important;
}

.held-item b,
.trash-name {
  font-size: clamp(18px, 2.4vmin, 34px) !important;
  font-weight: 900 !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.mini-score,
.combo-chip,
.held-item em,
.station-foot {
  display: none !important;
}

.station-status {
  font-size: clamp(13px, 1.7vmin, 22px) !important;
  padding: clamp(4px, 0.8vmin, 8px) clamp(8px, 1.2vmin, 14px) !important;
}

.rhythm-zone,
body.state-playing .rhythm-arena.rhythm-zone,
body.state-paused .rhythm-arena.rhythm-zone {
  grid-area: rhythm !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  position: relative !important;
  display: grid !important;
  grid-template-rows:
    clamp(34px, 8%, 58px)
    minmax(clamp(120px, 22vh, 190px), 1fr)
    clamp(44px, 8%, 72px)
    clamp(112px, 19%, 160px)
    clamp(60px, 10%, 84px) !important;
  gap: clamp(5px, 0.9vmin, 10px) !important;
  align-items: center !important;
  justify-items: center !important;
  overflow: hidden !important;
  transform: none !important;
}

body.state-title .rhythm-zone,
body.state-ready .rhythm-zone,
body.state-summary .rhythm-zone {
  display: none !important;
}

.beat-ticks,
.music-notes {
  grid-row: 1 !important;
  grid-column: 1 !important;
  position: relative !important;
  inset: auto !important;
}

.drop-ring,
.beat-ring {
  grid-row: 2 !important;
  grid-column: 1 !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  width: clamp(132px, 18vmin, 210px) !important;
  height: clamp(132px, 18vmin, 210px) !important;
  display: grid !important;
  place-items: center !important;
  font-size: clamp(34px, 5vmin, 58px) !important;
  z-index: 2 !important;
}

.flying-trash {
  grid-row: 3 !important;
  grid-column: 1 !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  width: clamp(56px, 8vmin, 92px) !important;
  height: clamp(56px, 8vmin, 92px) !important;
  max-width: none !important;
  max-height: none !important;
  font-size: clamp(40px, 6.5vmin, 78px) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 6 !important;
}

.flying-trash.success,
.flying-trash.manual,
.flying-trash.miss,
.flying-trash.penalty {
  opacity: 1 !important;
  animation: flyTrash 620ms ease-out forwards !important;
}

.rhythm-line,
.conveyor-area {
  grid-row: 4 !important;
  grid-column: 1 !important;
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  overflow: hidden !important;
  border-radius: clamp(14px, 2vmin, 24px) !important;
}

.stage-bins,
.conveyor-track {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  left: auto !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  gap: clamp(8px, 1.1vmin, 14px) !important;
  will-change: transform;
}

.stage-bin {
  flex: 0 0 clamp(88px, 10vw, 126px) !important;
  width: clamp(88px, 10vw, 126px) !important;
  height: clamp(86px, 11vh, 126px) !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  border-radius: clamp(12px, 1.8vmin, 22px) !important;
  border: 4px solid #173326 !important;
  background: #fff !important;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12) !important;
  display: grid !important;
  grid-template-rows: 1fr auto !important;
  align-items: center !important;
  justify-items: center !important;
}

.stage-bin img,
.bin-icon {
  width: clamp(40px, 5.6vmin, 58px) !important;
  height: clamp(40px, 5.6vmin, 58px) !important;
  font-size: clamp(40px, 5.6vmin, 58px) !important;
}

.stage-bin b,
.bin-label,
body.stage-level-3:not(.state-hint-mode) .stage-bin b,
body.stage-level-4:not(.state-hint-mode) .stage-bin b {
  display: block !important;
  height: auto !important;
  max-height: none !important;
  opacity: 1 !important;
  overflow: visible !important;
  font-size: clamp(20px, 2.1vmin, 26px) !important;
  font-weight: 900 !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
}

.stage-bin.at-drop-zone {
  transform: translateY(-4px) !important;
}

body:not(.state-hint-mode) .stage-bin.hint-mode-bin {
  border-color: #173326 !important;
  background: #fff !important;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12) !important;
}

.drop-marker {
  position: absolute !important;
  left: 50% !important;
  bottom: clamp(4px, 0.8vmin, 10px) !important;
  transform: translateX(-50%) !important;
  z-index: 5 !important;
  pointer-events: none !important;
}

.big-judgement {
  grid-row: 3 !important;
  grid-column: 1 !important;
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
  font-size: clamp(30px, 4.6vmin, 60px) !important;
  line-height: 1 !important;
  pointer-events: none !important;
}

.learning-bubble.feedback-zone,
.feedback-zone {
  grid-row: 5 !important;
  grid-column: 1 !important;
  grid-area: auto !important;
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-width: none !important;
  box-sizing: border-box !important;
  padding: clamp(5px, 0.8vmin, 10px) clamp(10px, 1.2vmin, 16px) !important;
  border-radius: clamp(12px, 1.7vmin, 20px) !important;
  font-size: clamp(16px, 2vmin, 24px) !important;
  line-height: 1.15 !important;
  display: grid !important;
  place-items: center !important;
  text-align: center !important;
  overflow: hidden !important;
}

.learning-bubble.feedback-zone.hidden {
  display: none !important;
}

.callout-zone,
.stage-callout.callout-zone,
body.state-playing .stage-callout.callout-zone {
  grid-area: callout !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
  padding: clamp(6px, 1vmin, 12px) !important;
}

.current-callout,
.callout-main {
  width: min(92vw, 92%) !important;
  max-width: 100% !important;
  height: clamp(46px, 7vh, 74px) !important;
  max-height: 100% !important;
  box-sizing: border-box !important;
  border-radius: clamp(16px, 2vmin, 28px) !important;
  font-size: clamp(24px, 3.4vmin, 48px) !important;
  font-weight: 1000 !important;
  line-height: 1.05 !important;
  display: grid !important;
  place-items: center !important;
  text-align: center !important;
  overflow: hidden !important;
}

.callout-sub {
  font-size: clamp(13px, 1.8vmin, 22px) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.student-badge,
.runner-chip {
  position: relative;
  overflow: visible;
  isolation: isolate;
}

.student-focus-ring {
  position: absolute;
  inset: clamp(-16px, -1.2vmin, -10px);
  border-radius: 999px;
  pointer-events: none;
}

.overlay,
.result-overlay {
  position: absolute !important;
  inset: 0 !important;
  z-index: 5000 !important;
  display: grid;
  place-items: center;
}

.admin-backdrop.open {
  z-index: 7000 !important;
}

.admin-panel {
  z-index: 7100 !important;
}

.admin-toggle {
  top: clamp(8px, 1.3vmin, 16px) !important;
  right: clamp(8px, 1.3vmin, 16px) !important;
  min-height: clamp(34px, 5.4vh, 48px) !important;
  padding: 0 clamp(10px, 1.4vmin, 16px) !important;
  border-radius: 999px !important;
  font-size: clamp(14px, 1.8vmin, 20px) !important;
  z-index: 7200 !important;
}

.admin-toggle[aria-expanded="true"] {
  pointer-events: none !important;
  opacity: 0.25 !important;
}

.overlay.hidden {
  display: none !important;
}

.summary-card,
.result-card {
  width: min(82vw, 760px) !important;
  max-height: min(86dvh, 820px) !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border-radius: clamp(18px, 2.4vmin, 30px) !important;
  display: grid !important;
  grid-template-rows: auto 1fr auto auto !important;
  gap: clamp(8px, 1.4vmin, 16px) !important;
  padding: clamp(18px, 3vmin, 34px) !important;
}

.summary-card h2 {
  margin: 0 !important;
  font-size: clamp(34px, 5.4vmin, 68px) !important;
}

.summary-teams,
.result-list {
  display: grid !important;
  gap: clamp(6px, 1vmin, 10px) !important;
  overflow: hidden !important;
}

.summary-team,
.result-row {
  min-height: clamp(54px, 8vh, 76px) !important;
  display: grid !important;
  grid-template-columns: 1fr auto !important;
  align-items: center !important;
  border-radius: clamp(14px, 1.8vmin, 22px) !important;
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.2, 1.3, .3, 1), box-shadow 240ms ease, background 240ms ease !important;
}

.summary-team.pending {
  opacity: 0.38 !important;
  filter: grayscale(0.35);
}

.summary-team.revealed {
  opacity: 1 !important;
  transform: translateY(-2px) !important;
  animation: resultPop 520ms cubic-bezier(.2, 1.35, .3, 1) both;
}

.summary-team.winner {
  background: linear-gradient(90deg, #fff7b8, #ffffff) !important;
  box-shadow: 0 0 0 5px rgba(255, 220, 70, 0.55), 0 0 32px rgba(255, 203, 41, 0.65) !important;
  animation: winnerSpotlight 880ms ease-in-out infinite alternate;
}

.summary-team.winner b::before {
  content: "👑 ";
}

.summary-team strong {
  min-width: clamp(86px, 10vw, 140px);
  text-align: right;
}

.winner-line.pending {
  opacity: 0.5;
  background: #52665a !important;
}

.winner-line.revealed {
  animation: winnerReveal 680ms cubic-bezier(.2, 1.35, .3, 1) both;
}

body.state-summary .flying-trash,
body.state-summary .trash-flight-area,
body.state-summary .conveyor-area,
body.state-summary .rhythm-line,
body.state-summary .drop-area,
body.state-summary .drop-ring,
body.state-summary .beat-ring,
body.state-summary .team-slot,
body.state-summary .callout-zone,
body.state-summary .stage-title {
  display: none !important;
}

@media (max-width: 1100px) {
  .game-root {
    --side-col: clamp(170px, 21vw, 230px);
    --callout-h: clamp(64px, 10vh, 96px);
    --admin-reserve: clamp(104px, 13vw, 140px);
  }
}

@keyframes resultPop {
  0% {
    transform: scale(0.96);
  }
  55% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes winnerSpotlight {
  from {
    transform: translateY(-2px);
  }
  to {
    transform: translateY(-5px);
  }
}

@keyframes winnerReveal {
  0% {
    transform: scale(0.94);
    opacity: 0;
  }
  70% {
    transform: scale(1.04);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* Final prep-screen placement guard. Older explicit row rules must not collapse cards. */
body.state-title .game-stage.stage-grid,
body.state-ready .game-stage.stage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-template-rows: clamp(82px, 15vh, 138px) minmax(260px, 1fr) var(--callout-h) !important;
  grid-template-areas:
    "header header header header"
    "teamA teamB teamC teamD"
    "callout callout callout callout" !important;
}

body.state-title .stage-title,
body.state-ready .stage-title {
  grid-area: header !important;
  grid-row: 1 !important;
  grid-column: 1 / -1 !important;
}

body.state-title .team-slot-a,
body.state-ready .team-slot-a {
  grid-area: teamA !important;
  grid-row: 2 !important;
  grid-column: 1 !important;
}

body.state-title .team-slot-b,
body.state-ready .team-slot-b {
  grid-area: teamB !important;
  grid-row: 2 !important;
  grid-column: 2 !important;
}

body.state-title .team-slot-c,
body.state-ready .team-slot-c {
  grid-area: teamC !important;
  grid-row: 2 !important;
  grid-column: 3 !important;
}

body.state-title .team-slot-d,
body.state-ready .team-slot-d {
  grid-area: teamD !important;
  grid-row: 2 !important;
  grid-column: 4 !important;
}

body.state-title .callout-zone,
body.state-ready .callout-zone {
  grid-area: callout !important;
  grid-row: 3 !important;
  grid-column: 1 / -1 !important;
}

@media (max-aspect-ratio: 4 / 3) {
  body.state-title .game-stage.stage-grid,
  body.state-ready .game-stage.stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: clamp(58px, 12vh, 104px) minmax(0, 1fr) minmax(0, 1fr) var(--callout-h) !important;
    grid-template-areas:
      "header header"
      "teamA teamB"
      "teamC teamD"
      "callout callout" !important;
  }

  body.state-title .team-slot-c,
  body.state-ready .team-slot-c {
    grid-row: 3 !important;
    grid-column: 1 !important;
  }

  body.state-title .team-slot-d,
  body.state-ready .team-slot-d {
    grid-row: 3 !important;
    grid-column: 2 !important;
  }

  body.state-title .callout-zone,
  body.state-ready .callout-zone {
    grid-row: 4 !important;
  }
}

/* Final rail/text separation guard. Learning feedback uses the former music-note row. */
body.state-playing .rhythm-zone,
body.state-playing .rhythm-arena.rhythm-zone,
body.state-paused .rhythm-zone,
body.state-paused .rhythm-arena.rhythm-zone {
  grid-template-rows:
    clamp(66px, 13%, 108px)
    minmax(clamp(116px, 20vh, 184px), 1fr)
    clamp(54px, 8%, 76px)
    clamp(126px, 22%, 174px)
    clamp(0px, 0%, 0px) !important;
  gap: clamp(5px, 0.8vmin, 9px) !important;
}

body.state-playing .beat-ticks,
body.state-playing .music-notes,
body.state-paused .beat-ticks,
body.state-paused .music-notes {
  display: none !important;
}

body.state-playing .rhythm-line,
body.state-playing .conveyor-area,
body.state-paused .rhythm-line,
body.state-paused .conveyor-area {
  grid-row: 4 !important;
  position: relative !important;
  z-index: 4 !important;
  overflow: hidden !important;
}

body.state-playing #learningBubble.learning-bubble.feedback-zone,
body.state-paused #learningBubble.learning-bubble.feedback-zone {
  grid-row: 1 !important;
  grid-column: 1 !important;
  grid-area: auto !important;
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  width: min(100%, 920px) !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 108px !important;
  margin: 0 !important;
  padding: clamp(8px, 1.2vmin, 14px) clamp(16px, 2vmin, 26px) !important;
  border-width: clamp(3px, 0.55vmin, 5px) !important;
  border-radius: clamp(16px, 2vmin, 26px) !important;
  font-size: clamp(26px, 3.6vmin, 42px) !important;
  font-weight: 1000 !important;
  line-height: 1.12 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  white-space: normal !important;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  z-index: 6 !important;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.14), 0 12px 26px rgba(255, 218, 80, 0.28) !important;
}

body.state-playing #learningBubble.learning-bubble.feedback-zone.hidden,
body.state-paused #learningBubble.learning-bubble.feedback-zone.hidden {
  display: none !important;
}

body.state-playing .stage-callout.callout-zone,
body.state-paused .stage-callout.callout-zone {
  position: relative !important;
  grid-area: callout !important;
  z-index: 2 !important;
  overflow: hidden !important;
}

/* Item names should wrap inside team cards instead of ending with "...". */
.held-item b,
.trash-name,
body.state-playing .held-item b,
body.state-paused .held-item b {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: keep-all !important;
  overflow-wrap: anywhere !important;
  line-height: 1.12 !important;
  max-height: none !important;
}

.player-station.long-item .held-item b {
  font-size: clamp(18px, 2.05vmin, 28px) !important;
}

.player-station.very-long-item .held-item b {
  font-size: clamp(16px, 1.8vmin, 24px) !important;
  line-height: 1.08 !important;
}

/* Title/ready is an entrance screen, not an item quiz preview. */
body.state-title .stage-title,
body.state-ready .stage-title {
  align-self: center !important;
}

body.state-title .stage-title strong,
body.state-ready .stage-title strong {
  max-width: min(840px, 80vw) !important;
  margin-top: clamp(6px, 1vmin, 12px) !important;
  padding: clamp(8px, 1.2vmin, 14px) clamp(18px, 2.2vmin, 30px) !important;
  border: clamp(4px, 0.7vmin, 7px) solid #172018 !important;
  border-radius: 999px !important;
  background: linear-gradient(90deg, #fff37a, #ffd047, #fff37a) !important;
  color: #172018 !important;
  font-size: clamp(22px, 3vmin, 42px) !important;
  font-weight: 1000 !important;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18) !important;
  animation: readyGlow 900ms ease-in-out infinite alternate;
}

body.state-title .player-station,
body.state-ready .player-station {
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.84) 58%, rgba(255, 247, 170, 0.5)),
    repeating-linear-gradient(-12deg, rgba(255, 255, 255, 0.16) 0 14px, rgba(255, 255, 255, 0) 14px 28px) !important;
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.18),
    inset 0 -12px 0 rgba(0, 0, 0, 0.05),
    0 0 0 7px rgba(255, 255, 255, 0.6) !important;
}

body.state-title .player-station::after,
body.state-ready .player-station::after {
  content: "READY";
  position: absolute;
  right: clamp(12px, 1.5vmin, 20px);
  top: clamp(12px, 1.5vmin, 20px);
  bottom: auto;
  padding: 0.35em 0.7em;
  border-radius: 999px;
  background: var(--team-color);
  color: #102018;
  font-size: clamp(18px, 2.2vmin, 30px);
  font-weight: 1000;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
}

body.state-title .character-wrap,
body.state-ready .character-wrap {
  grid-template-columns: 1fr !important;
  place-items: center !important;
}

body.state-title .character,
body.state-ready .character {
  width: clamp(104px, 11vmin, 150px) !important;
  height: clamp(104px, 11vmin, 150px) !important;
  animation: avatarBounce 780ms ease-in-out infinite alternate;
}

body.state-title .character img,
body.state-ready .character img {
  width: 92% !important;
  height: 92% !important;
}

body.state-title .held-item,
body.state-ready .held-item {
  display: grid !important;
  place-items: center !important;
  min-height: clamp(42px, 6vh, 68px) !important;
}

body.state-title .held-item span,
body.state-title .held-item b,
body.state-ready .held-item span,
body.state-ready .held-item b {
  display: none !important;
}

body.state-title .held-item::after,
body.state-ready .held-item::after {
  content: "입장 준비!";
  color: #172018;
  font-size: clamp(24px, 3.2vmin, 46px);
  font-weight: 1000;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.85);
}

body.state-title .callout-main,
body.state-ready .callout-main {
  background: #ffffff !important;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.13), 0 0 28px rgba(255, 220, 70, 0.4) !important;
}

/* Keep the result board fully visible on 720p projectors. */
.summary-card,
.result-card {
  width: min(78vw, 760px) !important;
  max-height: calc(100dvh - 28px) !important;
  padding: clamp(14px, 2.2vmin, 26px) !important;
  gap: clamp(6px, 1vmin, 12px) !important;
  overflow: visible !important;
  grid-template-rows: auto auto auto auto !important;
}

.summary-card h2 {
  margin: 0 !important;
  font-size: clamp(34px, 5.2vmin, 64px) !important;
  line-height: 1 !important;
}

.summary-score,
.summary-teams {
  gap: clamp(5px, 0.8vmin, 9px) !important;
}

.summary-team,
.result-row {
  min-height: clamp(42px, 6.4vh, 62px) !important;
  padding: clamp(7px, 1vmin, 12px) clamp(12px, 1.7vmin, 18px) !important;
  font-size: clamp(24px, 3.2vmin, 38px) !important;
}

.winner-line {
  margin-top: clamp(5px, 0.8vmin, 9px) !important;
  padding: clamp(8px, 1.4vmin, 14px) clamp(12px, 1.8vmin, 20px) !important;
  font-size: clamp(28px, 4.4vmin, 48px) !important;
  line-height: 1.08 !important;
}

.esg-summary {
  padding-top: clamp(7px, 1vmin, 12px) !important;
  padding-bottom: clamp(7px, 1vmin, 12px) !important;
  margin-top: clamp(4px, 0.8vmin, 8px) !important;
  margin-bottom: clamp(4px, 0.8vmin, 8px) !important;
}

.esg-summary p,
.summary-help,
.hint-summary {
  margin: clamp(3px, 0.6vmin, 6px) 0 !important;
  font-size: clamp(15px, 2vmin, 22px) !important;
  line-height: 1.25 !important;
}

@keyframes readyGlow {
  from {
    filter: brightness(1);
    transform: translateY(0);
  }
  to {
    filter: brightness(1.08);
    transform: translateY(-2px);
  }
}

/* Full learning copy: centered, no ellipsis, shrink by length instead. */
body.state-playing #learningBubble.learning-bubble.feedback-zone,
body.state-paused #learningBubble.learning-bubble.feedback-zone {
  justify-content: center !important;
  text-align: center !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: keep-all !important;
  overflow-wrap: anywhere !important;
}

body.state-playing #learningBubble.learning-bubble.feedback-zone.feedback-long,
body.state-paused #learningBubble.learning-bubble.feedback-zone.feedback-long {
  font-size: clamp(22px, 3vmin, 34px) !important;
  line-height: 1.08 !important;
}

body.state-playing #learningBubble.learning-bubble.feedback-zone.feedback-very-long,
body.state-paused #learningBubble.learning-bubble.feedback-zone.feedback-very-long {
  font-size: clamp(18px, 2.45vmin, 28px) !important;
  line-height: 1.06 !important;
}

body.state-playing #learningBubble.learning-bubble.feedback-zone.feedback-ultra-long,
body.state-paused #learningBubble.learning-bubble.feedback-zone.feedback-ultra-long {
  font-size: clamp(15px, 2.05vmin, 23px) !important;
  line-height: 1.04 !important;
}

/* DROP is a neutral input target. It should not reveal the correct timing with red color. */
body.state-playing .beat-ring,
body.state-playing .beat-ring.hit-window,
body.state-paused .beat-ring,
body.state-paused .beat-ring.hit-window {
  border-color: rgba(255, 207, 51, 0.94) !important;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.96), rgba(57, 205, 136, 0.48)) !important;
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.5), 0 18px 42px rgba(0, 0, 0, 0.22) !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Winner reveal fireworks. */
.summary-card {
  position: relative !important;
}

.firework-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

.summary-card.winner-revealed .firework-layer,
.firework-layer.show {
  opacity: 1;
}

.firework-layer span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(8px, 1.2vmin, 14px);
  height: clamp(8px, 1.2vmin, 14px);
  border-radius: 50%;
  background: hsl(calc(var(--i) * 31), 95%, 58%);
  box-shadow:
    0 -34px 0 hsl(calc(var(--i) * 31 + 40), 95%, 62%),
    30px -18px 0 hsl(calc(var(--i) * 31 + 80), 95%, 58%),
    30px 18px 0 hsl(calc(var(--i) * 31 + 130), 95%, 60%),
    0 34px 0 hsl(calc(var(--i) * 31 + 180), 95%, 58%),
    -30px 18px 0 hsl(calc(var(--i) * 31 + 230), 95%, 62%),
    -30px -18px 0 hsl(calc(var(--i) * 31 + 280), 95%, 58%);
  opacity: 0;
  transform: scale(0.1);
}

.summary-card.winner-revealed .firework-layer span,
.firework-layer.show span {
  animation: fireworkBurst 1250ms cubic-bezier(.15, .95, .2, 1) infinite;
  animation-delay: calc((var(--i) % 6) * 110ms);
}

@keyframes fireworkBurst {
  0% {
    opacity: 0;
    transform: scale(0.08) rotate(0deg);
    filter: brightness(1.4);
  }
  15% {
    opacity: 1;
  }
  55% {
    opacity: 1;
    transform: scale(1) rotate(35deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.55) rotate(72deg);
    filter: brightness(1);
  }
}

/* Final readability guard: never expose student-facing copy as "...". */
body.state-playing .stage-callout.callout-zone,
body.state-paused .stage-callout.callout-zone {
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.86fr) !important;
  align-content: center !important;
  justify-items: center !important;
  text-align: center !important;
}

body.state-playing .callout-main,
body.state-paused .callout-main {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: keep-all !important;
  overflow-wrap: anywhere !important;
}

body.state-playing .callout-sub,
body.state-paused .callout-sub {
  width: min(980px, 96%) !important;
  max-width: 100% !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: keep-all !important;
  overflow-wrap: anywhere !important;
  text-align: center !important;
  line-height: 1.08 !important;
}

body.state-playing .callout-zone.callout-long .callout-sub,
body.state-paused .callout-zone.callout-long .callout-sub {
  font-size: clamp(16px, 2.2vmin, 26px) !important;
}

body.state-playing .callout-zone.callout-very-long .callout-sub,
body.state-paused .callout-zone.callout-very-long .callout-sub {
  font-size: clamp(14px, 1.85vmin, 22px) !important;
  line-height: 1.02 !important;
}

.held-item,
body.state-playing .held-item,
body.state-paused .held-item {
  max-width: 100% !important;
  overflow: visible !important;
}

.held-item b,
.trash-name,
body.state-playing .held-item b,
body.state-paused .held-item b {
  display: block !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: keep-all !important;
  overflow-wrap: anywhere !important;
  text-align: left !important;
}

.player-station.long-item .held-item b {
  font-size: clamp(15px, 1.85vmin, 25px) !important;
  line-height: 1.08 !important;
}

.player-station.very-long-item .held-item b {
  font-size: clamp(13px, 1.55vmin, 21px) !important;
  line-height: 1.02 !important;
}

.result-card,
.summary-card {
  max-height: calc(100dvh - 28px) !important;
  overflow-y: auto !important;
}

.summary-card > *:not(.firework-layer) {
  position: relative;
  z-index: 3;
}

.firework-layer {
  z-index: 2;
}

/* Current-turn visibility and item-name centering. */
.held-item,
body.state-playing .held-item,
body.state-paused .held-item {
  width: 100% !important;
  justify-items: center !important;
  text-align: center !important;
}

.held-item b,
.trash-name,
body.state-playing .held-item b,
body.state-paused .held-item b {
  width: 100% !important;
  text-align: center !important;
}

.player-station.turn-focus {
  box-shadow:
    0 0 0 clamp(5px, 0.85vmin, 10px) rgba(255, 255, 255, 0.88),
    0 0 clamp(22px, 4vmin, 48px) var(--team-color),
    inset 0 0 0 clamp(4px, 0.7vmin, 8px) rgba(255, 255, 255, 0.62) !important;
  animation: turnFocusGlow 760ms ease-in-out infinite alternate !important;
}

.player-station.turn-focus .student-badge {
  box-shadow:
    0 0 0 clamp(4px, 0.7vmin, 8px) rgba(255, 255, 255, 0.92),
    0 0 clamp(16px, 3vmin, 34px) var(--team-color) !important;
}

.player-station.turn-focus .character {
  animation: avatarBounce 560ms ease-in-out infinite alternate !important;
}

@keyframes turnFocusGlow {
  from {
    filter: saturate(1.04) brightness(1);
  }
  to {
    filter: saturate(1.22) brightness(1.08);
  }
}

/* Full-screen winner confetti, not just inside the result card. */
.overlay .firework-layer,
.result-overlay .firework-layer,
.summary-card.winner-revealed .firework-layer,
.firework-layer.show {
  position: fixed !important;
  inset: -8vh -6vw !important;
  z-index: 9000 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  opacity: 1 !important;
}

.firework-layer span {
  position: absolute !important;
  left: var(--x) !important;
  top: var(--y) !important;
  width: clamp(7px, 0.8vmin, 13px) !important;
  height: clamp(18px, 2.1vmin, 32px) !important;
  border-radius: 4px !important;
  background: hsl(calc(var(--i) * 47), 96%, 58%) !important;
  box-shadow: none !important;
  opacity: 0;
  transform: translate3d(0, -12vh, 0) rotate(0deg);
}

.summary-card.winner-revealed .firework-layer span,
.firework-layer.show span {
  animation: confettiPaperFall calc(1800ms + (var(--i) % 5) * 240ms) linear infinite !important;
  animation-delay: calc((var(--i) % 11) * -150ms) !important;
}

@keyframes confettiPaperFall {
  0% {
    opacity: 0;
    transform: translate3d(calc((var(--i) % 5 - 2) * 3vw), -12vh, 0) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  55% {
    opacity: 1;
    transform: translate3d(calc((var(--i) % 7 - 3) * 5vw), 54vh, 0) rotate(calc(var(--i) * 37deg));
  }
  100% {
    opacity: 0;
    transform: translate3d(calc((var(--i) % 9 - 4) * 7vw), 118vh, 0) rotate(calc(var(--i) * 74deg));
  }
}

/* Final pass for classroom readability. */
#learningBubble.learning-bubble.feedback-zone {
  display: grid !important;
  place-items: center !important;
  justify-content: center !important;
  align-content: center !important;
  text-align: center !important;
  width: 100% !important;
  max-width: 100% !important;
  justify-self: stretch !important;
  align-self: stretch !important;
  box-sizing: border-box !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: clamp(20px, 2.6vmin, 42px) !important;
  padding-right: clamp(20px, 2.6vmin, 42px) !important;
}

#learningBubble.learning-bubble.feedback-zone::before,
#learningBubble.learning-bubble.feedback-zone::after {
  content: "";
}

body.state-playing .player-station.turn-focus,
body.state-paused .player-station.turn-focus {
  background: rgba(255, 255, 255, 0.98) !important;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--team-color) 22%, white), rgba(255, 255, 255, 0.96) 62%) !important;
  border-width: clamp(7px, 1vmin, 11px) !important;
  outline: clamp(7px, 0.9vmin, 12px) solid color-mix(in srgb, var(--team-color) 55%, white) !important;
  outline-offset: clamp(-5px, -0.45vmin, -3px) !important;
  box-shadow:
    0 0 0 clamp(7px, 1vmin, 13px) rgba(255, 255, 255, 0.92),
    0 0 clamp(34px, 5.5vmin, 70px) var(--team-color),
    inset 0 0 clamp(18px, 3vmin, 42px) color-mix(in srgb, var(--team-color) 32%, transparent) !important;
}

body.state-playing .player-station.turn-focus[data-team="A"],
body.state-paused .player-station.turn-focus[data-team="A"] {
  background: linear-gradient(135deg, #c7ffd9 0%, #ffffff 66%) !important;
}

body.state-playing .player-station.turn-focus[data-team="B"],
body.state-paused .player-station.turn-focus[data-team="B"] {
  background: linear-gradient(135deg, #c9ecff 0%, #ffffff 66%) !important;
}

body.state-playing .player-station.turn-focus[data-team="C"],
body.state-paused .player-station.turn-focus[data-team="C"] {
  background: linear-gradient(135deg, #ffe4a8 0%, #ffffff 66%) !important;
}

body.state-playing .player-station.turn-focus[data-team="D"],
body.state-paused .player-station.turn-focus[data-team="D"] {
  background: linear-gradient(135deg, #edd1ff 0%, #ffffff 66%) !important;
}

body.state-playing .player-station.turn-focus::before,
body.state-paused .player-station.turn-focus::before {
  content: "차례";
  position: absolute;
  top: clamp(8px, 1vmin, 14px);
  right: clamp(8px, 1vmin, 14px);
  z-index: 5;
  border: 4px solid #172018;
  border-radius: 999px;
  padding: 0.16em 0.55em;
  background: #ffcf33;
  color: #172018;
  font-size: clamp(17px, 2vmin, 28px);
  font-weight: 1000;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.14);
}

.stage-callout.callout-zone,
.stage-callout.callout-zone .callout-main,
.stage-callout.callout-zone .callout-sub {
  font-family: inherit !important;
  font-style: normal !important;
  letter-spacing: 0 !important;
  text-align: center !important;
}

.stage-callout.callout-zone .callout-main {
  font-weight: 1000 !important;
}

.stage-callout.callout-zone .callout-sub {
  font-weight: 850 !important;
}

.summary-card.winner-revealed .firework-layer,
.firework-layer.show {
  opacity: 1 !important;
}

.summary-card.winner-revealed .firework-layer span,
.firework-layer.show span {
  animation-iteration-count: infinite !important;
}

/* Override the older 920px cap: feedback must span from the left team lane to the right team lane. */
body.state-playing #learningBubble.learning-bubble.feedback-zone,
body.state-paused #learningBubble.learning-bubble.feedback-zone {
  position: fixed !important;
  top: clamp(78px, 10.5dvh, 108px) !important;
  left: calc(var(--safe-pad) + var(--side-col) + var(--gap)) !important;
  right: calc(var(--safe-pad) + var(--side-col) + var(--gap)) !important;
  bottom: auto !important;
  width: auto !important;
  max-width: none !important;
  height: clamp(70px, 10dvh, 98px) !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  display: grid !important;
  place-items: center !important;
  justify-content: stretch !important;
  align-content: center !important;
  text-align: center !important;
  padding: clamp(8px, 1.2vmin, 14px) clamp(22px, 3vmin, 48px) !important;
  box-sizing: border-box !important;
  z-index: 60 !important;
}

/* Result screen final layout: no scrolling, full-screen confetti, all content visible. */
#stageSummary.overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 5000 !important;
  display: grid !important;
  place-items: center !important;
  padding: clamp(8px, 1.6vmin, 18px) !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

#stageSummary.overlay.hidden {
  display: none !important;
}

#stageSummary .summary-card {
  position: relative !important;
  z-index: 5010 !important;
  width: min(760px, 88vw) !important;
  height: min(840px, calc(100dvh - clamp(16px, 3.2vmin, 36px))) !important;
  max-height: calc(100dvh - clamp(16px, 3.2vmin, 36px)) !important;
  overflow: hidden !important;
  overflow-y: hidden !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto auto !important;
  gap: clamp(5px, 0.9vmin, 10px) !important;
  padding: clamp(12px, 2.1vmin, 24px) !important;
  box-sizing: border-box !important;
}

#stageSummary .summary-card h2 {
  margin: 0 !important;
  font-size: clamp(32px, 5.1vmin, 58px) !important;
  line-height: 0.98 !important;
  text-align: center !important;
}

#stageSummary .summary-score {
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, auto) !important;
  gap: clamp(5px, 0.8vmin, 9px) !important;
  overflow: hidden !important;
}

#stageSummary .summary-teams {
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: repeat(4, minmax(42px, 1fr)) !important;
  gap: clamp(4px, 0.7vmin, 8px) !important;
  overflow: hidden !important;
}

#stageSummary .summary-team {
  min-height: 0 !important;
  height: auto !important;
  padding: clamp(5px, 0.9vmin, 10px) clamp(10px, 1.5vmin, 16px) !important;
  border-width: clamp(3px, 0.55vmin, 5px) !important;
  border-radius: clamp(12px, 1.6vmin, 18px) !important;
  font-size: clamp(22px, 3.3vmin, 36px) !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}

#stageSummary .summary-team strong {
  min-width: clamp(78px, 11vw, 132px) !important;
  text-align: right !important;
}

#stageSummary .winner-line {
  margin: clamp(4px, 0.7vmin, 8px) 0 0 !important;
  padding: clamp(7px, 1.2vmin, 12px) clamp(12px, 1.8vmin, 20px) !important;
  border-radius: 999px !important;
  font-size: clamp(26px, 4.1vmin, 44px) !important;
  line-height: 1 !important;
  text-align: center !important;
}

#stageSummary .esg-summary {
  min-height: 0 !important;
  margin: 0 !important;
  padding: clamp(5px, 0.8vmin, 9px) 0 !important;
  overflow: hidden !important;
}

#stageSummary .esg-summary p,
#stageSummary .summary-help,
#stageSummary .hint-summary {
  margin: clamp(2px, 0.45vmin, 5px) 0 !important;
  font-size: clamp(13px, 1.8vmin, 19px) !important;
  line-height: 1.16 !important;
}

#stageSummary .summary-help {
  text-align: center !important;
}

#stageSummary .summary-firework-layer,
#stageSummary .summary-firework-layer.show {
  position: fixed !important;
  inset: 0 !important;
  z-index: 5005 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  opacity: 1 !important;
}

#stageSummary .summary-firework-layer span {
  position: absolute !important;
  left: var(--x) !important;
  top: -12vh !important;
  width: var(--size, 10px) !important;
  height: calc(var(--size, 10px) * 1.9) !important;
  border-radius: 3px !important;
  background: hsl(calc(var(--i) * 43), 96%, 58%) !important;
  box-shadow: none !important;
  opacity: 0 !important;
  transform: translate3d(0, -12vh, 0) rotate(0deg) !important;
}

#stageSummary .summary-firework-layer.show span {
  animation: resultConfettiFall var(--duration, 2800ms) linear infinite !important;
  animation-delay: var(--delay, 0ms) !important;
}

@keyframes resultConfettiFall {
  0% {
    opacity: 0;
    transform: translate3d(calc((var(--i) % 5 - 2) * 2.8vw), -12vh, 0) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  72% {
    opacity: 1;
    transform: translate3d(calc((var(--i) % 9 - 4) * 5.5vw), 74vh, 0) rotate(calc(var(--i) * 39deg));
  }
  100% {
    opacity: 0;
    transform: translate3d(calc((var(--i) % 11 - 5) * 6.5vw), 114vh, 0) rotate(calc(var(--i) * 83deg));
  }
}

@media (max-height: 760px) {
  #stageSummary .summary-card {
    width: min(740px, 86vw) !important;
    gap: 5px !important;
    padding: 12px !important;
  }

  #stageSummary .summary-card h2 {
    font-size: clamp(30px, 5vmin, 48px) !important;
  }

  #stageSummary .summary-team {
    font-size: clamp(20px, 3.1vmin, 32px) !important;
    padding-top: 5px !important;
    padding-bottom: 5px !important;
  }

  #stageSummary .winner-line {
    font-size: clamp(24px, 3.8vmin, 38px) !important;
  }

  #stageSummary .esg-summary p,
  #stageSummary .summary-help,
  #stageSummary .hint-summary {
    font-size: clamp(12px, 1.7vmin, 17px) !important;
    line-height: 1.12 !important;
  }
}

body.state-playing #learningBubble.learning-bubble.feedback-zone.hidden,
body.state-paused #learningBubble.learning-bubble.feedback-zone.hidden {
  display: none !important;
}

/* ========================================================================== */
/* 2026-09-04 QA overrides: accessibility, motion, and compact landscape UI. */
/* ========================================================================== */

/* Keep the confetti alpha under keyframe control even though an older rule
   fixes `opacity` with !important. The animated custom property feeds the
   important declaration, so the pieces can fade in and out normally. */
@property --qa-confetti-opacity {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

#stageSummary .summary-firework-layer span {
  top: 0 !important;
  opacity: var(--qa-confetti-opacity) !important;
  transform: none !important;
  --qa-confetti-mid-x: 2vw;
  --qa-confetti-end-x: -3vw;
  --qa-confetti-mid-spin: 390deg;
  --qa-confetti-end-spin: 760deg;
}

#stageSummary .summary-firework-layer span:nth-child(3n + 1) {
  --qa-confetti-mid-x: -5vw;
  --qa-confetti-end-x: 4vw;
  --qa-confetti-mid-spin: -330deg;
  --qa-confetti-end-spin: -700deg;
}

#stageSummary .summary-firework-layer span:nth-child(3n + 2) {
  --qa-confetti-mid-x: 6vw;
  --qa-confetti-end-x: 9vw;
  --qa-confetti-mid-spin: 460deg;
  --qa-confetti-end-spin: 840deg;
}

@keyframes resultConfettiFall {
  0% {
    --qa-confetti-opacity: 0;
    opacity: 0;
    translate: 0 -12vh;
    rotate: 0deg;
  }

  8% {
    --qa-confetti-opacity: 1;
    opacity: 1;
  }

  72% {
    --qa-confetti-opacity: 1;
    opacity: 1;
    translate: var(--qa-confetti-mid-x) 74vh;
    rotate: var(--qa-confetti-mid-spin);
  }

  100% {
    --qa-confetti-opacity: 0;
    opacity: 0;
    translate: var(--qa-confetti-end-x) 114vh;
    rotate: var(--qa-confetti-end-spin);
  }
}

.beat-ring[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 207, 51, 0.34);
}

.beat-ring[role="button"]:focus-visible {
  outline: 5px solid #075985 !important;
  outline-offset: 6px !important;
  box-shadow:
    0 0 0 11px rgba(255, 255, 255, 0.94),
    0 0 0 17px rgba(7, 89, 133, 0.38),
    0 18px 42px rgba(0, 0, 0, 0.26) !important;
}

.big-judgement {
  -webkit-text-stroke: clamp(3px, 0.55vmin, 6px) rgba(8, 19, 14, 0.96) !important;
  paint-order: stroke fill !important;
  text-shadow:
    -3px -3px 0 #08130e,
    3px -3px 0 #08130e,
    -3px 3px 0 #08130e,
    3px 3px 0 #08130e,
    0 7px 0 #08130e,
    0 10px 18px rgba(0, 0, 0, 0.72),
    0 0 22px rgba(0, 0, 0, 0.5) !important;
}

/* Reusable controls added by the 2026-09-04 interaction QA pass. */
.summary-next-button {
  justify-self: center;
  width: min(100%, 360px);
  min-height: 48px;
  border: 3px solid #173326;
  border-radius: 999px;
  padding: 8px 20px;
  background: linear-gradient(180deg, #ffeb61, #ffc928);
  color: #172018;
  box-shadow: 0 6px 0 rgba(23, 51, 38, 0.22);
  font-size: clamp(17px, 2.2vmin, 23px);
  font-weight: 1000;
  line-height: 1.1;
}

.summary-next-button:hover {
  filter: brightness(1.04);
}

.summary-next-button:focus-visible {
  outline: 4px solid #075985;
  outline-offset: 4px;
}

body.admin-open .admin-toggle {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.screen-notice {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  place-items: center;
  padding: clamp(22px, 7vmin, 52px);
  border: clamp(8px, 2vmin, 16px) solid rgba(255, 255, 255, 0.86);
  background:
    radial-gradient(circle at 50% 25%, rgba(255, 244, 153, 0.96), transparent 34%),
    linear-gradient(145deg, #5bd4ef, #8d7bea 58%, #ff91bd);
  color: #10251b;
  font-size: clamp(22px, 6vmin, 42px);
  font-weight: 1000;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
}

.screen-notice > * {
  max-width: 680px;
  margin: 0;
  border: 4px solid #173326;
  border-radius: 28px;
  padding: clamp(20px, 6vmin, 42px);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 0 rgba(23, 51, 38, 0.2);
}

.screen-notice strong,
.screen-notice span {
  display: block;
  word-break: keep-all;
}

.screen-notice strong {
  font-size: 0.88em;
}

.screen-notice span {
  margin-top: 0.65em;
  font-size: 0.62em;
  line-height: 1.45;
}

@media (orientation: portrait), (max-width: 759px) {
  .screen-notice {
    display: grid !important;
  }
}

/* 800x600 and 1024x768: reserve a short, two-column lobby header and use the
   remaining height for a complete 2x2 team-card grid. */
@media (orientation: landscape) and (min-width: 760px) and (max-width: 1100px) and (max-height: 800px) {
  body.state-title .game-shell,
  body.state-ready .game-shell {
    grid-template-rows: clamp(104px, 16vh, 118px) minmax(0, 1fr) !important;
    gap: 6px !important;
    padding: 6px !important;
  }

  body.state-title .lobby-header,
  body.state-ready .lobby-header {
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr) !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    column-gap: 8px !important;
    row-gap: 3px !important;
    width: calc(100% - var(--admin-reserve)) !important;
    height: 100% !important;
    padding: 5px 8px !important;
    border-width: 3px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }

  body.state-title .lobby-header .brand-block,
  body.state-ready .lobby-header .brand-block {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    align-content: center;
    min-width: 0;
  }

  body.state-title .lobby-header .eyebrow,
  body.state-ready .lobby-header .eyebrow {
    justify-self: start;
    min-height: 17px;
    padding: 1px 7px;
    font-size: 10px !important;
    line-height: 1.1;
  }

  body.state-title .lobby-header h1,
  body.state-ready .lobby-header h1 {
    margin: 2px 0 0 !important;
    overflow: hidden;
    font-size: clamp(20px, 3.1vw, 28px) !important;
    line-height: 0.96 !important;
    white-space: nowrap;
  }

  body.state-title .lobby-header .brand-block p,
  body.state-ready .lobby-header .brand-block p {
    margin: 3px 0 0 !important;
    font-size: clamp(11px, 1.65vw, 14px) !important;
    line-height: 1 !important;
    white-space: nowrap;
  }

  body.state-title .lobby-header .round-board,
  body.state-ready .lobby-header .round-board {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: 0.62fr 0.75fr 1.63fr !important;
    gap: 4px !important;
    min-width: 0;
    min-height: 0;
  }

  body.state-title .lobby-header .round-board > div,
  body.state-ready .lobby-header .round-board > div {
    min-width: 0;
    min-height: 0 !important;
    height: 100%;
    border-radius: 11px;
    padding: 4px 6px;
    overflow: hidden;
  }

  body.state-title .lobby-header .round-board span,
  body.state-ready .lobby-header .round-board span {
    font-size: clamp(9px, 1.4vw, 12px) !important;
    line-height: 1;
  }

  body.state-title .lobby-header .round-board strong,
  body.state-ready .lobby-header .round-board strong {
    margin-top: 2px;
    font-size: clamp(18px, 3vh, 24px) !important;
    line-height: 1;
  }

  body.state-title .lobby-header .earth-panel,
  body.state-ready .lobby-header .earth-panel {
    grid-template-columns: clamp(28px, 5vh, 36px) minmax(0, 1fr) auto;
    gap: 2px 4px;
  }

  body.state-title .lobby-header .earth-panel img,
  body.state-ready .lobby-header .earth-panel img {
    width: clamp(28px, 5vh, 36px);
    height: clamp(28px, 5vh, 36px);
  }

  body.state-title .lobby-header .earth-bar,
  body.state-ready .lobby-header .earth-bar {
    height: 8px;
    border-width: 1px;
  }

  body.state-title .lobby-header .score-ribbon,
  body.state-ready .lobby-header .score-ribbon {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 20px;
    padding: 3px 8px;
    font-size: clamp(10px, 1.65vw, 13px) !important;
    line-height: 1.1;
  }

  body.state-title .game-stage.stage-grid,
  body.state-ready .game-stage.stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: clamp(48px, 9vh, 64px) minmax(0, 1fr) minmax(0, 1fr) clamp(56px, 10vh, 72px) !important;
    grid-template-areas:
      "header header"
      "teamA teamB"
      "teamC teamD"
      "callout callout" !important;
    gap: 6px !important;
    padding: 8px !important;
  }

  body.state-title .stage-title span,
  body.state-ready .stage-title span {
    font-size: clamp(17px, 3vh, 23px) !important;
    line-height: 1 !important;
  }

  body.state-title .stage-title strong,
  body.state-ready .stage-title strong {
    max-width: 94vw !important;
    margin-top: 2px !important;
    padding: 3px 11px !important;
    border-width: 3px !important;
    font-size: clamp(14px, 2.5vh, 19px) !important;
    line-height: 1 !important;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18) !important;
  }

  body.state-title .player-station,
  body.state-ready .player-station {
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    gap: 2px !important;
    padding: clamp(5px, 1vh, 8px) !important;
    border-width: 4px !important;
    border-radius: 16px !important;
  }

  body.state-title .station-head h2,
  body.state-ready .station-head h2 {
    font-size: clamp(18px, 3.2vh, 24px) !important;
  }

  body.state-title .runner-chip,
  body.state-ready .runner-chip,
  body.state-title .student-badge,
  body.state-ready .student-badge {
    justify-self: start;
    min-height: 20px;
    margin: 0 !important;
    padding: 2px 8px !important;
    font-size: clamp(13px, 2.25vh, 17px) !important;
    line-height: 1.05;
  }

  body.state-title .character-wrap,
  body.state-ready .character-wrap {
    grid-template-columns: clamp(54px, 10vh, 78px) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    place-items: center !important;
    gap: clamp(5px, 1vw, 10px) !important;
    overflow: hidden;
  }

  body.state-title .character,
  body.state-ready .character {
    width: clamp(54px, 10vh, 78px) !important;
    height: clamp(54px, 10vh, 78px) !important;
    border-width: 3px;
  }

  body.state-title .held-item,
  body.state-ready .held-item {
    width: 100%;
    height: 100%;
    min-height: 0 !important;
    place-items: center !important;
  }

  body.state-title .held-item::after,
  body.state-ready .held-item::after {
    font-size: clamp(16px, 2.8vh, 22px) !important;
    line-height: 1.05;
    text-align: center;
  }

  body.state-title .station-foot,
  body.state-ready .station-foot {
    justify-content: center !important;
    min-height: 20px;
    margin-top: 0 !important;
  }

  body.state-title .station-status,
  body.state-ready .station-status {
    padding: 2px 8px !important;
    font-size: clamp(11px, 2vh, 14px) !important;
    line-height: 1.05;
  }

  body.state-title .player-station::after,
  body.state-ready .player-station::after {
    top: 7px;
    right: 7px;
    padding: 3px 7px;
    font-size: clamp(11px, 2vh, 14px);
    line-height: 1;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
  }

  body.state-title .callout-main,
  body.state-ready .callout-main {
    width: 96% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 4px 10px;
    font-size: clamp(20px, 3.8vh, 28px) !important;
    line-height: 1.05 !important;
  }

  /* The fixed admin control occupies the far right. Keep the in-stage gauge
     short enough to remain inside the top row and away from team B. */
  .game-root {
    --top-row: clamp(52px, 8.5vh, 64px);
  }

  body.state-playing .stage-earth-gauge,
  body.state-paused .stage-earth-gauge {
    box-sizing: border-box;
    width: clamp(70px, 8vw, 82px) !important;
    min-width: 0;
    min-height: 0;
    max-width: 82px;
    margin-right: calc(var(--admin-reserve) + 8px) !important;
    gap: 0 !important;
    border-width: 2px;
    border-radius: 15px;
    padding: 4px 6px;
    overflow: hidden;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  }

  body.state-playing .stage-earth-gauge img,
  body.state-paused .stage-earth-gauge img {
    display: none !important;
  }

  body.state-playing .stage-earth-gauge > div,
  body.state-paused .stage-earth-gauge > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  body.state-playing .stage-earth-gauge span,
  body.state-playing .stage-earth-gauge strong,
  body.state-paused .stage-earth-gauge span,
  body.state-paused .stage-earth-gauge strong {
    font-size: clamp(12px, 2vh, 15px);
    line-height: 1;
  }

  body.state-playing .stage-earth-gauge .earth-bar.mini,
  body.state-paused .stage-earth-gauge .earth-bar.mini {
    height: 7px;
    margin-top: 2px;
    border-width: 1px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-delay: 0ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

@media (min-width: 1101px) and (max-height: 800px) {
  body.state-playing .game-root,
  body.state-paused .game-root {
    --top-row: clamp(74px, 7vh, 76px);
  }
}

/* ========================================================================== */
/* 2026-09-04 revision 02: practice, turn preview, preflight, learning summary. */
/* ========================================================================== */

.stage-heading-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 0.8vmin, 10px);
  min-width: 0;
  line-height: 1;
}

.practice-badge {
  flex: 0 0 auto;
  margin: 0;
  border: 2px solid #173326;
  border-radius: 999px;
  padding: 0.2em 0.55em;
  background: #fff4a8;
  color: #173326;
  font-size: clamp(10px, 1.35vmin, 15px);
  font-style: normal;
  font-weight: 1000;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(23, 51, 38, 0.18);
  white-space: nowrap;
}

.beat-ring,
.drop-ring {
  box-sizing: border-box !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  align-content: center !important;
  justify-items: center !important;
  gap: clamp(1px, 0.35vmin, 4px) !important;
  padding: clamp(8px, 1.4vmin, 15px) !important;
  overflow: hidden !important;
  text-align: center !important;
}

.beat-ring .drop-action,
.drop-ring .drop-action {
  display: block !important;
  align-self: end !important;
  color: #173326 !important;
  font-size: clamp(12px, 1.8vmin, 20px) !important;
  font-style: normal !important;
  font-weight: 1000 !important;
  letter-spacing: 0.06em !important;
  line-height: 1 !important;
}

.beat-ring .center-item-icon,
.drop-ring .center-item-icon {
  display: grid !important;
  place-items: center !important;
  align-self: center !important;
  min-width: 0 !important;
  min-height: 0 !important;
  color: #173326 !important;
  font-size: clamp(32px, 5.2vmin, 58px) !important;
  font-style: normal !important;
  line-height: 0.95 !important;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.75));
}

.beat-ring .center-item-name,
.drop-ring .center-item-name {
  display: -webkit-box !important;
  align-self: start !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  color: #173326 !important;
  font-size: clamp(13px, 1.55vmin, 18px) !important;
  font-weight: 1000 !important;
  line-height: 1.06 !important;
  letter-spacing: -0.04em !important;
  overflow-wrap: anywhere !important;
  word-break: keep-all !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
}

.beat-ring.next-window {
  border-color: var(--focus-team-color, #ffcf33) !important;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.82),
    0 0 28px var(--focus-team-color, #ffcf33),
    inset 0 0 18px color-mix(in srgb, var(--focus-team-color, #ffcf33) 26%, transparent) !important;
}

.beat-ring.hit-window {
  border-color: #173326 !important;
  box-shadow:
    0 0 0 8px #fff,
    0 0 36px var(--focus-team-color, #ffcf33),
    inset 0 0 24px color-mix(in srgb, var(--focus-team-color, #ffcf33) 42%, transparent) !important;
}

body.state-playing .beat-ring.next-window,
body.state-paused .beat-ring.next-window {
  border-color: var(--focus-team-color, #ffcf33) !important;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.82),
    0 0 28px var(--focus-team-color, #ffcf33),
    inset 0 0 18px color-mix(in srgb, var(--focus-team-color, #ffcf33) 26%, transparent) !important;
}

body.state-playing .beat-ring.hit-window,
body.state-paused .beat-ring.hit-window {
  border-color: #173326 !important;
  box-shadow:
    0 0 0 8px #fff,
    0 0 36px var(--focus-team-color, #ffcf33),
    inset 0 0 24px color-mix(in srgb, var(--focus-team-color, #ffcf33) 42%, transparent) !important;
}

body.state-playing .beat-ring.round-complete,
body.state-paused .beat-ring.round-complete {
  border-color: #16865f !important;
  background: radial-gradient(circle, #f0fff7, #b9f6d8) !important;
  box-shadow:
    0 0 0 7px rgba(255, 255, 255, 0.86),
    0 0 28px rgba(38, 200, 139, 0.72) !important;
}

.beat-ring.round-complete .center-item-icon {
  color: #08734e !important;
}

.beat-ring.practice::after {
  content: "연습";
  position: absolute;
  top: 6px;
  right: 6px;
  border-radius: 999px;
  padding: 2px 5px;
  background: #173326;
  color: #fff;
  font-size: clamp(8px, 1vmin, 11px);
  font-weight: 1000;
  line-height: 1;
}

body.state-playing .player-station.turn-focus::before,
body.state-paused .player-station.turn-focus::before {
  content: attr(data-cue-label) !important;
}

body.state-playing .player-station.waiting-dim:not(.turn-focus),
body.state-paused .player-station.waiting-dim:not(.turn-focus) {
  opacity: 0.7;
  filter: saturate(0.72) brightness(0.98);
}

body.state-practice .score-ribbon,
body.state-practice .mini-score,
body.state-practice .combo-chip {
  opacity: 0.58;
}

#stageSummary .learning-summary p {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 0.45em !important;
  min-width: 0 !important;
}

#stageSummary .learning-summary p span {
  min-width: 0 !important;
  overflow-wrap: anywhere !important;
  word-break: keep-all !important;
}

.preflight-overlay {
  position: fixed;
  inset: 0;
  z-index: 7600;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: clamp(8px, 1.8vmin, 18px);
  overflow: hidden;
  background: rgba(9, 25, 32, 0.78);
  backdrop-filter: blur(8px);
}

.preflight-overlay.hidden {
  display: none !important;
}

.preflight-card {
  width: min(920px, calc(100vw - clamp(16px, 3.6vmin, 36px)));
  max-height: calc(100dvh - clamp(16px, 3.6vmin, 36px));
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  gap: clamp(6px, 1.1vmin, 12px);
  border: clamp(4px, 0.7vmin, 7px) solid #173326;
  border-radius: clamp(18px, 2.8vmin, 30px);
  padding: clamp(10px, 1.8vmin, 20px);
  overflow-x: hidden;
  overflow-y: auto;
  background: linear-gradient(150deg, #f9fff9, #e8fbff 58%, #fff7cb);
  box-shadow: 0 16px 0 rgba(0, 0, 0, 0.22);
  color: #173326;
}

.preflight-header,
.preflight-section-head,
.preflight-practice-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.preflight-header h2,
.preflight-students h3 {
  margin: 0;
  line-height: 1.15;
}

#stageSummary .learning-summary p {
  line-height: 1.24 !important;
}

.preflight-header h2 {
  font-size: clamp(25px, 4vmin, 38px);
}

.preflight-kicker {
  display: block;
  margin-bottom: 3px;
  color: #14725d;
  font-size: clamp(10px, 1.4vmin, 14px);
  font-weight: 1000;
}

.preflight-header button,
.preflight-actions button {
  min-height: clamp(34px, 5.2vmin, 46px);
  border: 2px solid #173326;
  border-radius: 11px;
  padding: 0.45em 0.7em;
  background: #fff;
  color: #173326;
  font: inherit;
  font-size: clamp(11px, 1.65vmin, 15px);
  font-weight: 900;
  line-height: 1.08;
}

.preflight-actions button.primary {
  background: #26c88b;
}

.preflight-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(5px, 0.9vmin, 9px);
  min-width: 0;
}

.preflight-status-card {
  min-width: 0;
  border: 2px solid #64748b;
  border-radius: 12px;
  padding: clamp(5px, 0.9vmin, 9px);
  background: #fff;
  text-align: center;
}

.preflight-status-card span,
.preflight-status-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preflight-status-card span {
  font-size: clamp(10px, 1.45vmin, 13px);
  font-weight: 800;
}

.preflight-status-card strong {
  margin-top: 2px;
  font-size: clamp(11px, 1.7vmin, 15px);
}

.preflight-status-card.ok {
  border-color: #17865f;
  background: #dcfce7;
}

.preflight-status-card.warn {
  border-color: #c77c08;
  background: #fff7d6;
}

.preflight-students {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  border: 2px solid #94a3b8;
  border-radius: 14px;
  padding: clamp(7px, 1.1vmin, 11px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
}

.preflight-students h3 {
  font-size: clamp(14px, 2.1vmin, 20px);
}

.preflight-section-head > strong {
  border-radius: 999px;
  padding: 0.2em 0.65em;
  background: #173326;
  color: #fff;
  font-size: clamp(11px, 1.65vmin, 15px);
}

.preflight-student-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(3px, 0.7vmin, 7px);
  align-content: center;
}

.student-signal {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: clamp(27px, 4.2vmin, 38px);
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--student-team-color) 72%, #173326);
  border-radius: 9px;
  background: #e2e8f0;
  color: #475569;
  font-size: clamp(11px, 1.7vmin, 16px);
  font-weight: 1000;
}

.student-signal.confirmed {
  background: var(--student-team-color);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.preflight-students p,
.preflight-summary {
  margin: 0;
  font-size: clamp(10px, 1.45vmin, 13px);
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.preflight-practice-toggle {
  justify-content: flex-start;
  gap: 9px;
  border-radius: 12px;
  padding: clamp(6px, 1vmin, 10px);
  background: #fff4a8;
}

.preflight-practice-toggle input {
  flex: 0 0 auto;
  width: clamp(19px, 2.8vmin, 26px);
  height: clamp(19px, 2.8vmin, 26px);
}

.preflight-practice-toggle span,
.preflight-practice-toggle strong,
.preflight-practice-toggle small {
  display: block;
  min-width: 0;
}

.preflight-practice-toggle strong {
  font-size: clamp(12px, 1.75vmin, 16px);
}

.preflight-practice-toggle small {
  margin-top: 2px;
  font-size: clamp(9px, 1.35vmin, 12px);
  font-weight: 750;
}

.preflight-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(5px, 0.9vmin, 9px);
  min-width: 0;
}

.preflight-summary {
  border-radius: 9px;
  padding: 5px 8px;
  background: rgba(23, 51, 38, 0.08);
}

body.preflight-open .admin-toggle {
  display: none !important;
}

@media (orientation: landscape) and (min-width: 760px) and (max-height: 650px) {
  .preflight-card {
    gap: 5px;
    padding: 9px;
    border-width: 4px;
  }

  .preflight-students {
    padding: 6px;
  }

  .preflight-header button,
  .preflight-actions button {
    min-height: 32px;
    padding-top: 0.35em;
    padding-bottom: 0.35em;
  }

  .student-signal {
    min-height: 27px;
  }

  #stageSummary .learning-summary p {
    line-height: 1.16 !important;
  }
}

/* ========================================================================== */
/* 2026-09-04 revision 04: original "Eco Candy Carnival" visual theme.        */
/* Layout metrics stay in the responsive rules above; this layer changes paint */
/* only so 800 x 600 classrooms and projector screens keep their safe fit.     */
/* ========================================================================== */

body.theme-puffy-party {
  --party-ink: #263858;
  --party-outline: #405175;
  --party-cream: #fffdf3;
  --party-sky: #a9e8ff;
  --party-mint: #bdf2d4;
  --party-lemon: #ffe477;
  --party-peach: #ffd1b7;
  --party-lilac: #d9ceff;
  --party-pink: #ff8fbd;
  --party-shadow: rgba(48, 62, 94, 0.22);
  --ink: var(--party-ink);
  --muted: #5b6882;
  --line: rgba(64, 81, 117, 0.18);
  --panel: rgba(255, 253, 243, 0.94);
  --shadow: 0 7px 0 rgba(93, 112, 151, 0.22), 0 20px 42px var(--party-shadow);
  color: var(--party-ink);
  font-family: "Arial Rounded MT Bold", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, 0.88) 0 3.2%, transparent 3.5%),
    radial-gradient(circle at 90% 17%, rgba(255, 255, 255, 0.72) 0 4.1%, transparent 4.4%),
    radial-gradient(circle at 12% 86%, rgba(255, 235, 137, 0.74) 0 5%, transparent 5.3%),
    linear-gradient(145deg, var(--party-sky), #fff1ba 49%, var(--party-lilac)) !important;
}

body.theme-puffy-party .game-viewport,
body.theme-puffy-party .game-root {
  color: var(--party-ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, 0.88) 0 3.2%, transparent 3.5%),
    radial-gradient(circle at 91% 16%, rgba(255, 255, 255, 0.7) 0 4%, transparent 4.3%),
    radial-gradient(circle at 84% 84%, rgba(255, 145, 192, 0.24) 0 7%, transparent 7.3%),
    radial-gradient(circle at 13% 86%, rgba(255, 229, 111, 0.38) 0 7.5%, transparent 7.8%),
    linear-gradient(145deg, var(--party-sky), #fff1ba 49%, var(--party-lilac)) !important;
}

body.theme-puffy-party button {
  border-color: var(--party-outline);
  color: var(--party-ink);
  background: linear-gradient(180deg, #ffffff, #f7f4ff);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.78),
    0 4px 0 rgba(64, 81, 117, 0.2);
  transition: filter 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

body.theme-puffy-party button:hover:not(:disabled) {
  filter: brightness(1.03) saturate(1.06);
}

body.theme-puffy-party button:active:not(:disabled) {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.72), 0 2px 0 rgba(64, 81, 117, 0.2);
  transform: translateY(2px);
}

body.theme-puffy-party button.primary {
  border-color: #2d6f62;
  color: #163e37;
  background: linear-gradient(180deg, #91f0c8, #57d9a6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.68),
    0 4px 0 #35a77d;
}

body.theme-puffy-party .game-header,
body.theme-puffy-party .game-stage {
  border-color: rgba(255, 255, 255, 0.96) !important;
  box-shadow:
    inset 0 0 0 2px rgba(64, 81, 117, 0.1),
    0 7px 0 rgba(93, 112, 151, 0.22),
    0 20px 38px var(--party-shadow) !important;
}

body.theme-puffy-party .game-header {
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.96), rgba(255, 253, 239, 0.91) 54%, rgba(239, 249, 255, 0.94)) !important;
}

body.theme-puffy-party .eyebrow {
  border: 2px solid var(--party-outline);
  color: var(--party-ink);
  background: linear-gradient(180deg, #fff4a9, #ffd95f);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.72), 0 4px 0 rgba(64, 81, 117, 0.18);
}

body.theme-puffy-party .brand-block h1 {
  color: #29446d;
  letter-spacing: -0.04em;
  text-shadow:
    0 3px 0 #ffffff,
    3px 5px 0 rgba(255, 143, 189, 0.28),
    -2px 5px 0 rgba(80, 196, 230, 0.22);
}

body.theme-puffy-party .brand-block p {
  color: #49617d;
}

body.theme-puffy-party .round-board > div {
  border-color: var(--party-outline);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.82),
    inset 0 -5px 0 rgba(64, 81, 117, 0.06),
    0 5px 0 rgba(64, 81, 117, 0.18);
}

body.theme-puffy-party .round-board > div:nth-child(1) {
  background: linear-gradient(155deg, #ffffff, #d7f5ff);
}

body.theme-puffy-party .round-board > div:nth-child(2) {
  background: linear-gradient(155deg, #ffffff, #ffe2ef);
}

body.theme-puffy-party .round-board > .earth-panel {
  background: linear-gradient(155deg, #ffffff, #d8f7e5);
}

body.theme-puffy-party .round-board span {
  color: #596984;
}

body.theme-puffy-party .round-board strong {
  color: #263858;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.92);
}

body.theme-puffy-party .earth-panel img,
body.theme-puffy-party .stage-earth-gauge img {
  filter: drop-shadow(0 5px 0 rgba(55, 139, 111, 0.18));
}

body.theme-puffy-party .earth-bar {
  border-color: #405175;
  background: #dfe7ef;
  box-shadow: inset 0 2px 4px rgba(38, 56, 88, 0.16), 0 2px 0 rgba(255, 255, 255, 0.75);
}

body.theme-puffy-party .earth-bar div {
  background: linear-gradient(90deg, #54d98f, #57d7cd 53%, #a0df68);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.48);
}

body.theme-puffy-party .score-ribbon {
  border: 3px solid var(--party-outline);
  color: var(--party-ink);
  background:
    linear-gradient(90deg, #dcf8e6 0 24%, #dff4ff 24% 49%, #fff1cd 49% 74%, #f0e5ff 74% 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.86), 0 5px 0 rgba(64, 81, 117, 0.2);
  text-shadow: 0 1px 0 #ffffff;
}

body.theme-puffy-party .admin-toggle {
  border-color: var(--party-outline) !important;
  color: var(--party-ink);
  background: linear-gradient(180deg, #ffffff, #eaf8ff);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    0 5px 0 rgba(64, 81, 117, 0.2),
    0 11px 22px rgba(48, 62, 94, 0.15);
}

body.theme-puffy-party .game-stage {
  background:
    radial-gradient(circle at 50% 7%, rgba(255, 252, 211, 0.84), transparent 35%),
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)),
    url("./assets/svg/stage-bg.svg") center / cover no-repeat !important;
}

body.theme-puffy-party .stage-lights {
  opacity: 0.9;
  mix-blend-mode: normal;
  background:
    radial-gradient(circle at 12% 17%, rgba(255, 255, 255, 0.82) 0 2.1%, transparent 2.4%),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.72) 0 2.8%, transparent 3.1%),
    radial-gradient(circle at 27% 13%, rgba(255, 233, 112, 0.56), transparent 18%),
    radial-gradient(circle at 75% 16%, rgba(255, 143, 189, 0.35), transparent 21%),
    repeating-linear-gradient(90deg, transparent 0 57px, rgba(255, 255, 255, 0.12) 57px 60px);
}

body.theme-puffy-party .stage-title {
  color: var(--party-ink);
  text-shadow:
    0 3px 0 #ffffff,
    2px 5px 0 rgba(112, 148, 191, 0.24);
}

body.theme-puffy-party .stage-title strong,
body.theme-puffy-party .practice-badge {
  border-color: var(--party-outline) !important;
  color: var(--party-ink);
  background: linear-gradient(180deg, #fff5a8, #ffd85d) !important;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.78),
    0 5px 0 rgba(64, 81, 117, 0.22) !important;
}

body.theme-puffy-party .round-dots,
body.theme-puffy-party .stage-earth-gauge {
  border-color: var(--party-outline);
  color: var(--party-ink);
  background: linear-gradient(180deg, #ffffff, #fffaf0);
  box-shadow: inset 0 2px 0 #ffffff, 0 5px 0 rgba(64, 81, 117, 0.2);
}

body.theme-puffy-party .round-dots span.done,
body.theme-puffy-party .round-dots span.current {
  color: #ffd54f;
  text-shadow: 0 2px 0 var(--party-outline);
}

body.theme-puffy-party .player-station,
body.theme-puffy-party.state-title .player-station,
body.theme-puffy-party.state-ready .player-station,
body.theme-puffy-party.state-playing .player-station,
body.theme-puffy-party.state-paused .player-station {
  border-color: color-mix(in srgb, var(--team-color) 70%, var(--party-outline)) !important;
  background:
    radial-gradient(circle at 22% 9%, rgba(255, 255, 255, 0.98) 0 11%, transparent 24%),
    linear-gradient(160deg, #ffffff 0 18%, color-mix(in srgb, var(--team-color) 17%, var(--party-cream)) 100%) !important;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.96),
    inset 0 -7px 0 color-mix(in srgb, var(--team-color) 14%, transparent),
    0 6px 0 color-mix(in srgb, var(--team-color) 38%, #7b88a3),
    0 13px 24px var(--party-shadow) !important;
}

body.theme-puffy-party .station-head h2,
body.theme-puffy-party .team-title,
body.theme-puffy-party .held-item b {
  color: var(--party-ink) !important;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.92);
}

body.theme-puffy-party .runner-chip,
body.theme-puffy-party .student-badge,
body.theme-puffy-party .station-status,
body.theme-puffy-party .combo-chip {
  border: 2px solid rgba(64, 81, 117, 0.4);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.62),
    0 4px 0 rgba(64, 81, 117, 0.18) !important;
}

body.theme-puffy-party .runner-chip,
body.theme-puffy-party .student-badge {
  color: #263858 !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--team-color) 64%, white), var(--team-color)) !important;
}

body.theme-puffy-party .station-status {
  color: #42526e;
  background: linear-gradient(180deg, #ffffff, #edf3f9);
}

body.theme-puffy-party .character {
  border-color: #ffffff !important;
  outline: 2px solid color-mix(in srgb, var(--team-color) 48%, var(--party-outline));
  outline-offset: -1px;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.82), transparent 24%),
    linear-gradient(160deg, color-mix(in srgb, var(--team-color) 72%, white), var(--team-color)) !important;
  box-shadow:
    inset 0 -7px 0 rgba(38, 56, 88, 0.11),
    0 6px 0 color-mix(in srgb, var(--team-color) 55%, #65728d),
    0 11px 18px rgba(38, 56, 88, 0.18) !important;
}

body.theme-puffy-party .character img,
body.theme-puffy-party .held-item span {
  filter: drop-shadow(0 5px 0 rgba(38, 56, 88, 0.13));
}

body.theme-puffy-party .beat-ticks span {
  background: #ffffff;
  box-shadow: inset 0 -3px 0 rgba(64, 81, 117, 0.09), 0 4px 0 rgba(64, 81, 117, 0.18);
}

body.theme-puffy-party .beat-ticks span:nth-child(2n) {
  background: #ffe16f;
}

body.theme-puffy-party .beat-ring,
body.theme-puffy-party .drop-ring {
  border-color: #ffffff !important;
  outline: 3px solid var(--party-outline);
  outline-offset: -3px;
  color: var(--party-ink);
  background:
    radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.98), transparent 18%),
    linear-gradient(165deg, #f8fff9, #a9eccb) !important;
  box-shadow:
    inset 0 5px 0 #ffffff,
    inset 0 -9px 0 rgba(36, 151, 105, 0.15),
    0 7px 0 #72c39e,
    0 15px 28px rgba(38, 56, 88, 0.22) !important;
}

body.theme-puffy-party .beat-ring .drop-action,
body.theme-puffy-party .beat-ring .center-item-icon,
body.theme-puffy-party .beat-ring .center-item-name {
  color: var(--party-ink) !important;
}

/* NEXT is intentionally calm: it previews the turn without revealing the exact hit. */
body.theme-puffy-party .beat-ring.next-window,
body.theme-puffy-party.state-playing .beat-ring.next-window,
body.theme-puffy-party.state-paused .beat-ring.next-window {
  border-color: #ffffff !important;
  outline-color: color-mix(in srgb, var(--focus-team-color, #ffe16f) 45%, var(--party-outline));
  box-shadow:
    inset 0 5px 0 #ffffff,
    inset 0 -9px 0 rgba(36, 151, 105, 0.15),
    0 7px 0 color-mix(in srgb, var(--focus-team-color, #72c39e) 34%, #72c39e),
    0 15px 28px rgba(38, 56, 88, 0.22) !important;
}

/* Exact-hit emphasis is allowed only when the teacher enabled answer hints. */
body.theme-puffy-party.state-hint-mode .beat-ring.hit-window {
  border-color: #ffffff !important;
  outline-color: var(--focus-team-color, #ffd95f);
  box-shadow:
    inset 0 5px 0 #ffffff,
    inset 0 -9px 0 color-mix(in srgb, var(--focus-team-color, #ffd95f) 24%, transparent),
    0 7px 0 color-mix(in srgb, var(--focus-team-color, #ffd95f) 52%, #7b88a3),
    0 0 28px var(--focus-team-color, #ffd95f) !important;
}

body.theme-puffy-party .rhythm-line,
body.theme-puffy-party .conveyor-area {
  border-color: var(--party-outline) !important;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.46) 0 28px, rgba(255, 255, 255, 0.13) 28px 56px),
    linear-gradient(180deg, #e9fbff, #b9efd7) !important;
  box-shadow:
    inset 0 5px 0 rgba(255, 255, 255, 0.84),
    inset 0 -7px 0 rgba(64, 81, 117, 0.1),
    0 6px 0 rgba(64, 81, 117, 0.22) !important;
}

body.theme-puffy-party .stage-bin {
  border-color: var(--party-outline) !important;
  background: linear-gradient(165deg, #ffffff, #fff8e5) !important;
  box-shadow:
    inset 0 3px 0 #ffffff,
    inset 0 -6px 0 rgba(38, 56, 88, 0.08),
    0 6px 0 rgba(64, 81, 117, 0.24) !important;
}

body.theme-puffy-party .stage-bin:nth-child(4n + 1) {
  background: linear-gradient(165deg, #ffffff, #e3f8ea) !important;
}

body.theme-puffy-party .stage-bin:nth-child(4n + 2) {
  background: linear-gradient(165deg, #ffffff, #e3f4ff) !important;
}

body.theme-puffy-party .stage-bin:nth-child(4n + 3) {
  background: linear-gradient(165deg, #ffffff, #fff0d4) !important;
}

body.theme-puffy-party .stage-bin:nth-child(4n) {
  background: linear-gradient(165deg, #ffffff, #f0e8ff) !important;
}

body.theme-puffy-party:not(.state-hint-mode) .stage-bin.hint-mode-bin {
  border-color: var(--party-outline) !important;
  background: linear-gradient(165deg, #ffffff, #fff8e5) !important;
  box-shadow: inset 0 3px 0 #ffffff, inset 0 -6px 0 rgba(38, 56, 88, 0.08), 0 6px 0 rgba(64, 81, 117, 0.24) !important;
}

body.theme-puffy-party .drop-marker span {
  color: #ff6ca9;
  text-shadow: 0 2px 0 #ffffff, 0 4px 0 rgba(64, 81, 117, 0.2);
}

body.theme-puffy-party .drop-marker b {
  border: 2px solid var(--party-outline);
  color: var(--party-ink);
  background: linear-gradient(180deg, #fff3a5, #ffd65a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.72), 0 3px 0 rgba(64, 81, 117, 0.2);
}

body.theme-puffy-party .big-judgement {
  color: #ffffff;
  -webkit-text-stroke: 2px var(--party-outline) !important;
  text-shadow:
    0 4px 0 var(--party-outline),
    0 8px 16px rgba(38, 56, 88, 0.32) !important;
}

body.theme-puffy-party .big-judgement.perfect,
body.theme-puffy-party .big-judgement.good {
  color: #fff178;
}

body.theme-puffy-party .big-judgement.ok {
  color: #9df0c5;
}

body.theme-puffy-party .big-judgement.miss,
body.theme-puffy-party .big-judgement.penalty {
  color: #ff9dbf;
}

body.theme-puffy-party .learning-bubble.feedback-zone,
body.theme-puffy-party .stage-callout.callout-zone,
body.theme-puffy-party .current-callout,
body.theme-puffy-party .callout-main {
  border-color: var(--party-outline) !important;
  color: var(--party-ink) !important;
  background: linear-gradient(180deg, #ffffff, var(--party-cream)) !important;
  box-shadow:
    inset 0 3px 0 #ffffff,
    0 6px 0 rgba(64, 81, 117, 0.22),
    0 13px 24px rgba(38, 56, 88, 0.13) !important;
}

body.theme-puffy-party .callout-sub {
  color: #576884;
}

body.theme-puffy-party.state-paused .game-stage {
  filter: saturate(0.7) brightness(0.97);
}

/* Paused keeps the live board visible; the lobby HUD must not fall over it. */
body.theme-puffy-party.state-paused .game-shell {
  display: block !important;
  padding: 0 !important;
}

body.theme-puffy-party.state-paused .lobby-header {
  opacity: 0 !important;
  transform: translateY(-130%) !important;
  pointer-events: none !important;
}

body.theme-puffy-party.state-paused .score-ribbon,
body.theme-puffy-party.state-paused .round-board {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.theme-puffy-party.state-paused .stage-title {
  align-self: center !important;
  justify-self: center !important;
  opacity: 1 !important;
  pointer-events: none !important;
}

body.theme-puffy-party.state-paused .stage-title span {
  font-size: 34px !important;
}

body.theme-puffy-party.state-paused .stage-title strong {
  display: none !important;
}

body.theme-puffy-party.state-paused .callout-main {
  border-color: #725fb2 !important;
  color: #3d316c !important;
  background: linear-gradient(180deg, #ffffff, #ece4ff) !important;
}

body.theme-puffy-party .overlay,
body.theme-puffy-party .preflight-overlay {
  background: rgba(35, 47, 78, 0.62);
  backdrop-filter: blur(8px) saturate(0.8);
}

body.theme-puffy-party .summary-card,
body.theme-puffy-party .result-card,
body.theme-puffy-party .preflight-card,
body.theme-puffy-party .countdown-card {
  border-color: var(--party-outline) !important;
  color: var(--party-ink);
  background: linear-gradient(155deg, #ffffff, #fff8dd 62%, #e8f8ff) !important;
  box-shadow:
    inset 0 4px 0 #ffffff,
    0 8px 0 rgba(64, 81, 117, 0.3),
    0 22px 46px rgba(38, 56, 88, 0.3) !important;
}

body.theme-puffy-party .countdown-card span {
  color: #5b6882;
}

body.theme-puffy-party .countdown-card strong {
  color: #ff6ca9;
  -webkit-text-stroke: 2px var(--party-outline);
  text-shadow: 0 5px 0 #ffffff, 0 9px 0 rgba(64, 81, 117, 0.18);
}

body.theme-puffy-party .summary-card h2,
body.theme-puffy-party .winner-line {
  color: var(--party-ink);
  text-shadow: 0 3px 0 #ffffff;
}

body.theme-puffy-party.state-summary .admin-toggle {
  top: clamp(18px, 2.6vmin, 24px) !important;
  right: calc((100vw - min(760px, 88vw)) / 2 + 12px) !important;
  min-width: 88px !important;
  min-height: 34px !important;
  padding: 0 10px !important;
  font-size: 13px !important;
  opacity: 0.72 !important;
  transform: none !important;
}

body.theme-puffy-party .summary-team,
body.theme-puffy-party .result-row {
  border-color: var(--party-outline) !important;
  color: var(--party-ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.72), 0 5px 0 rgba(64, 81, 117, 0.2) !important;
}

body.theme-puffy-party .summary-team[data-result-team="A"] {
  background: linear-gradient(90deg, #ffffff, #dcf8e6) !important;
}

body.theme-puffy-party .summary-team[data-result-team="B"] {
  background: linear-gradient(90deg, #ffffff, #dff4ff) !important;
}

body.theme-puffy-party .summary-team[data-result-team="C"] {
  background: linear-gradient(90deg, #ffffff, #fff0cf) !important;
}

body.theme-puffy-party .summary-team[data-result-team="D"] {
  background: linear-gradient(90deg, #ffffff, #efe5ff) !important;
}

body.theme-puffy-party .summary-team.winner {
  border-color: #8b6b12 !important;
  background: linear-gradient(90deg, #fffbe2, #ffe989) !important;
  box-shadow: inset 0 3px 0 #ffffff, 0 5px 0 #d2aa32, 0 0 30px rgba(255, 210, 68, 0.54) !important;
}

body.theme-puffy-party .winner-line {
  border: 3px solid var(--party-outline);
  background: linear-gradient(180deg, #fff3a1, #ffd35b) !important;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.74), 0 5px 0 rgba(64, 81, 117, 0.22);
}

body.theme-puffy-party .learning-summary {
  border-color: rgba(64, 81, 117, 0.26) !important;
  color: #405175;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(225, 248, 237, 0.86)) !important;
}

body.theme-puffy-party .admin-panel {
  border-left-color: rgba(64, 81, 117, 0.24);
  color: var(--party-ink);
  background: linear-gradient(180deg, #f5fbff, #fffaf0);
  box-shadow: -12px 0 0 rgba(64, 81, 117, 0.16), -24px 0 48px rgba(38, 56, 88, 0.22);
}

body.theme-puffy-party .admin-panel-header {
  border-bottom-color: rgba(64, 81, 117, 0.18);
  background: linear-gradient(180deg, #f5fbff, #eef8ff);
}

body.theme-puffy-party .admin-section,
body.theme-puffy-party .preflight-students {
  border-color: rgba(64, 81, 117, 0.28);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 2px 0 #ffffff, 0 4px 0 rgba(64, 81, 117, 0.1);
}

body.theme-puffy-party .admin-facts div,
body.theme-puffy-party .last-line,
body.theme-puffy-party .admin-note,
body.theme-puffy-party .preflight-summary {
  background: #eef6fa;
}

body.theme-puffy-party .preflight-status-card {
  border-color: var(--party-outline);
  color: var(--party-ink);
  background: linear-gradient(180deg, #ffffff, #eef5fa);
  box-shadow: inset 0 2px 0 #ffffff, 0 4px 0 rgba(64, 81, 117, 0.17);
}

body.theme-puffy-party .preflight-status-card.ok {
  border-color: #3a7b68;
  background: linear-gradient(180deg, #f4fff8, #cdf4df);
}

body.theme-puffy-party .preflight-status-card.warn {
  border-color: #a67622;
  background: linear-gradient(180deg, #fffdf0, #ffedb3);
}

body.theme-puffy-party .preflight-practice-toggle {
  border: 2px solid #9a7b2a;
  color: #4b3c1d;
  background: linear-gradient(180deg, #fff9c4, #ffe781);
  box-shadow: inset 0 2px 0 #ffffff, 0 4px 0 rgba(64, 81, 117, 0.16);
}

body.theme-puffy-party .student-signal {
  border-color: color-mix(in srgb, var(--student-team-color) 64%, var(--party-outline));
  color: #5c6b83;
  background: linear-gradient(180deg, #f7f9fc, #e1e7ef);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8), 0 3px 0 rgba(64, 81, 117, 0.16);
}

body.theme-puffy-party .student-signal.confirmed {
  color: #263858;
  background: linear-gradient(180deg, color-mix(in srgb, var(--student-team-color) 64%, white), var(--student-team-color));
}

@media (max-height: 760px) {
  body.theme-puffy-party.state-summary .admin-toggle {
    right: calc((100vw - min(740px, 86vw)) / 2 + 10px) !important;
  }
}

@media (orientation: portrait), (max-width: 760px) {
  body.theme-puffy-party .screen-notice > div {
    border-color: var(--party-outline);
    color: var(--party-ink);
    background: linear-gradient(155deg, #ffffff, #fff6d5 58%, #e7f7ff);
    box-shadow: inset 0 3px 0 #ffffff, 0 7px 0 rgba(64, 81, 117, 0.25), 0 20px 36px rgba(38, 56, 88, 0.24);
  }
}
