/* =============================================================
   Dragon Duel — Dark volcanic theme
   ============================================================= */

:root {
  --gold:       #FFD700;
  --gold-dim:   #b8970a;
  --hp-green:   #2ecc40;
  --hp-yellow:  #ffd166;
  --hp-red:     #ef233c;
  --dark-bg:    #0a0010;
  --panel-bg:   rgba(8, 4, 20, 0.88);
  --text:       #ffffff;
  --text-dim:   #cccccc;
  --ck-cyan:    #00E5FF;
  --ck-purple:  #9C6FFF;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at center, #1a0500 0%, #0a0010 60%, #000 100%);
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  font-family: 'Segoe UI', 'Trebuchet MS', Arial, sans-serif;
  color: var(--text);
  user-select: none;
}

/* ── App container ─────────────────────────────────────────── */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Arena canvas ──────────────────────────────────────────── */
#arena-canvas {
  display: block;
  width: 100vw;
  /* Leave exactly enough room for the compact question panel */
  height: calc(100vh - 162px);
  height: calc(100dvh - 162px);
  flex-shrink: 0;
}

/* ── HUD (HP bars + round info) ────────────────────────────── */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 20px 0;
  z-index: 10;
}

.hp-bar-wrap {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 280px;
}

.hp-bar-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  padding: 0 2px;
}

.player-side .hp-bar-label { text-align: left; }
.enemy-side  .hp-bar-label { text-align: right; }

.hp-bar-track {
  position: relative;
  height: 28px;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 14px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2ecc40, #27ae60);
  border-radius: 12px;
  transition: width 0.35s ease, background 0.4s ease;
}

.hp-bar-num {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  white-space: nowrap;
}

@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-5px); }
  40%  { transform: translateX(5px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}
.hp-bar-wrap.shake { animation: shake 0.4s ease-in-out; }

@keyframes low-hp-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(239,35,60,0.5); }
  50%       { box-shadow: 0 0 18px rgba(239,35,60,0.9); }
}
.hp-bar-wrap.low-hp-pulse .hp-bar-track { animation: low-hp-pulse 0.7s infinite; }

/* Round info centre */
#round-info {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 4px;
  pointer-events: auto;
}

#round-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Streak indicator */
#streak-display {
  display: none;
  font-size: 1.1rem;
  font-weight: 900;
  color: #FF6B35;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255,107,53,0.9);
  animation: streak-pop 0.3s ease-out;
}

@keyframes streak-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1.0); opacity: 1; }
}

#mute-btn {
  font-size: 1.1rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
  color: #fff;
  pointer-events: auto;
}
#mute-btn:hover { transform: scale(1.12); background: rgba(255,255,255,0.22); }

/* ── CKSTEM Logo (DOM) ─────────────────────────────────────── */
.ckstem-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(255,215,0,0.6))
          drop-shadow(0 0 24px rgba(255,160,0,0.3));
  animation: logo-glow 2.4s ease-in-out infinite;
}

@keyframes logo-glow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(255,215,0,0.6)) drop-shadow(0 0 24px rgba(255,160,0,0.3)) brightness(1.0); }
  50%      { filter: drop-shadow(0 0 18px rgba(255,215,0,0.9)) drop-shadow(0 0 36px rgba(255,160,0,0.5)) brightness(1.15); }
}

.win-screen .ckstem-logo  { width: 64px; height: 64px; }
.lose-screen .ckstem-logo { width: 64px; height: 64px; }

/* ── Question panel ────────────────────────────────────────── */
#question-panel {
  position: relative;
  width: min(740px, 96vw);
  flex-shrink: 0;
  background: var(--panel-bg);
  border: 2px solid var(--gold);
  border-radius: 14px;
  /* Compact padding — leaves room so nothing is cut at bottom */
  padding: 7px 14px 8px;
  z-index: 10;
  margin-top: 4px;
  box-shadow: 0 0 30px rgba(255,215,0,0.25), 0 4px 20px rgba(0,0,0,0.6);
}

/* Timer bar */
#timer-bar-wrap {
  width: 100%;
  height: 7px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 7px;
}
#timer-bar-inner {
  height: 100%;
  width: 100%;
  background: #06d6a0;
  border-radius: 4px;
  transition: width 0.1s linear, background 0.4s ease;
}
@keyframes timer-urgent-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
#timer-bar-wrap.urgent #timer-bar-inner { animation: timer-urgent-pulse 0.4s infinite; }

/* Question expression */
#question-expr {
  font-size: 2.2rem;
  font-weight: 900;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  text-align: center;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-shadow: 0 0 18px rgba(255,215,0,0.4), 0 2px 8px rgba(0,0,0,0.6);
}

/* ── "Get Ready" countdown overlay ────────────────────────── */
#ready-overlay {
  display: none;
  position: absolute;
  /* Covers the answer-buttons row */
  bottom: 8px;
  left: 14px;
  right: 14px;
  height: 66px;
  background: rgba(0, 0, 0, 0.78);
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--ck-cyan);
  text-shadow: 0 0 20px rgba(0,229,255,0.9), 0 0 40px rgba(0,229,255,0.5);
  z-index: 5;
  border: 2px solid rgba(0,229,255,0.35);
  animation: ready-appear 0.2s ease-out;
}
@keyframes ready-appear {
  0%   { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1.0);  opacity: 1; }
}
.ready-fade {
  animation: ready-fade-out 0.4s ease-out forwards !important;
}
@keyframes ready-fade-out {
  0%   { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Answer buttons grid */
#answer-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@keyframes btn-idle-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(255,215,0,0.15); }
  50%       { box-shadow: 0 0 14px rgba(255,215,0,0.30); }
}

.answer-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px 8px;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,215,0,0.45);
  border-radius: 11px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  min-height: 66px;
  animation: btn-idle-glow 2.4s ease-in-out infinite;
}
.answer-btn:hover {
  transform: scale(1.07) translateY(-2px);
  box-shadow: 0 0 22px rgba(255,215,0,0.65), 0 4px 12px rgba(0,0,0,0.5);
  background: rgba(255,215,0,0.14);
  border-color: var(--gold);
  animation: none;
}
.answer-btn:active { transform: scale(0.97); }

/* Disabled state during "Get Ready" countdown */
.answer-btn.btn-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
  animation: none;
}

.key-badge {
  position: absolute;
  top: 5px; left: 7px;
  background: rgba(255,215,0,0.8);
  color: #1a0a00;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
  font-family: 'Courier New', monospace;
}

.btn-value {
  font-size: 1.55rem;
  font-weight: 900;
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 0.02em;
}

/* Correct / wrong flash */
@keyframes correct-flash {
  0%   { background: rgba(46,204,64,0.3); }
  30%  { background: rgba(46,204,64,0.55); box-shadow: 0 0 22px rgba(46,204,64,0.7); border-color: #2ecc40; }
  100% { background: rgba(255,255,255,0.07); box-shadow: none; }
}
.answer-btn.correct {
  animation: correct-flash 1.0s ease-out forwards;
  border-color: #2ecc40 !important;
}

@keyframes wrong-flash {
  0%   { background: rgba(239,35,60,0.3); }
  30%  { background: rgba(239,35,60,0.55); box-shadow: 0 0 20px rgba(239,35,60,0.7); border-color: #ef233c; transform: translateX(-4px); }
  50%  { transform: translateX(4px); }
  70%  { transform: translateX(-3px); }
  100% { background: rgba(255,255,255,0.07); transform: translateX(0); }
}
.answer-btn.wrong {
  animation: wrong-flash 1.0s ease-out forwards;
  border-color: #ef233c !important;
}

@keyframes reveal-correct {
  0%   { background: rgba(255,215,0,0.1); }
  40%  { background: rgba(255,215,0,0.35); border-color: var(--gold); box-shadow: 0 0 16px rgba(255,215,0,0.5); }
  100% { background: rgba(255,255,255,0.07); }
}
.answer-btn.reveal-correct { animation: reveal-correct 1.0s ease-out forwards; }

/* ── Solution button (small pill after wrong answer) ────────── */
#solution-overlay {
  display: none;
  z-index: 55;
}
#solution-overlay.sol-button-mode {
  position: fixed;
  bottom: 168px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sol-appear 0.35s ease-out;
}
#solution-overlay.sol-modal-mode {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  animation: sol-fade 0.25s ease-out;
}
@keyframes sol-appear {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes sol-fade {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
.sol-btn {
  font-size: 1rem;
  font-weight: 800;
  font-family: inherit;
  color: #06d6a0;
  background: rgba(6, 214, 160, 0.10);
  border: 2px solid rgba(6, 214, 160, 0.45);
  border-radius: 20px;
  padding: 6px 20px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, box-shadow 0.15s;
  letter-spacing: 0.04em;
}
.sol-btn:hover {
  transform: scale(1.06);
  background: rgba(6, 214, 160, 0.22);
  box-shadow: 0 0 14px rgba(6, 214, 160, 0.4);
}
.sol-btn:active { transform: scale(0.96); }
.sol-key {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.55;
}

/* ── Solution modal ─────────────────────────────────────────── */
.sol-modal {
  background: linear-gradient(160deg, #0d0025, #1a0030 60%, #0a001a);
  border: 2px solid rgba(6, 214, 160, 0.5);
  border-radius: 18px;
  padding: 24px 28px;
  max-width: min(520px, 90vw);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 0 40px rgba(6, 214, 160, 0.2);
}
.sol-modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #06d6a0;
  letter-spacing: 0.06em;
}
.sol-modal-expr {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: 'Courier New', Courier, monospace;
  color: #ffd166;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px 20px;
  border-radius: 10px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}
.sol-modal-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.sol-modal-step {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 14px;
  border-radius: 8px;
  border-left: 3px solid rgba(6, 214, 160, 0.5);
}
.sol-dismiss {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #06d6a0, #06a67a);
  border: none;
  border-radius: 20px;
  padding: 10px 28px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
  letter-spacing: 0.04em;
}
.sol-dismiss:hover {
  transform: scale(1.04);
  box-shadow: 0 0 18px rgba(6, 214, 160, 0.5);
}
.sol-dismiss:active { transform: scale(0.96); }

/* ── Screen overlay (title / level / win / lose) ──────────── */
#screen-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

/* Win/lose result screens: transparent overlay so canvas fireworks show through */
#screen-overlay.overlay-result {
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: none;
}

/* ── Title screen ─────────────────────────────────────────── */
.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 60px;
  background: linear-gradient(160deg, #0d0025 0%, #200012 60%, #1a0500 100%);
  border: 3px solid var(--gold);
  border-radius: 22px;
  box-shadow: 0 0 60px rgba(255,215,0,0.35), 0 0 120px rgba(255,60,0,0.2);
  text-align: center;
}

.title-fire {
  font-size: 3.4rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #ff6200, #ffb400, #ffe000, #ffb400, #ff6200);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fire-gradient 2s linear infinite;
  text-shadow: none;
}

@keyframes fire-gradient {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.title-subtitle {
  font-size: 1.15rem;
  color: #e0d0a0;
  font-weight: 500;
}

.start-btn {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 14px 48px;
  border-radius: 9999px;
  border: 3px solid var(--gold);
  background: linear-gradient(135deg, #ff6200, #cc3a00);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 20px rgba(255,100,0,0.5);
}
.start-btn:hover { transform: scale(1.07); box-shadow: 0 0 35px rgba(255,150,0,0.7); }
.start-btn:active { transform: scale(0.97); }

.title-hint {
  font-size: 0.88rem;
  color: #998870;
  letter-spacing: 0.05em;
}

/* ── Level select screen ──────────────────────────────────── */
.level-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 36px;
  background: linear-gradient(160deg, #0d0025 0%, #1a0030 60%, #1a0500 100%);
  border: 3px solid var(--gold);
  border-radius: 22px;
  box-shadow: 0 0 60px rgba(255,215,0,0.3);
  text-align: center;
}

.level-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.level-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.level-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,215,0,0.4);
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  width: 138px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  font-family: inherit;
}
.level-btn:hover {
  transform: scale(1.06) translateY(-4px);
  box-shadow: 0 10px 28px rgba(255,215,0,0.4);
  background: rgba(255,215,0,0.10);
  border-color: var(--gold);
}
.level-btn:active { transform: scale(0.97) translateY(0); }

.level-num {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(255,215,0,0.7);
}
.level-icon { font-size: 2.4rem; }
.level-name {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--gold);
}
.level-desc {
  font-size: 0.76rem;
  color: #aaa;
  line-height: 1.4;
}

/* ── Completed level badge ────────────────────────────────── */
.level-btn.level-cleared {
  box-shadow: 0 0 14px rgba(255,215,0,0.25);
}
.cleared-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 1.3rem;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid var(--gold);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes badge-pop {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ── Timer mode selector ─────────────────────────────────── */
.timer-section {
  display: flex;
  align-items: center;
  gap: 12px;
}
.timer-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.timer-buttons {
  display: flex;
  gap: 8px;
}
.timer-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, color 0.15s;
}
.timer-btn:hover {
  transform: scale(1.06);
  border-color: rgba(255,215,0,0.5);
  color: #fff;
  background: rgba(255,215,0,0.08);
}
.timer-btn.timer-active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255,215,0,0.12);
  box-shadow: 0 0 12px rgba(255,215,0,0.25);
}
.timer-icon { font-size: 1rem; }
.timer-sec {
  font-size: 0.72rem;
  opacity: 0.6;
}

/* Level card color tints: 1=green, 2=teal, 3=orange, 4=magenta, 5=red */
#level-btn-1 { border-color: rgba(46,204,64,0.45); }
#level-btn-1:hover { border-color: #2ecc40; box-shadow: 0 10px 28px rgba(46,204,64,0.35); }
#level-btn-2 { border-color: rgba(6,214,160,0.45); }
#level-btn-2:hover { border-color: #06d6a0; box-shadow: 0 10px 28px rgba(6,214,160,0.35); }
#level-btn-3 { border-color: rgba(255,166,0,0.45); }
#level-btn-3:hover { border-color: #ffa600; box-shadow: 0 10px 28px rgba(255,166,0,0.35); }
#level-btn-4 { border-color: rgba(156,111,255,0.45); }
#level-btn-4:hover { border-color: #9C6FFF; box-shadow: 0 10px 28px rgba(156,111,255,0.35); }
#level-btn-5 { border-color: rgba(239,35,60,0.45); }
#level-btn-5:hover { border-color: #ef233c; box-shadow: 0 10px 28px rgba(239,35,60,0.35); }

/* ── End screens (win / lose) ────────────────────────────── */
.end-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 36px 56px;
  border: 3px solid var(--gold);
  border-radius: 22px;
  text-align: center;
  animation: end-screen-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes end-screen-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1.0); opacity: 1; }
}

.win-screen {
  background: linear-gradient(160deg, #001a0a 0%, #003a14 60%, #001805 100%);
  box-shadow: 0 0 80px rgba(46,204,64,0.5), 0 0 160px rgba(46,204,64,0.2);
}
.lose-screen {
  background: linear-gradient(160deg, #1a0000 0%, #3a0000 60%, #1a0000 100%);
  box-shadow: 0 0 80px rgba(239,35,60,0.5), 0 0 160px rgba(239,35,60,0.2);
}

@keyframes victory-pulse {
  0%, 100% { text-shadow: 0 0 20px rgba(46,204,64,0.8), 0 0 40px rgba(46,204,64,0.4); }
  50%       { text-shadow: 0 0 40px rgba(46,204,64,1.0), 0 0 80px rgba(46,204,64,0.6); }
}
@keyframes defeat-throb {
  0%, 100% { text-shadow: 0 0 20px rgba(239,35,60,0.8); }
  50%       { text-shadow: 0 0 40px rgba(239,35,60,1.0), 0 0 60px rgba(239,35,60,0.5); }
}

.end-title {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}
.win-screen  .end-title { color: #2ecc40; animation: victory-pulse 1.2s ease-in-out infinite; }
.lose-screen .end-title { color: #ef233c; animation: defeat-throb 1.0s ease-in-out infinite; }

.end-trophy, .end-skull { font-size: 3.6rem; }
.end-msg { font-size: 1.05rem; color: #ccc; font-style: italic; }

.end-level-badge {
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  font-weight: 700;
  background: rgba(255,215,0,0.08);
  padding: 4px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,215,0,0.3);
}

.end-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 1.05rem;
  color: #ddd;
  background: rgba(0,0,0,0.3);
  padding: 12px 22px;
  border-radius: 12px;
  width: 100%;
}
.end-stats div b { color: #fff; }

.play-again-btn {
  font-size: 1.35rem;
  font-weight: 900;
  padding: 11px 38px;
  border-radius: 9999px;
  border: 3px solid var(--gold);
  background: linear-gradient(135deg, #ff6200, #cc3a00);
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 18px rgba(255,100,0,0.4);
  margin-top: 4px;
}
.play-again-btn:hover  { transform: scale(1.07); box-shadow: 0 0 30px rgba(255,150,0,0.7); }
.play-again-btn:active { transform: scale(0.97); }

/* ── Responsive scaling for smaller windows ──────────────── */
@media (max-width: 920px) {
  #arena-canvas {
    width: 100vw;
    height: calc(100vh - 162px);
    height: calc(100dvh - 162px);
  }
  #question-panel {
    width: calc(100vw - 24px);
  }
  #screen-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 8px 0;
  }
  .title-screen, .level-screen, .win-screen, .lose-screen {
    max-width: 88vw;
    box-sizing: border-box;
  }
  .level-screen {
    padding: 14px 10px;
    gap: 10px;
  }
  .level-title { font-size: 1.3rem; }
  .level-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  .level-btn {
    width: 100%;
    flex-direction: row;
    gap: 8px;
    text-align: left;
    padding: 8px 10px;
    box-sizing: border-box;
  }
  .level-num { font-size: 0.65rem; min-width: 38px; }
  .level-icon { font-size: 1.4rem; flex-shrink: 0; }
  .level-name { font-size: 0.82rem; min-width: 0; }
  .level-desc { font-size: 0.68rem; min-width: 0; flex: 1; }
  .timer-section { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .timer-title { width: 100%; text-align: center; font-size: 0.72rem; }
  .timer-btn { padding: 3px 8px; font-size: 0.72rem; }
  .ckstem-logo { width: 48px !important; height: 48px !important; }
}
