:root {
  --cr-bg: #0d1538;
  --cr-surface: rgba(255, 255, 255, 0.95);
  --cr-surface-dark: rgba(18, 28, 70, 0.85);
  --cr-primary: #3b66ff;
  --cr-primary-grad: linear-gradient(135deg, #3b66ff, #7454f5);
  --cr-accent-yellow: #ffb800;
  --cr-accent-pink: #ff4785;
  --cr-accent-green: #00d27a;
  --cr-accent-cyan: #00c6ff;
  --cr-text: #13254a;
  --cr-text-light: #ffffff;
  --cr-muted: #7184a8;
  --cr-radius: 24px;
  --cr-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: hidden;
  max-width: 100%;
}
body.classroom-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  background: radial-gradient(circle at 50% 20%, #1a2868 0%, #0c1334 100%);
  color: var(--cr-text-light);
  font-size: 16px;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* Ambient Particles */
.cr-ambient {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.cr-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
}
.cr-orb-1 { width: 350px; height: 350px; top: -100px; left: 10%; background: #6147ff; }
.cr-orb-2 { width: 400px; height: 400px; bottom: -100px; right: 5%; background: #00b4d8; }

/* Main Classroom Shell */
.cr-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px 24px;
  max-width: 1440px;
  margin: 0 auto;
}

/* Classroom Top Bar */
.cr-header {
  position: relative;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  background: var(--cr-header-bg, rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.cr-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.cr-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}
.cr-brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.cr-brand div {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.cr-brand strong {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #6fe1ff, #bd78ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cr-brand span {
  font-size: 13px;
  color: #a6b8db;
  font-weight: 700;
}

/* Nav Tabs */
.cr-tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.28);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  scrollbar-width: none;
  width: 100%;
}
.cr-tabs::-webkit-scrollbar {
  display: none;
}
.cr-tab-btn {
  border: 0;
  background: transparent;
  color: #b3c5e8;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.cr-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.cr-tab-btn.is-active {
  background: var(--cr-primary-grad);
  color: #fff;
  box-shadow: 0 6px 20px rgba(59, 102, 255, 0.35);
}
.tab-badge {
  font-size: 9px;
  font-weight: 900;
  background: linear-gradient(135deg, #ff3b68, #ff6a3d);
  color: white;
  padding: 1px 5px;
  border-radius: 6px;
  letter-spacing: .02em;
  line-height: 1.2;
}

/* Top Action Buttons */
.cr-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cr-icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
}
.cr-icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}
.cr-icon-btn.primary {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  border-color: transparent;
}

/* Content Panels */
.cr-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  padding-bottom: 56px;
}
.cr-panel {
  display: none;
  flex: 1;
  animation: panelFade 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cr-panel.is-active {
  display: flex;
  flex-direction: column;
}
@keyframes panelFade {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   1. 🎡 LUCKY WHEEL (วงล้อสุ่มเกม)
   ============================================================ */
.wheel-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: center;
  flex: 1;
}
.wheel-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.wheel-container {
  position: relative;
  width: min(480px, 76vw, calc(100vh - 280px));
  max-width: 480px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.wheel-pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 36px;
  height: 48px;
  background: #ff2a5f;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 6px 12px rgba(255, 42, 95, 0.5));
}
.wheel-pointer::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}
#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.12), 0 0 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.05s ease-out;
}
.wheel-center-btn {
  position: absolute;
  z-index: 8;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  color: #fff;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: 0.03em;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(255, 75, 43, 0.5), inset 0 2px 6px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.wheel-center-btn:hover {
  transform: scale(1.08);
  filter: brightness(1.1);
}
.wheel-center-btn:active {
  transform: scale(0.94);
}
.wheel-center-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Wheel Side Controls */
.wheel-sidebar {
  background: var(--cr-surface);
  color: var(--cr-text);
  padding: 24px;
  border-radius: var(--cr-radius);
  box-shadow: var(--cr-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.wheel-sidebar h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  color: #17284f;
}
.wheel-sidebar p {
  margin: 2px 0 0;
  color: var(--cr-muted);
  font-size: 13.5px;
}
.wheel-filters {
  display: grid;
  gap: 10px;
}
.wheel-filters label {
  font-size: 13px;
  font-weight: 800;
  color: #4b5d7d;
}
.wheel-filters select {
  height: 44px;
  border: 1px solid #dce4f3;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 14.5px;
  color: #1a2c4e;
  background: #f8faff;
  outline: 0;
}
.wheel-game-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}
.wheel-game-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #f3f6fc;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  color: #273859;
}
.wheel-game-item small {
  color: #7b8ea8;
}
.wheel-spin-large-btn {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  color: #fff;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 75, 43, 0.35);
  transition: transform 0.16s ease, filter 0.16s ease;
}
.wheel-spin-large-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.wheel-spin-large-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   2. 🎲 LUCKY NUMBER PICKER (สุ่มเลขที่ / ตัวเลข)
   ============================================================ */
.number-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  flex: 1;
  align-items: stretch;
}
.number-stage {
  background: radial-gradient(circle at 50% 30%, #1e295d 0%, #0a1028 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--cr-radius);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   KAWAII GACHAPON CAPSULE MACHINE
   ============================================================ */
.gacha-machine {
  width: min(390px, 94vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45));
}

/* 1. Gacha Roof with Cute Bear/Cat Ears & Marquee */
.gacha-roof {
  width: 100%;
  height: 64px;
  background: linear-gradient(180deg, #ff7597 0%, #ff4770 100%);
  border-radius: 28px 28px 12px 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.6), 0 8px 20px rgba(255, 71, 112, 0.35);
  border: 3px solid #ffffff;
  border-bottom: 0;
  z-index: 5;
}
.gacha-ear {
  position: absolute;
  top: -18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ff4770;
  border: 3px solid #ffffff;
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.5);
}
.gacha-ear::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffaec0;
}
.gacha-ear.left { left: 24px; }
.gacha-ear.right { right: 24px; }

.gacha-header-sign {
  background: #ffffff;
  padding: 4px 18px;
  border-radius: 20px;
  font-size: 14.5px;
  font-weight: 950;
  color: #ff3366;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.gacha-sparkle {
  animation: sparkleTwinkle 1.4s infinite alternate;
}
@keyframes sparkleTwinkle {
  0% { transform: scale(0.8) rotate(0deg); opacity: 0.7; }
  100% { transform: scale(1.2) rotate(15deg); opacity: 1; }
}

.gacha-bulbs {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}
.gacha-bulbs span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 0 8px #ffd166;
  animation: bulbBlink 1s infinite alternate;
}
.gacha-bulbs span:nth-child(even) {
  animation-delay: 0.5s;
  background: #06d6a0;
  box-shadow: 0 0 8px #06d6a0;
}
@keyframes bulbBlink {
  0% { opacity: 0.4; }
  100% { opacity: 1; transform: scale(1.15); }
}

/* 2. Transparent 3D Glass Dome */
.gacha-dome-wrap {
  width: 94%;
  height: 250px;
  border-radius: 36px 36px 20px 20px;
  background: radial-gradient(circle at 40% 30%, rgba(255, 255, 255, 0.28) 0%, rgba(147, 197, 253, 0.15) 50%, rgba(30, 58, 138, 0.35) 100%);
  border: 4px solid rgba(255, 255, 255, 0.45);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 14px 28px rgba(255, 255, 255, 0.55), inset 0 -14px 28px rgba(0, 0, 0, 0.3), 0 12px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
#gachaCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.gacha-glass-shine {
  position: absolute;
  top: 12px;
  left: 20px;
  width: 100px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
  transform: rotate(-25deg);
  pointer-events: none;
}

/* Center Number Display inside Dome */
.gacha-center-number {
  position: relative;
  z-index: 3;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #ffffff;
  border: 5px solid #ff4770;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 -6px 14px rgba(0, 0, 0, 0.15), 0 0 25px rgba(255, 71, 112, 0.5);
}
.number-display {
  font-size: 64px;
  font-weight: 950;
  color: #12285a;
  letter-spacing: -0.04em;
  line-height: 1;
  transition: transform 0.1s ease;
}
.number-display.is-rolling {
  animation: rollBounce 0.08s infinite alternate;
  color: #ff3366;
}
@keyframes rollBounce {
  0% { transform: translateY(-5px) scale(0.95); opacity: 0.85; }
  100% { transform: translateY(5px) scale(1.05); opacity: 1; }
}
.number-display.is-winner {
  animation: winnerPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  color: #059669;
}
@keyframes winnerPop {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); opacity: 1; }
}

/* 3. Machine Base (Crank & Prize Dispenser) */
.gacha-base {
  width: 100%;
  min-height: 135px;
  background: linear-gradient(180deg, #ff4770 0%, #e11d48 100%);
  border-radius: 16px 16px 36px 36px;
  border: 3px solid #ffffff;
  border-top: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), inset 0 4px 8px rgba(255, 255, 255, 0.4);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 5;
}
.gacha-front-panel {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

/* Coin Slot */
.gacha-coin-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.18);
  padding: 6px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
}
.coin-icon { font-size: 20px; }
.coin-label {
  font-size: 11px;
  font-weight: 900;
  color: #ffd166;
  letter-spacing: 0.05em;
}

/* Golden Rotating Crank */
.gacha-crank-wrap {
  width: 58px;
  height: 58px;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.crank-dial {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffbeb 0%, #ffd166 60%, #b45309 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}
.crank-wing {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 12px;
  background: linear-gradient(180deg, #fde047, #ca8a04);
  border-radius: 6px;
  border: 2px solid #ffffff;
  transform: translateY(-50%);
}
.crank-wing.left { left: -14px; }
.crank-wing.right { right: -14px; }
.crank-center-gem {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: #ff4770;
  display: grid;
  place-items: center;
  color: #ffd166;
  font-size: 13px;
  font-weight: 900;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.gacha-crank-wrap.is-cranking {
  animation: crankSpin 0.4s linear infinite;
}
@keyframes crankSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Prize Dispenser Chute */
.gacha-chute {
  background: #111827;
  height: 48px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 8px 16px rgba(0, 0, 0, 0.6);
}
.chute-flap {
  font-size: 12px;
  font-weight: 900;
  color: #94a3b8;
  letter-spacing: 0.06em;
}
.chute-ball {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8da6 0%, #ff4770 60%, #9f1239 100%);
  border: 2px solid #ffffff;
  display: none;
  animation: chuteDrop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes chuteDrop {
  0% { transform: translateY(-40px) scale(0.5); opacity: 0; }
  60% { transform: translateY(0) scale(1.15); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 4. Juicy Candy Action Button */
.number-actions {
  display: flex;
  justify-content: center;
}
.gacha-spin-btn {
  min-height: 56px;
  padding: 0 42px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff4785 0%, #ff6b9d 100%);
  color: #ffffff;
  font-size: 20px;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 71, 133, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: all 0.16s ease;
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.gacha-spin-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 34px rgba(255, 71, 133, 0.55);
}
.gacha-spin-btn:active {
  transform: scale(0.96);
}
.gacha-spin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Number Config Sidebar */
.number-sidebar {
  background: var(--cr-surface);
  color: var(--cr-text);
  padding: 24px;
  border-radius: var(--cr-radius);
  box-shadow: var(--cr-shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.number-config-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  min-width: 0;
}
.number-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.number-field label {
  font-size: 13px;
  font-weight: 800;
  color: #4b5d7d;
}
.number-field input,
.number-field select,
.number-field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #dce4f3;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: #1a2c4e;
  background: #f8faff;
  outline: 0;
  box-sizing: border-box;
  font-family: inherit;
}
.number-field textarea {
  height: auto;
  min-height: 70px;
  padding: 10px 12px;
  resize: vertical;
}

/* Mode Switch: Repeat vs No-Repeat */
.repeat-switch {
  display: flex;
  background: #eef3fc;
  padding: 5px;
  border-radius: 14px;
  gap: 6px;
}
.repeat-switch button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #5d6f8f;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 850;
  cursor: pointer;
  transition: all 0.16s ease;
}
.repeat-switch button.is-active {
  background: #fff;
  color: #274ea5;
  box-shadow: 0 3px 10px rgba(39, 78, 165, 0.15);
}

/* History Chips */
.number-history-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.number-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #5d6f8f;
}
.number-chips-wrap {
  flex: 1;
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  background: #f4f7fd;
  border: 1px solid #e1e8f5;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
}
.num-chip {
  background: #fff;
  color: #1f3560;
  border: 1px solid #ccd8ed;
  font-size: 14px;
  font-weight: 850;
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  animation: popChip 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes popChip {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ============================================================
   3. ⏱️ ACTIVITY TIMER (นาฬิกานับถอยหลัง)
   ============================================================ */
.timer-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  flex: 1;
  padding: 24px;
}

.timer-dial-wrap {
  position: relative;
  width: min(440px, 84vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.timer-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 12;
}
.timer-progress {
  fill: none;
  stroke: #00d27a;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear, stroke 0.3s ease;
}
.timer-progress.warning { stroke: #ffb800; }
.timer-progress.danger { stroke: #ff4785; }

.timer-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.timer-digits {
  font-size: clamp(64px, 12vw, 98px);
  font-weight: 950;
  font-family: monospace, system-ui;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 30px rgba(0, 210, 122, 0.4);
}
.timer-digits.danger {
  color: #ff4785;
  text-shadow: 0 0 35px rgba(255, 71, 133, 0.6);
  animation: pulseDanger 1s infinite alternate;
}
@keyframes pulseDanger {
  0% { transform: scale(1); }
  100% { transform: scale(1.04); }
}
.timer-label {
  font-size: 15px;
  font-weight: 800;
  color: #a3b8de;
  letter-spacing: 0.05em;
}

/* Timer Quick Presets */
.timer-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.timer-preset-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  transition: all 0.16s ease;
}
.timer-preset-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}
.timer-preset-btn.is-active {
  background: #00d27a;
  border-color: #00d27a;
  color: #0c1a2e;
  box-shadow: 0 6px 18px rgba(0, 210, 122, 0.35);
}

/* Timer Controls */
.timer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}
.timer-btn {
  min-height: 54px;
  padding: 0 32px;
  border-radius: 16px;
  border: 0;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.16s ease;
}
.timer-btn.start {
  background: linear-gradient(135deg, #00d27a, #00b064);
  color: #091a13;
  box-shadow: 0 8px 24px rgba(0, 210, 122, 0.35);
}
.timer-btn.pause {
  background: linear-gradient(135deg, #ffb800, #f59e0b);
  color: #2b1800;
  box-shadow: 0 8px 24px rgba(255, 184, 0, 0.35);
}
.timer-btn.reset {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.timer-btn:hover {
  transform: translateY(-2px);
}
.timer-btn:active {
  transform: scale(0.96);
}

/* ============================================================
   4. 🏁 GRAND RACING ARENA (วิ่งแข่งสุ่มเลขที่ & ผู้ชนะ)
   ============================================================ */
.race-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  flex: 1;
  align-items: stretch;
}
.race-stage {
  background: #081028;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--cr-radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.race-ticker {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 850;
  color: #f1f5f9;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}
.race-ticker-live {
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 950;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  animation: pulseLive 1.2s infinite alternate;
}
@keyframes pulseLive {
  0% { opacity: 0.8; transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1.04); }
}
.race-ticker-msg {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e2e8f0;
}
.race-ticker-msg.highlight {
  color: #ffb800;
  text-shadow: 0 0 10px rgba(255, 184, 0, 0.4);
}
.race-canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 480px;
  border-radius: 18px;
  overflow: hidden;
  background: #0d1738;
}
#raceCanvas {
  width: 100%;
  height: 100%;
  display: block;
}
.race-countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 38, 0.6);
  backdrop-filter: blur(4px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.race-countdown-overlay.is-active {
  opacity: 1;
}
.race-countdown-text {
  font-size: clamp(80px, 15vw, 140px);
  font-weight: 950;
  color: #ffb800;
  text-shadow: 0 0 40px rgba(255, 184, 0, 0.8);
  animation: countdownPop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
}
@keyframes countdownPop {
  0% { transform: scale(0.4); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Race Sidebar Controls */
.race-sidebar {
  background: var(--cr-surface);
  color: var(--cr-text);
  padding: 24px;
  border-radius: var(--cr-radius);
  box-shadow: var(--cr-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}
.race-sidebar h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  color: #17284f;
}
.race-sidebar p {
  margin: 2px 0 0;
  color: var(--cr-muted);
  font-size: 13.5px;
}

/* Theme Picker Grid */
.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.theme-btn {
  border: 1px solid #dce4f3;
  background: #f8faff;
  color: #3b4e72;
  padding: 10px 8px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 850;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.16s ease;
}
.theme-btn span { font-size: 22px; }
.theme-btn:hover {
  background: #eef4fe;
  border-color: #b0c7fa;
}
.theme-btn.is-active {
  background: #e8efff;
  border-color: #3b66ff;
  color: #204db8;
  box-shadow: 0 4px 12px rgba(59, 102, 255, 0.2);
}

.race-start-btn {
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #00d27a, #00b064);
  color: #071f14;
  font-size: 19px;
  font-weight: 950;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 210, 122, 0.35);
  transition: all 0.16s ease;
}
.race-start-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.race-start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Podium Winner Results */
.race-podium {
  background: #f4f8fe;
  border: 1px solid #d8e4f8;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.podium-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 850;
  font-size: 14px;
}
.podium-item.p1 { background: #fff8e1; color: #b78103; border: 1px solid #ffe082; }
.podium-item.p2 { background: #f5f5f5; color: #616161; border: 1px solid #e0e0e0; }
.podium-item.p3 { background: #fbe9e7; color: #bf360c; border: 1px solid #ffccbc; }

/* ============================================================
   Winner Dialog Modal & Close Button
   ============================================================ */
.cr-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: 28px;
  background: #ffffff;
  color: var(--cr-text);
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
  overflow: visible;
  position: relative;
  z-index: 99999;
}
.cr-dialog::backdrop {
  background: rgba(6, 12, 34, 0.8);
  backdrop-filter: blur(10px);
}
.cr-dialog-x {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #e2e8f5;
  background: #f4f7fc;
  color: #5d6f8f;
  font-size: 18px;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.18s ease;
  z-index: 10;
}
.cr-dialog-x:hover {
  background: #ffebf0;
  color: #ff2a5f;
  border-color: #ffd2dc;
  transform: scale(1.1);
}
.cr-dialog-body {
  padding: 38px 32px 34px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cr-dialog-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fdf2e9;
  font-size: 42px;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.25);
  animation: bounceWinner 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes bounceWinner {
  0% { transform: scale(0) rotate(-45deg); }
  70% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.cr-dialog-title {
  margin: 0;
  font-size: 25px;
  font-weight: 950;
  color: #12244a;
  line-height: 1.3;
}
.cr-dialog-desc {
  margin: 0;
  font-size: 15px;
  color: #556684;
  line-height: 1.6;
}
.cr-dialog-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}
.cr-dialog-actions button, .cr-dialog-actions a {
  flex: 1;
  min-height: 50px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 850;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
}
.cr-btn-play {
  background: var(--cr-primary-grad);
  color: #fff;
  border: 0;
  box-shadow: 0 6px 20px rgba(59, 102, 255, 0.35);
}
.cr-btn-play:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 102, 255, 0.45);
}
.cr-btn-close {
  background: #f0f4fb;
  color: #435474;
  border: 1px solid #dce4f3;
}
.cr-btn-close:hover {
  background: #e5ebf7;
  color: #1d2d4d;
}

/* Confetti Canvas */
#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99998;
}

/* ============================================================
   RESPONSIVE DESIGN (Smartboard 4K, Desktop, Tablet, Mobile)
   ============================================================ */

/* --- 1. Large Displays (Smartboard 4K, Projectors >= 1600px) --- */
@media (min-width: 1600px) {
  .cr-shell {
    max-width: 1800px;
    padding: 24px 36px;
  }
  .cr-tab-btn {
    font-size: 17px;
    padding: 12px 24px;
  }
  .wheel-container {
    width: 600px;
  }
  .wheel-center-btn {
    width: 110px;
    height: 110px;
    font-size: 22px;
  }
  .gacha-machine {
    width: 440px;
  }
  .gacha-dome-wrap {
    height: 290px;
  }
  .gacha-center-number {
    width: 160px;
    height: 160px;
  }
  .number-display {
    font-size: 76px;
  }
  .race-canvas-wrap {
    min-height: 560px;
  }
  .timer-clock-wrap {
    width: 380px;
    height: 380px;
  }
}

/* --- 2. Medium Tablets & Laptops (961px - 1200px) --- */
@media (max-width: 1200px) {
  .wheel-layout, .number-layout, .race-layout {
    grid-template-columns: 1fr 340px;
    gap: 18px;
  }
  .cr-tab-btn {
    padding: 8px 14px;
    font-size: 14px;
  }
}

/* --- 3. Tablets & Small Screens (<= 960px) --- */
@media (max-width: 960px) {
  .cr-shell {
    padding: 14px 16px;
  }
  .wheel-layout, .number-layout, .race-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .cr-header {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }
  .cr-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    justify-content: flex-start;
    scrollbar-width: none;
    padding: 4px;
  }
  .cr-tabs::-webkit-scrollbar {
    display: none;
  }
  .cr-tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 14px;
    padding: 8px 14px;
  }
  .cr-actions {
    margin-left: auto;
  }
  .wheel-sidebar, .number-sidebar, .race-sidebar {
    max-height: none;
  }
}

/* --- 4. Mobile Devices (<= 640px) --- */
@media (max-width: 640px) {
  .cr-shell {
    padding: 10px 10px;
  }
  .cr-header {
    padding: 10px 12px;
    border-radius: 16px;
  }
  .cr-brand img {
    width: 36px;
    height: 36px;
  }
  .cr-brand strong {
    font-size: 15px;
  }
  .cr-brand span {
    font-size: 11px;
  }

  /* Compact actions on mobile */
  .cr-actions {
    gap: 6px;
  }
  .cr-icon-btn {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
  }
  .cr-icon-btn .action-label {
    display: none;
  }

  /* Lucky Wheel on mobile */
  .wheel-stage {
    padding: 16px 8px;
  }
  .wheel-container {
    width: min(340px, 88vw);
  }
  .wheel-center-btn {
    width: 76px;
    height: 76px;
    font-size: 16px;
  }

  /* Gachapon Machine on mobile */
  .number-stage {
    padding: 20px 10px;
  }
  .gacha-machine {
    width: 100%;
    max-width: 340px;
  }
  .gacha-roof {
    height: 56px;
  }
  .gacha-header-sign {
    font-size: 12.5px;
    padding: 3px 12px;
  }
  .gacha-dome-wrap {
    height: 210px;
  }
  .gacha-center-number {
    width: 110px;
    height: 110px;
    border-width: 4px;
  }
  .number-display {
    font-size: 50px;
  }
  .gacha-spin-btn {
    width: 100%;
    min-height: 50px;
    font-size: 17px;
    padding: 0 16px;
  }

  /* Grand Racing Arena on mobile */
  .race-stage {
    padding: 12px 10px;
  }
  .race-ticker {
    padding: 6px 10px;
    font-size: 12px;
  }
  .race-canvas-wrap {
    min-height: 360px;
  }
  .theme-picker-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .theme-btn {
    padding: 8px 4px;
    font-size: 12px;
  }
  .race-start-btn {
    min-height: 48px;
    font-size: 17px;
  }

  /* Activity Timer on mobile */
  .timer-stage {
    padding: 24px 12px;
  }
  .timer-clock-wrap {
    width: min(280px, 78vw);
    height: min(280px, 78vw);
  }
  .timer-digits {
    font-size: clamp(48px, 15vw, 68px);
  }
  .timer-presets {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .timer-preset-btn {
    padding: 8px 6px;
    font-size: 12.5px;
  }
  .timer-controls {
    flex-direction: column;
    width: 100%;
  }
  .timer-btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 16px;
  }

  /* Dialog on mobile */
  .cr-dialog {
    width: min(360px, 94vw);
    border-radius: 22px;
  }
  .cr-dialog-body {
    padding: 26px 18px 22px;
  }
  .cr-dialog-title {
    font-size: 20px;
  }
  .cr-dialog-desc {
    font-size: 13.5px;
  }
  .cr-dialog-actions {
    flex-direction: column;
  }
  .cr-btn-play, .cr-btn-close {
    width: 100%;
    min-height: 46px;
    font-size: 15px;
  }
}

/* ============================================ */
/* Credit Footer                                */
/* ============================================ */
.cr-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 20px;
  background: rgba(8, 14, 44, 0.72);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12.5px;
  color: rgba(180, 200, 235, 0.72);
  font-weight: 600;
  letter-spacing: 0.01em;
  flex-wrap: wrap;
}
.cr-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: rgba(200, 220, 255, 0.9);
  transition: color 0.18s ease;
}
.cr-footer-brand:hover {
  color: #fff;
}
.cr-footer-brand img {
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  opacity: 0.88;
}
.cr-footer-brand strong {
  color: #88c0ff;
  font-weight: 900;
  letter-spacing: 0.03em;
}
.cr-footer-brand:hover strong {
  color: #aad4ff;
}
.cr-footer-dot {
  opacity: 0.38;
  font-size: 14px;
}
.cr-footer-copy, .cr-footer-year {
  opacity: 0.55;
}

/* ============================================ */
/* THEME SYSTEM                                  */
/* ============================================ */
body[data-theme="space"] {
  --cr-bg-a: #1a2868;
  --cr-bg-b: #0c1334;
  --cr-orb1-color: #6147ff;
  --cr-orb2-color: #00b4d8;
  --cr-header-bg: rgba(255,255,255,0.08);
  --cr-surface-new: rgba(18,28,70,0.9);
  --cr-tab-new-color: #7a9fff;
}
body[data-theme="forest"] {
  --cr-bg-a: #0d3320;
  --cr-bg-b: #061a10;
  --cr-orb1-color: #1a7a3c;
  --cr-orb2-color: #4caf50;
  --cr-header-bg: rgba(255,255,255,0.09);
  --cr-surface-new: rgba(10,30,18,0.9);
  --cr-tab-new-color: #7edd9f;
}
body[data-theme="sunset"] {
  --cr-bg-a: #4a1825;
  --cr-bg-b: #1e0a12;
  --cr-orb1-color: #ff4500;
  --cr-orb2-color: #ff8c00;
  --cr-header-bg: rgba(255,255,255,0.09);
  --cr-surface-new: rgba(40,12,18,0.9);
  --cr-tab-new-color: #ffb347;
}
body[data-theme="ocean"] {
  --cr-bg-a: #0a2040;
  --cr-bg-b: #040e20;
  --cr-orb1-color: #0077b6;
  --cr-orb2-color: #00b4d8;
  --cr-header-bg: rgba(255,255,255,0.08);
  --cr-surface-new: rgba(5,15,35,0.9);
  --cr-tab-new-color: #56d8f5;
}

body.classroom-body {
  background: radial-gradient(circle at 50% 20%, var(--cr-bg-a, #1a2868) 0%, var(--cr-bg-b, #0c1334) 100%);
}
.cr-orb-1 { background: var(--cr-orb1-color, #6147ff); }
.cr-orb-2 { background: var(--cr-orb2-color, #00b4d8); }
.cr-header { background: var(--cr-header-bg, rgba(255,255,255,0.08)); }

/* ============================================ */
/* THEME SWITCHER UI                            */
/* ============================================ */
.cr-theme-wrap {
  position: relative;
  z-index: 1000;
}
.cr-theme-picker {
  display: none !important;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(12, 18, 50, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  z-index: 1001;
  backdrop-filter: blur(24px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.1);
  animation: pickerFade .15s ease both;
}
.cr-theme-picker.is-open {
  display: flex !important;
}
@keyframes pickerFade {
  from { opacity:0; transform:translateY(-6px); }
  to { opacity:1; transform:translateY(0); }
}
.cr-theme-opt {
  border: 0;
  background: transparent;
  color: #b3c5e8;
  padding: 9px 14px;
  border-radius: 9px;
  text-align: left;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  transition: background .15s ease;
}
.cr-theme-opt:hover { background: rgba(255,255,255,0.12); color: #fff; }
.cr-theme-opt.is-active { background: linear-gradient(135deg,#3b66ff,#7454f5); color: #fff; }

/* ============================================ */
/* 5. 🎰 SLOT MACHINE                           */
/* ============================================ */
.slot-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: center;
  flex: 1;
}
.slot-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px;
}
.slot-machine {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 28px;
  padding: 36px 40px;
  text-align: center;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.slot-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}
.slot-reels-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.slot-reel-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.slot-reel {
  width: 110px;
  height: 110px;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 4px 20px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
}
.slot-answer-reel { background: rgba(99,190,50,0.15); border-color: rgba(99,190,50,0.4); }
.reel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 42px;
  font-weight: 900;
  color: #fff;
  width: 100%;
  transition: none;
}
.reel-inner.spinning {
  animation: reelSpin .08s linear infinite;
}
@keyframes reelSpin {
  0% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}
.slot-reel-label { font-size: 12px; color: #7fa0c8; font-weight: 700; }
.slot-op-wrap { display: flex; align-items: center; padding-bottom: 24px; }
.slot-op {
  font-size: 40px;
  font-weight: 900;
  color: #ffb800;
  width: 56px;
  text-align: center;
  text-shadow: 0 0 20px rgba(255,184,0,0.5);
}
.slot-eq {
  font-size: 40px;
  font-weight: 900;
  color: rgba(255,255,255,0.5);
  padding: 0 8px;
  padding-bottom: 24px;
}
.slot-actions-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.slot-spin-btn {
  padding: 16px 36px;
  font-size: 18px;
  font-weight: 900;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff6a00, #ee0979);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255,106,0,0.4);
  transition: transform .15s, box-shadow .15s;
  letter-spacing: 0.03em;
}
.slot-spin-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(255,106,0,0.5); }
.slot-spin-btn:active { transform: translateY(0); }
.slot-spin-btn:disabled { opacity: 0.5; transform: none; cursor: not-allowed; }

.slot-reveal-btn {
  padding: 16px 36px;
  font-size: 18px;
  font-weight: 900;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #00d27a, #00a854);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,210,122,0.4);
  transition: transform .15s, box-shadow .15s;
  letter-spacing: 0.03em;
}
.slot-reveal-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,210,122,0.5); }
.slot-reveal-btn:active { transform: translateY(0); }
.slot-reveal-btn:disabled { opacity: 0.35; transform: none; cursor: not-allowed; }

.slot-timer-wrap {
  width: 100%;
  max-width: 440px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot-timer-track {
  height: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  overflow: hidden;
}
.slot-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffb800, #ff4785);
  border-radius: 4px;
  transition: width 0.1s linear;
}
.slot-timer-label {
  font-size: 13px;
  color: #a6c0e8;
  font-weight: 700;
  text-align: center;
}

.slot-result-msg {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #7fe87f;
  min-height: 24px;
  animation: fadeIn .3s ease;
  text-align: center;
}
.slot-sidebar { display: flex; flex-direction: column; gap: 14px; }
@keyframes fadeIn { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform: none; } }

/* ============================================ */
/* 6. 👥 TEAM BUILDER                           */
/* ============================================ */
.teams-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  flex: 1;
}
.teams-stage { display: flex; flex-direction: column; flex: 1; gap: 16px; }
.teams-result-wrap {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 300px;
}
.teams-placeholder { text-align: center; color: #5d7fa8; }
.teams-placeholder span { font-size: 52px; display: block; margin-bottom: 12px; }
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  width: 100%;
}
.team-card {
  background: linear-gradient(135deg, var(--tc, #3b66ff), rgba(0,0,0,0.2));
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.15);
  animation: teamCardIn .35s cubic-bezier(.34,1.56,.64,1) both;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
@keyframes teamCardIn {
  from { opacity: 0; transform: scale(0.7) rotate(-5deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
.team-card-title {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.team-card-members {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.team-member-chip {
  background: rgba(255,255,255,0.2);
  color: #fff;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}
.teams-actions { display: flex; gap: 10px; }
.teams-go-btn {
  flex: 1;
  padding: 18px;
  font-size: 17px;
  font-weight: 900;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg,#3b66ff,#7454f5);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(59,102,255,0.4);
  transition: transform .15s;
}
.teams-go-btn:hover { transform: translateY(-2px); }
.teams-sidebar { display: flex; flex-direction: column; gap: 14px; }

/* ============================================ */
/* 7. ⚡ FLASH CARD                              */
/* ============================================ */
.flash-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  flex: 1;
}
.flash-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
}
.flash-card-display {
  width: 100%;
  max-width: 560px;
  perspective: 1000px;
}
.flash-card {
  background: linear-gradient(135deg, rgba(59,102,255,0.18), rgba(116,84,245,0.22));
  border: 2px solid rgba(255,255,255,0.16);
  border-radius: 28px;
  padding: 50px 40px;
  text-align: center;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  position: relative;
  transition: transform .4s ease;
}
.flash-card.flipped { transform: rotateY(180deg); }
.flash-card-number {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  font-weight: 800;
}
.flash-question {
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,0.3);
  letter-spacing: -0.02em;
}
.flash-answer-label {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.flash-answer {
  font-size: 56px;
  font-weight: 900;
  color: #7fe87f;
  text-shadow: 0 0 30px rgba(127,232,127,0.5);
}
.flash-timer-bar-wrap {
  width: 100%;
  max-width: 560px;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  overflow: hidden;
}
.flash-timer-bar {
  height: 100%;
  background: linear-gradient(90deg,#00d27a,#3b66ff);
  border-radius: 3px;
  transition: width .1s linear, background .5s ease;
  width: 100%;
}
.flash-progress {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255,255,255,0.5);
}
.flash-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.flash-btn {
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 850;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.flash-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.flash-btn.start { background: linear-gradient(135deg,#00d27a,#00b050); color: #fff; box-shadow: 0 4px 14px rgba(0,210,122,0.4); }
.flash-btn.reveal { background: linear-gradient(135deg,#ffb800,#ff7700); color: #fff; box-shadow: 0 4px 14px rgba(255,184,0,0.4); }
.flash-btn.next { background: linear-gradient(135deg,#3b66ff,#7454f5); color: #fff; box-shadow: 0 4px 14px rgba(59,102,255,0.4); }
.flash-btn.reset { background: rgba(255,255,255,0.12); color: #b3c5e8; border: 1px solid rgba(255,255,255,0.15); }
.flash-btn:hover:not(:disabled) { transform: translateY(-2px); }
.flash-sidebar { display: flex; flex-direction: column; gap: 14px; }

/* ============================================ */
/* 8. 🎯 QUICK QUIZ                             */
/* ============================================ */
.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  flex: 1;
}
.quiz-stage { display: flex; flex-direction: column; flex: 1; gap: 14px; }
.quiz-display {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 300px;
}
.quiz-display-placeholder { text-align: center; color: #5d7fa8; }
.quiz-display-placeholder span { font-size: 52px; display: block; margin-bottom: 12px; }
.quiz-active { width: 100%; }
.quiz-q-text {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.3;
  white-space: pre-wrap;
}
.quiz-opts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.quiz-opt {
  background: rgba(59,102,255,0.15);
  border: 2px solid rgba(59,102,255,0.3);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: default;
  transition: all .2s ease;
}
.quiz-opt.correct { background: rgba(0,210,122,0.2); border-color: #00d27a; }
.quiz-opt.wrong { background: rgba(255,60,75,0.15); border-color: #ff3c4b; opacity: 0.6; }
.quiz-opt-key {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(59,102,255,0.5);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quiz-opt.correct .quiz-opt-key { background: #00d27a; }
.quiz-opt.wrong .quiz-opt-key { background: #ff3c4b; }
.quiz-opt-text { font-size: 20px; font-weight: 800; color: #fff; }
.quiz-stage-btns { display: flex; gap: 10px; }
.quiz-action-btn {
  flex: 1;
  padding: 15px;
  font-size: 16px;
  font-weight: 900;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  transition: all .15s;
}
.quiz-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.quiz-action-btn.show { background: linear-gradient(135deg,#3b66ff,#7454f5); color: #fff; box-shadow: 0 4px 14px rgba(59,102,255,.4); }
.quiz-action-btn.reveal { background: linear-gradient(135deg,#00d27a,#00b050); color: #fff; box-shadow: 0 4px 14px rgba(0,210,122,.4); }
.quiz-action-btn.reset { background: rgba(255,255,255,0.1); color: #b3c5e8; border: 1px solid rgba(255,255,255,0.15); }
.quiz-action-btn:hover:not(:disabled) { transform: translateY(-2px); }
.quiz-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  box-sizing: border-box;
}
.quiz-choices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.quiz-choices-grid .number-field {
  min-width: 0;
  width: 100%;
}
.quiz-choices-grid input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ============================================ */
/* 9. 🏆 SCOREBOARD                             */
/* ============================================ */
.score-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  flex: 1;
}
.score-stage { display: flex; flex-direction: column; flex: 1; }
.score-display {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  min-height: 300px;
}
.score-placeholder { text-align: center; color: #5d7fa8; }
.score-placeholder span { font-size: 52px; display: block; margin-bottom: 12px; }
.score-bars-wrap { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.score-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 14px;
}
.score-bar-rank {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  text-align: center;
}
.score-bar-name {
  font-size: 18px;
  font-weight: 850;
  color: rgba(255,255,255,0.9);
  margin-bottom: 4px;
}
.score-bar-track {
  height: 28px;
  background: rgba(255,255,255,0.1);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
.score-bar-fill {
  height: 100%;
  border-radius: 14px;
  background: var(--sc, #3b66ff);
  transition: width 0.5s cubic-bezier(.22,1,.36,1);
  min-width: 4px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.score-val {
  font-size: 22px;
  font-weight: 900;
  color: rgba(255,255,255,0.9);
  min-width: 60px;
  text-align: right;
}
.score-btns-row { display: flex; gap: 6px; margin-top: 6px; justify-content: center; flex-wrap: wrap; }
.score-adj-btn {
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 850;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: all .12s;
}
.score-adj-btn.plus { background: linear-gradient(135deg,#00d27a,#00b050); color: #fff; }
.score-adj-btn.minus { background: rgba(255,60,75,0.22); color: #ff7a85; border: 1px solid rgba(255,60,75,0.3); }
.score-adj-btn:hover { transform: scale(1.08); }
.score-team-names { display: flex; flex-direction: column; gap: 8px; }
.score-sidebar { display: flex; flex-direction: column; gap: 14px; }

/* ============================================ */
/* 10. 🔊 NOISE METER                           */
/* ============================================ */
.noise-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  flex: 1;
}
.noise-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex: 1;
}
.noise-gauge-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#noiseCanvas { display: block; max-width: 100%; }
.noise-db-display {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
#noiseDbVal {
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.noise-db-display small { font-size: 18px; color: rgba(255,255,255,0.5); font-weight: 700; }
.noise-level-label {
  font-size: 20px;
  font-weight: 850;
  color: rgba(255,255,255,0.7);
  text-align: center;
  min-height: 28px;
}
.noise-challenge-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 18px;
  width: 100%;
  max-width: 500px;
  font-size: 14px;
  font-weight: 750;
  color: #b3c5e8;
}
.noise-challenge-track {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
}
.noise-challenge-fill {
  height: 100%;
  background: linear-gradient(90deg,#00d27a,#00c6ff);
  border-radius: 6px;
  transition: width .5s ease;
  width: 0%;
}
/* ============================================ */
/* COMMON SIDEBAR STYLES (shared across tools)  */
/* ============================================ */
.slot-sidebar,
.teams-sidebar,
.flash-sidebar,
.quiz-sidebar,
.score-sidebar,
.noise-sidebar {
  background: var(--cr-surface);
  color: var(--cr-text);
  padding: 24px;
  border-radius: var(--cr-radius);
  box-shadow: var(--cr-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.slot-sidebar h3,
.teams-sidebar h3,
.flash-sidebar h3,
.quiz-sidebar h3,
.score-sidebar h3,
.noise-sidebar h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  color: #17284f;
}

.slot-sidebar p,
.teams-sidebar p,
.flash-sidebar p,
.quiz-sidebar p,
.score-sidebar p,
.noise-sidebar p {
  margin: 2px 0 0;
  color: var(--cr-muted);
  font-size: 13.5px;
}

/* ============================================ */
/* RESPONSIVE — Full Multi-Breakpoint System    */
/* ============================================ */

/* ── 1. Laptops & Medium Desktops (961px - 1200px) ── */
@media (max-width: 1200px) {
  .cr-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .cr-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding: 4px;
  }
  .cr-tabs::-webkit-scrollbar { display: none; }
  .cr-tab-btn {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .slot-layout, .teams-layout, .flash-layout,
  .quiz-layout, .score-layout, .noise-layout {
    grid-template-columns: 1fr 300px;
    gap: 18px;
  }
}

/* ── 2. Tablets & Small Screens (<= 960px) ── */
@media (max-width: 960px) {
  .cr-shell {
    padding: 12px 14px;
  }
  .cr-main {
    padding-bottom: 50px;
  }
  .cr-header {
    border-radius: 16px;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .cr-actions .action-label {
    display: none;
  }
  .cr-icon-btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  /* Stack layouts */
  .slot-layout, .teams-layout, .flash-layout,
  .quiz-layout, .score-layout, .noise-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    width: 100%;
  }

  /* Sidebars on top on mobile */
  .slot-sidebar, .teams-sidebar, .flash-sidebar,
  .quiz-sidebar, .score-sidebar, .noise-sidebar {
    order: -1;
    padding: 18px 20px;
    border-radius: 18px;
    width: 100%;
  }

  /* Slot Machine */
  .slot-machine {
    padding: 24px 16px;
    border-radius: 20px;
  }
  .slot-title { font-size: 18px; margin-bottom: 18px; }
  .slot-reels-row { gap: 6px; margin-bottom: 20px; }
  .slot-reel { width: 72px; height: 72px; border-radius: 14px; }
  .reel-inner { font-size: 28px; }
  .slot-op { font-size: 26px; width: 36px; }
  .slot-eq { font-size: 26px; }
  .slot-spin-btn { padding: 14px 32px; font-size: 17px; }
  .slot-result-msg { font-size: 15px; }

  /* Team Builder */
  .teams-result-wrap { min-height: 200px; padding: 14px; }
  .teams-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .teams-go-btn { padding: 14px; font-size: 15px; }

  /* Flash Card */
  .flash-card { padding: 36px 20px; min-height: 180px; }
  .flash-question { font-size: 32px; }
  .flash-answer { font-size: 38px; }
  .flash-btn { padding: 10px 14px; font-size: 13.5px; }
  .flash-card-display { max-width: 100%; }
  .flash-timer-bar-wrap { max-width: 100%; }

  /* Quick Quiz */
  .quiz-display { min-height: 220px; padding: 16px; }
  .quiz-q-text { font-size: 22px; margin-bottom: 16px; }
  .quiz-opts-grid { grid-template-columns: 1fr; gap: 8px; }
  .quiz-opt { padding: 14px 16px; gap: 10px; }
  .quiz-opt-text { font-size: 17px; }
  .quiz-stage-btns { flex-wrap: wrap; gap: 8px; }
  .quiz-action-btn { padding: 12px; font-size: 14px; min-width: calc(50% - 4px); }

  /* Scoreboard */
  .score-display { min-height: 200px; padding: 16px; }
  .score-bar-row { grid-template-columns: 50px 1fr auto; gap: 8px; }
  .score-bar-rank { font-size: 20px; }
  .score-bar-name { font-size: 15px; }
  .score-bar-track { height: 22px; }
  .score-val { font-size: 18px; min-width: 44px; }
  .score-adj-btn { padding: 6px 9px; font-size: 12.5px; }

  /* Noise Meter */
  #noiseCanvas { width: 320px; height: 190px; }
  #noiseDbVal { font-size: 44px; }
  .noise-db-display small { font-size: 14px; }
  .noise-level-label { font-size: 16px; }
  .noise-challenge-bar { padding: 10px 14px; font-size: 12.5px; }

  /* Credit Footer */
  .cr-footer { font-size: 11px; padding: 6px 12px; gap: 6px; }
  .cr-footer-dot:last-of-type,
  .cr-footer-copy { display: none; }
}

/* ── 3. Mobile Devices (<= 640px) ── */
@media (max-width: 640px) {
  .cr-shell { padding: 10px 10px; }
  .cr-brand strong { font-size: 14px; }
  .cr-brand span { font-size: 11px; }
  .cr-brand img { width: 34px; height: 34px; }
  .cr-tab-btn { padding: 6px 10px; font-size: 12px; }
  .cr-icon-btn { padding: 7px 9px; font-size: 12px; }

  /* Slot small */
  .slot-reel { width: min(68px, 18vw); height: min(68px, 18vw); border-radius: 12px; }
  .reel-inner { font-size: clamp(20px, 5vw, 26px); }
  .slot-op { font-size: 22px; width: 28px; }
  .slot-eq { font-size: 22px; }
  .slot-spin-btn { padding: 12px 24px; font-size: 15px; width: 100%; }

  /* Flash Card small */
  .flash-question { font-size: 26px; }
  .flash-answer { font-size: 32px; }
  .flash-card { padding: 28px 16px; min-height: 150px; }
  .flash-controls { gap: 6px; }
  .flash-btn { padding: 9px 12px; font-size: 12.5px; }

  /* Quiz small */
  .quiz-q-text { font-size: 18px; }
  .quiz-opt-key { width: 30px; height: 30px; font-size: 16px; }
  .quiz-opt-text { font-size: 15px; }

  /* Score small */
  .score-bar-row { grid-template-columns: 36px 1fr auto; }
  .score-bar-rank { font-size: 16px; }
  .score-btns-row { gap: 4px; }
  .score-adj-btn { padding: 5px 8px; font-size: 12px; }

  /* Noise small */
  #noiseCanvas { width: 260px; height: 155px; }
  #noiseDbVal { font-size: 36px; }
  .noise-db-display { bottom: 28px; }

  /* Teams small */
  .teams-grid { grid-template-columns: 1fr 1fr; }
}

/* ── 4. Tiny Screen Phones (<= 380px) ── */
@media (max-width: 380px) {
  .cr-shell { padding: 6px 8px; }
  .slot-reels-row { gap: 4px; }
  .slot-reel { width: 54px; height: 54px; }
  .reel-inner { font-size: 20px; }
  .slot-op, .slot-eq { font-size: 18px; }
  .flash-question { font-size: 22px; }
  .quiz-q-text { font-size: 16px; }
  .quiz-action-btn { min-width: 100%; }
}

/* ── 5. Landscape phone (short height) ── */
@media (max-height: 600px) and (orientation: landscape) {
  .cr-main { padding-bottom: 36px; }
  .cr-shell { padding: 8px 14px; }
  .flash-card { min-height: 120px; padding: 20px 24px; }
  .quiz-display { min-height: 160px; }
  .score-display { min-height: 160px; }
}

/* ── 6. Extra Large Widescreen (>= 1440px) ── */
@media (min-width: 1440px) {
  .cr-shell { max-width: 1520px; }
  .slot-layout { grid-template-columns: 1fr 380px; }
  .teams-layout { grid-template-columns: 1fr 360px; }
  .flash-layout { grid-template-columns: 1fr 340px; }
  .quiz-layout { grid-template-columns: 1fr 340px; }
  .score-layout { grid-template-columns: 1fr 340px; }
  .noise-layout { grid-template-columns: 1fr 340px; }
  .slot-reel { width: 120px; height: 120px; }
  .reel-inner { font-size: 48px; }
  .flash-question { font-size: 52px; }
  .quiz-q-text { font-size: 34px; }
}
