/* ==========================================================================
   ROCK-STAR MULTIPLICATION THEME (CSS)
   Commercial grade responsive neon arcade UI for Mobile, Tablet & Desktop
   ========================================================================== */

:root {
  --bg-dark: #0a0c16;
  --bg-card: #131728;
  --bg-card-hover: #1c223b;
  --border-color: #262d4a;
  
  --neon-pink: #ff007f;
  --neon-cyan: #00f0ff;
  --neon-green: #00ff88;
  --neon-yellow: #ffd000;
  --neon-purple: #9d4edd;
  --neon-orange: #ff5400;
  --neon-red: #ff2a5f;
  --neon-diamond: #b9f2ff;

  --text-primary: #ffffff;
  --text-secondary: #9aa7c7;
  --text-dim: #606d8d;

  --font-main: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 9999px;

  --shadow-neon-pink: 0 0 24px rgba(255, 0, 127, 0.45);
  --shadow-neon-cyan: 0 0 24px rgba(0, 240, 255, 0.4);
  --shadow-neon-green: 0 0 24px rgba(0, 255, 136, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

html, body {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 20% 15%, rgba(255, 0, 127, 0.14) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 240, 255, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(157, 78, 221, 0.1) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 860px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

@media (min-width: 600px) {
  .app-container {
    padding: 16px;
  }
}

/* Screen Management */
.screen {
  display: none !important;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.22s ease forwards;
}

.screen.active {
  display: flex !important;
}

#screen-game {
  height: 100%;
  min-height: calc(100dvh - 24px);
  max-height: calc(100dvh - 24px);
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(6px, 1.4vh, 12px);
  box-sizing: border-box;
}

@media (min-width: 600px) {
  #screen-game {
    min-height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
    gap: 12px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PWA Install Banner */
.pwa-banner {
  display: none;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(255, 0, 127, 0.25));
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pwa-banner.active {
  display: flex;
}

.pwa-banner-btn {
  background: var(--neon-cyan);
  color: #080a14;
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

/* PWA Install Banner (Setup Screen Only) */
.pwa-banner {
  display: none;
}

.pwa-banner.active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(16, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--neon-cyan);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  margin-bottom: 10px;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.35);
  animation: slideDownFade 0.3s ease-out;
  flex-shrink: 0;
}

.pwa-banner-btn {
  background: linear-gradient(135deg, var(--neon-cyan), #00a8ff);
  color: #030816;
  border: none;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.pwa-banner-btn:active {
  transform: scale(0.95);
}

.pwa-banner-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.pwa-banner-close:hover {
  color: #fff;
  background: rgba(255, 42, 95, 0.3);
  border-color: var(--neon-red);
}

/* STRICTLY HIDE PWA BANNER & TOP NAV ON GAMEPLAY, DUEL, RESULTS */
body:has(#screen-game.active) #pwa-install-banner,
body:has(#screen-duel[style*="display: flex"]) #pwa-install-banner,
body:has(#screen-results.active) #pwa-install-banner,
body:has(#screen-game.active) .top-nav,
body:has(#screen-duel[style*="display: flex"]) .top-nav,
body:has(#screen-results.active) .top-nav {
  display: none !important;
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Top Nav */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 6px 10px;
  background: rgba(19, 23, 40, 0.82);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  gap: 8px;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  max-width: 65%;
  overflow: hidden;
}

.profile-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--neon-cyan);
}

.avatar-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-neon-pink);
}

.player-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.player-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-coins {
  font-size: 0.72rem;
  color: var(--neon-yellow);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cloud-status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--neon-green);
  transition: all 0.25s ease;
  user-select: none;
}

.cloud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
  display: inline-block;
}

.cloud-status-pill.syncing {
  background: rgba(255, 208, 0, 0.12);
  border-color: rgba(255, 208, 0, 0.4);
  color: var(--neon-yellow);
}

.cloud-status-pill.syncing .cloud-dot {
  background: var(--neon-yellow);
  box-shadow: 0 0 6px var(--neon-yellow);
  animation: pulseSync 0.6s infinite alternate;
}

.cloud-status-pill.offline {
  background: rgba(255, 42, 95, 0.1);
  border-color: rgba(255, 42, 95, 0.3);
  color: var(--neon-red);
}

.cloud-status-pill.offline .cloud-dot {
  background: var(--neon-red);
  box-shadow: 0 0 6px var(--neon-red);
}

@keyframes pulseSync {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.3); opacity: 1; }
}

@media (max-width: 420px) {
  .cloud-text {
    display: none;
  }
  .cloud-status-pill {
    padding: 6px;
  }
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.06);
}

/* Hero Title */
.hero-header {
  text-align: center;
  margin: 4px 0 16px;
}

.hero-title {
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 0%, var(--neon-cyan) 50%, var(--neon-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* Glass Card */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  margin-bottom: 14px;
}

@media (min-width: 600px) {
  .glass-panel {
    padding: 20px;
  }
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--neon-cyan);
}

/* Table Selector Grid (2 to 9) */
.table-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

@media (min-width: 650px) {
  .table-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.table-btn {
  background: #191e33;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: 12px 4px;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.table-btn span.label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
}

.table-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--text-primary);
}

.table-btn.active {
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.25), rgba(157, 78, 221, 0.35));
  border-color: var(--neon-pink);
  color: #ffffff;
  box-shadow: var(--shadow-neon-pink);
  transform: scale(1.02);
}

/* Presets */
.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

/* Difficulty Multiplier Indicator */
.difficulty-indicator-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}

.diff-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.diff-badge {
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
  transition: all 0.2s ease;
}

.diff-badge.diff-master {
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.35), rgba(255, 208, 0, 0.35));
  color: var(--neon-yellow);
  border-color: var(--neon-yellow);
  box-shadow: 0 0 14px rgba(255, 208, 0, 0.4);
  animation: pulseFire 1s infinite alternate;
}

.hud-diff-tag {
  font-size: 0.7rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--neon-yellow);
  background: rgba(255, 208, 0, 0.18);
  border: 1px solid rgba(255, 208, 0, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
}

.table-tag-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}

.table-tag-pill.tag-master {
  color: var(--neon-yellow);
  background: rgba(255, 208, 0, 0.18);
  border-color: rgba(255, 208, 0, 0.4);
}

/* Mode Selection Cards */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 600px) {
  .mode-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.mode-card {
  background: #171b30;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.mode-card .mode-icon {
  font-size: 1.6rem;
  margin-bottom: 2px;
}

.mode-card .mode-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
}

.mode-card .mode-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.mode-card:hover {
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.mode-card.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(157, 78, 221, 0.2));
  border-color: var(--neon-cyan);
  box-shadow: var(--shadow-neon-cyan);
}

/* Boss Hardcore Difficulty Selector */
.boss-difficulty-section {
  margin-top: 14px;
  background: rgba(255, 42, 95, 0.08);
  border: 1px solid rgba(255, 42, 95, 0.35);
  border-radius: var(--radius-md);
  padding: 12px;
  animation: fadeIn 0.25s ease forwards;
}

.boss-diff-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--neon-yellow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.boss-diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
}

.boss-diff-card {
  background: rgba(20, 24, 42, 0.85);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.18s ease;
  position: relative;
}

.boss-diff-card:hover {
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.boss-diff-card.active {
  border-color: var(--neon-pink);
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.2), rgba(157, 78, 221, 0.25));
  box-shadow: 0 0 16px rgba(255, 0, 127, 0.4);
}

.boss-diff-card[data-boss-diff="nightmare"].active {
  border-color: var(--neon-yellow);
  background: linear-gradient(135deg, rgba(255, 84, 0, 0.25), rgba(255, 42, 95, 0.35));
  box-shadow: 0 0 20px rgba(255, 84, 0, 0.6);
}

.boss-diff-img-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.boss-diff-card.active .boss-diff-img-wrap {
  border-color: var(--neon-yellow);
  box-shadow: 0 0 12px var(--neon-yellow);
}

.boss-diff-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.boss-diff-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.boss-diff-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-primary);
}

.boss-diff-stats {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.boss-diff-pill {
  font-size: 0.64rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

.boss-diff-pill.easy { background: rgba(0, 255, 136, 0.2); color: var(--neon-green); border: 1px solid var(--neon-green); }
.boss-diff-pill.medium { background: rgba(255, 208, 0, 0.2); color: var(--neon-yellow); border: 1px solid var(--neon-yellow); }
.boss-diff-pill.hard { background: rgba(157, 78, 221, 0.2); color: var(--neon-purple); border: 1px solid var(--neon-purple); }
.boss-diff-pill.nightmare { background: rgba(255, 42, 95, 0.25); color: var(--neon-red); border: 1px solid var(--neon-red); animation: pulseFire 0.8s infinite alternate; }

/* Input Mode Selector */
.input-mode-section {
  margin-top: 14px;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  animation: fadeIn 0.25s ease forwards;
}

.input-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.input-mode-tab {
  background: rgba(20, 24, 42, 0.85);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  user-select: none;
}

.input-mode-tab .input-mode-icon {
  font-size: 1.35rem;
}

.input-mode-tab .input-mode-text {
  text-align: center;
  line-height: 1.15;
}

.input-mode-tab .input-mode-bonus {
  background: linear-gradient(135deg, var(--neon-orange), var(--neon-pink));
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255, 0, 127, 0.5);
  animation: pulseFire 0.8s infinite alternate;
}

.input-mode-tab:hover {
  border-color: var(--neon-cyan);
  color: #fff;
  transform: translateY(-2px);
}

.input-mode-tab.active {
  border-color: var(--neon-cyan);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(157, 78, 221, 0.25));
  color: #fff;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
}

/* Big Start Button */
.big-start-btn {
  background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 50%, var(--neon-cyan) 100%);
  background-size: 200% 200%;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-size: 1.25rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 0, 127, 0.45);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.big-start-btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 12px 32px rgba(255, 0, 127, 0.6);
}

.big-start-btn:active {
  transform: translateY(2px) scale(0.99);
}

/* ==========================================================================
   GAME SCREEN & BOSS BATTLE (Enhanced Visual Feedback)
   ========================================================================== */

.game-hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  height: 44px;
  min-height: 44px;
  background: rgba(18, 23, 40, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0 8px 0 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 10;
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.hud-island {
  display: flex;
  align-items: center;
  min-width: 0;
}

.hud-island-left {
  justify-content: flex-start;
  gap: 4px;
  flex-shrink: 0;
}

.hud-island-center {
  justify-content: center;
  overflow: hidden;
}

.hud-island-right {
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.hud-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.hud-time-wrap {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.hud-time-wrap .hud-value {
  font-size: clamp(1rem, 3.6vw, 1.2rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--neon-cyan);
  line-height: 1;
  letter-spacing: -0.5px;
}

.hud-unit {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.hud-streak-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(255, 208, 0, 0.08);
  border: 1px solid rgba(255, 208, 0, 0.25);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  min-width: auto;
  flex-shrink: 0;
}

.hud-streak-flame {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}

.hud-streak-box .hud-value {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--neon-yellow);
  line-height: 1;
}

.streak-multiplier {
  background: linear-gradient(135deg, var(--neon-orange), var(--neon-pink));
  color: #ffffff;
  font-size: 0.58rem;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 1px 4px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.1;
  box-shadow: 0 0 8px rgba(255, 84, 0, 0.6);
  animation: pulseFire 0.8s infinite alternate;
}

.hud-score-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.hud-score-val {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--neon-yellow);
  line-height: 1;
}

.hud-coin-icon {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

.hud-diff-tag {
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--neon-cyan);
  font-size: 0.62rem;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.exit-hud-btn,
.game-hud .icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 42, 95, 0.12);
  border: 1px solid rgba(255, 42, 95, 0.35);
  color: #ff5480;
  transition: all 0.18s ease;
}

.exit-hud-btn:hover {
  background: rgba(255, 42, 95, 0.3);
  border-color: var(--neon-red);
  color: #ffffff;
  transform: scale(1.08);
}

@keyframes pulseFire {
  from { transform: scale(1); }
  to { transform: scale(1.15); box-shadow: 0 0 14px var(--neon-pink); }
}

/* ==========================================================================
   HEARTHSTONE-STYLE BOSS BATTLE ARENA & JUICY COMBAT FX
   ========================================================================== */

/* Fullscreen Screen Damage Flash Overlay */
.screen-damage-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, transparent 40%, rgba(255, 0, 80, 0.65) 100%);
  pointer-events: none;
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

.screen-damage-flash.flash-active {
  opacity: 1;
  animation: damageVignette 0.4s ease-out forwards;
}

@keyframes damageVignette {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Fullscreen Arcade Combo Banner */
.combo-banner-overlay {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  pointer-events: none;
  z-index: 9500;
  opacity: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.combo-banner-overlay.show-combo {
  animation: comboPopSlide 1.1s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.combo-banner-text {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: clamp(1.8rem, 6vw, 3rem);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fff 0%, var(--neon-yellow) 40%, var(--neon-orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 208, 0, 0.9)) drop-shadow(0 4px 8px #000);
  white-space: nowrap;
}

@keyframes comboPopSlide {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(0deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(0.9); }
}

/* Combat FX Projectiles & Slashes */
.combat-fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8500;
  overflow: hidden;
}

.flying-projectile {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffffff 0%, #ffd000 35%, #ff5400 65%, #ff0055 90%, transparent 100%);
  box-shadow: 0 0 16px #ffd000, 0 0 32px #ff5400, 0 0 48px #ff0055;
  transform: translate(-50%, -50%);
  transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1), top 0.32s cubic-bezier(0.22, 1, 0.36, 1), transform 0.32s ease-out;
  z-index: 8600;
  animation: flameFlickerCore 0.15s infinite alternate;
}

.flying-projectile::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 208, 0, 0.8) 0%, rgba(255, 84, 0, 0.4) 60%, transparent 80%);
  filter: blur(4px);
  z-index: -1;
  animation: pulseFlameAura 0.2s infinite alternate;
}

@keyframes flameFlickerCore {
  0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { transform: translate(-50%, -50%) scale(1.18) rotate(15deg); }
}

@keyframes pulseFlameAura {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.3); opacity: 1; }
}

.projectile-ember {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd000;
  box-shadow: 0 0 10px #ff5400;
  pointer-events: none;
  z-index: 8590;
  animation: emberFade 0.4s ease-out forwards;
}

@keyframes emberFade {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0.2); opacity: 0; }
}

.boss-claw-slash {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 320px;
  height: 8px;
  background: linear-gradient(90deg, transparent, #ff0055 20%, #ffffff 50%, #ff0055 80%, transparent 100%);
  box-shadow: 0 0 35px rgba(255, 0, 85, 0.95), 0 0 15px #ffffff;
  transform: translate(-50%, -50%) rotate(-35deg) scaleX(0);
  animation: clawSlashAnim 0.38s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
  z-index: 8800;
}

@keyframes clawSlashAnim {
  0% { transform: translate(-50%, -50%) rotate(-35deg) scaleX(0); opacity: 0; }
  35% { transform: translate(-50%, -50%) rotate(-35deg) scaleX(1.5); opacity: 1; height: 14px; }
  100% { transform: translate(-50%, -50%) rotate(-35deg) scaleX(2.0); opacity: 0; }
}

/* Screen Shakes */
.screen-shake-sm {
  animation: shakeSm 0.28s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeSm {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 3px); }
  40% { transform: translate(4px, -3px); }
  60% { transform: translate(-3px, 1px); }
  80% { transform: translate(2px, -1px); }
}

.screen-shake-heavy {
  animation: shakeHeavy 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeHeavy {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-12px, 9px) rotate(-2deg); }
  30% { transform: translate(12px, -9px) rotate(2deg); }
  50% { transform: translate(-8px, 6px) rotate(-1deg); }
  70% { transform: translate(8px, -4px) rotate(1deg); }
  85% { transform: translate(-4px, 2px) rotate(-0.5deg); }
}

/* ==========================================================================
   EPIC CINEMATIC TITAN BOSS ARENA & 4 ELEMENTAL BIOMES
   ========================================================================== */

.boss-arena-stage,
.boss-banner {
  display: none;
  position: relative;
  width: 100%;
  height: clamp(215px, 34vh, 265px);
  min-height: 200px;
  max-height: 275px;
  flex: 0 0 auto;
  border-radius: var(--radius-lg);
  overflow: visible;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.5);
  background: radial-gradient(ellipse at 50% 25%, #101c36 0%, #080d1e 65%, #040710 100%);
  box-sizing: border-box;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.boss-arena-stage.active,
.boss-banner.active {
  display: flex;
  flex-direction: column;
}

/* Weather Canvas Layer */
.boss-weather-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  border-radius: var(--radius-lg);
}

/* Arena Bottom Fog Mist Overlay */
.boss-arena-fog {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 115%, rgba(0, 0, 0, 0.75) 0%, transparent 60%);
}

.boss-arena-inner {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 14px 8px;
  box-sizing: border-box;
}

/* 1. Top Bar */
.boss-arena-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 6px;
}

.boss-header-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.boss-element-icon {
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  line-height: 1;
  filter: drop-shadow(0 0 8px currentColor);
  flex-shrink: 0;
  animation: elementIconPulse 2s infinite ease-in-out;
}

@keyframes elementIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15) rotate(5deg); }
}

.boss-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.boss-name-text {
  font-size: clamp(0.95rem, 3.2vw, 1.2rem);
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.4), 0 2px 4px #000;
  letter-spacing: 0.3px;
}

.boss-phase-badge {
  background: rgba(0, 240, 255, 0.18);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
  transition: all 0.3s ease;
}

.boss-phase-badge.enraged-badge {
  background: linear-gradient(135deg, var(--neon-orange), var(--neon-red));
  border-color: var(--neon-yellow);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(255, 84, 0, 0.95);
  animation: pulseFire 0.6s infinite alternate;
}

.player-hearts-defense {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.defense-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--neon-pink);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.player-hearts {
  font-size: 1.25rem;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 42, 95, 0.5));
}

.player-hearts.hearts-shattered {
  animation: heartShake 0.4s ease;
}

@keyframes heartShake {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.3) rotate(-8deg); }
  50% { transform: scale(0.9) rotate(8deg); }
  75% { transform: scale(1.1); }
}

/* 2. Dual-Layer Ghost HP Bar */
.boss-hp-bar-wrap {
  width: 100%;
  height: 20px;
  background: #080a14;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.85), 0 2px 10px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  margin-bottom: 4px;
}

/* Ghost Bleed Layer (Lagging White/Golden Damage Trail) */
.boss-hp-ghost {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #ffffff, #ffe082);
  border-radius: var(--radius-pill);
  transition: width 0.55s cubic-bezier(0.25, 1, 0.5, 1) 0.25s;
  z-index: 1;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

/* Instant Front Layer (Colored Theme Gradient) */
.boss-hp-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #0077b6 0%, #00f0ff 60%, #b9f2ff 100%);
  border-radius: var(--radius-pill);
  transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
  z-index: 2;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.6);
}

.boss-hp-fill.boss-regen-flash {
  background: linear-gradient(90deg, #00ff88, #00f0ff) !important;
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.95) !important;
}

.boss-hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 8px #000000;
  letter-spacing: 0.6px;
  pointer-events: none;
  z-index: 3;
}

/* 3. Central Dragon Stage */
.boss-dragon-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  min-height: 130px;
  padding: 6px 0;
}

/* Elemental Aura Background Layer */
.boss-elemental-aura {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(150px, 24vh, 210px);
  height: clamp(150px, 24vh, 210px);
  pointer-events: none;
  z-index: 1;
}

.aura-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2), inset 0 0 20px rgba(0, 240, 255, 0.15);
}

.aura-ring.ring-outer {
  animation: rotateCW 18s linear infinite;
}

.aura-ring.ring-inner {
  inset: 16px;
  border-style: dotted;
  border-width: 2px;
  animation: rotateCCW 12s linear infinite;
}

.aura-core-glow {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.25) 0%, rgba(0, 240, 255, 0.05) 55%, transparent 75%);
  filter: blur(8px);
  animation: auraPulse 2.4s infinite ease-in-out;
}

@keyframes rotateCW {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotateCCW {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes auraPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* Dragon Avatar Frame (Circular Glowing Armor Frame) */
.boss-avatar-frame {
  position: relative;
  z-index: 2;
  width: clamp(125px, 20vh, 175px);
  height: clamp(125px, 20vh, 175px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid var(--neon-cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.45), inset 0 0 15px rgba(0, 0, 0, 0.5);
  background: #090d1e;
  overflow: hidden;
  transition: transform 0.2s ease, filter 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  animation: bossIdleBreathing 3s infinite ease-in-out;
}

.boss-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.4));
  transition: filter 0.3s ease;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

.boss-mist-gradient {
  display: none !important;
}

.boss-enrage-flame {
  position: absolute;
  top: 0px;
  right: 8px;
  font-size: 1.8rem;
  display: none;
  animation: flameFlicker 0.4s infinite alternate;
  filter: drop-shadow(0 0 12px var(--neon-yellow));
  z-index: 10;
}

.boss-theme-ice .boss-avatar-frame { border-color: var(--neon-cyan); box-shadow: 0 0 20px rgba(0, 240, 255, 0.5); }
.boss-theme-fire .boss-avatar-frame { border-color: var(--neon-orange); box-shadow: 0 0 20px rgba(255, 84, 0, 0.5); }
.boss-theme-poison .boss-avatar-frame { border-color: var(--neon-green); box-shadow: 0 0 20px rgba(0, 255, 136, 0.5); }
.boss-theme-void .boss-avatar-frame { border-color: #ffd000; box-shadow: 0 0 24px rgba(255, 208, 0, 0.6), 0 0 14px rgba(181, 23, 158, 0.7); }

/* ==========================================================================
   THE 4 ELEMENTAL BIOME THEMES
   ========================================================================== */

/* 1. ICE THEME (.boss-theme-ice) - Easy 150 HP */
.boss-arena-stage.boss-theme-ice {
  border-color: var(--neon-cyan);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 240, 255, 0.35), inset 0 0 20px rgba(0, 240, 255, 0.15);
  background: radial-gradient(ellipse at 50% 25%, #0d2844 0%, #071324 65%, #030810 100%);
}
.boss-theme-ice .boss-element-icon { color: var(--neon-cyan); }
.boss-theme-ice .boss-phase-badge { border-color: var(--neon-cyan); color: var(--neon-cyan); background: rgba(0, 240, 255, 0.18); }
.boss-theme-ice .boss-hp-fill { background: linear-gradient(90deg, #0077b6 0%, #00f0ff 60%, #b9f2ff 100%); box-shadow: 0 0 16px rgba(0, 240, 255, 0.7); }
.boss-theme-ice .aura-ring { border-color: rgba(0, 240, 255, 0.4); box-shadow: 0 0 24px rgba(0, 240, 255, 0.25), inset 0 0 20px rgba(0, 240, 255, 0.15); }
.boss-theme-ice .aura-core-glow { background: radial-gradient(circle, rgba(0, 240, 255, 0.3) 0%, rgba(0, 240, 255, 0.05) 60%, transparent 80%); }
.boss-theme-ice .boss-avatar-img { filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.5)); }

/* 2. FIRE THEME (.boss-theme-fire) - Medium 300 HP */
.boss-arena-stage.boss-theme-fire {
  border-color: var(--neon-orange);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 28px rgba(255, 84, 0, 0.45), inset 0 0 20px rgba(255, 0, 85, 0.2);
  background: radial-gradient(ellipse at 50% 25%, #3c1219 0%, #1c080d 65%, #0a0305 100%);
}
.boss-theme-fire .boss-element-icon { color: var(--neon-orange); }
.boss-theme-fire .boss-phase-badge { border-color: var(--neon-orange); color: var(--neon-orange); background: rgba(255, 84, 0, 0.18); }
.boss-theme-fire .boss-hp-fill { background: linear-gradient(90deg, #ff0055 0%, #ff5400 60%, #ffd000 100%); box-shadow: 0 0 16px rgba(255, 84, 0, 0.8); }
.boss-theme-fire .aura-ring { border-color: rgba(255, 84, 0, 0.45); box-shadow: 0 0 25px rgba(255, 84, 0, 0.3), inset 0 0 20px rgba(255, 0, 85, 0.2); }
.boss-theme-fire .aura-core-glow { background: radial-gradient(circle, rgba(255, 84, 0, 0.35) 0%, rgba(255, 0, 85, 0.08) 60%, transparent 80%); }
.boss-theme-fire .boss-avatar-img { filter: drop-shadow(0 0 18px rgba(255, 84, 0, 0.6)) drop-shadow(0 0 8px rgba(255, 0, 85, 0.5)); }

/* 3. POISON THEME (.boss-theme-poison) - Hard 500 HP */
.boss-arena-stage.boss-theme-poison {
  border-color: var(--neon-green);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 28px rgba(0, 255, 136, 0.4), inset 0 0 22px rgba(157, 78, 221, 0.22);
  background: radial-gradient(ellipse at 50% 25%, #18311e 0%, #0d1e17 65%, #050e0a 100%);
}
.boss-theme-poison .boss-element-icon { color: var(--neon-green); }
.boss-theme-poison .boss-phase-badge { border-color: var(--neon-green); color: var(--neon-green); background: rgba(0, 255, 136, 0.18); }
.boss-theme-poison .boss-hp-fill { background: linear-gradient(90deg, #9d4edd 0%, #00ff88 60%, #a7f3d0 100%); box-shadow: 0 0 16px rgba(0, 255, 136, 0.8); }
.boss-theme-poison .aura-ring { border-color: rgba(0, 255, 136, 0.45); box-shadow: 0 0 25px rgba(0, 255, 136, 0.3), inset 0 0 20px rgba(157, 78, 221, 0.2); }
.boss-theme-poison .aura-core-glow { background: radial-gradient(circle, rgba(0, 255, 136, 0.35) 0%, rgba(157, 78, 221, 0.1) 60%, transparent 80%); }
.boss-theme-poison .boss-avatar-img { filter: drop-shadow(0 0 18px rgba(0, 255, 136, 0.6)) drop-shadow(0 0 10px rgba(157, 78, 221, 0.5)); }

/* 4. VOID THEME (.boss-theme-void) - Nightmare 700 HP */
.boss-arena-stage.boss-theme-void {
  border-color: #b5179e;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 35px rgba(181, 23, 158, 0.5), 0 0 12px rgba(255, 208, 0, 0.4), inset 0 0 24px rgba(114, 9, 183, 0.3);
  background: radial-gradient(ellipse at 50% 25%, #2d0f3c 0%, #170724 65%, #08020d 100%);
}
.boss-theme-void .boss-element-icon { color: var(--neon-yellow); }
.boss-theme-void .boss-phase-badge { border-color: var(--neon-yellow); color: var(--neon-yellow); background: rgba(255, 208, 0, 0.18); box-shadow: 0 0 10px rgba(255, 208, 0, 0.4); }
.boss-theme-void .boss-hp-fill { background: linear-gradient(90deg, #7209b7 0%, #b5179e 50%, #ffd000 100%); box-shadow: 0 0 20px rgba(181, 23, 158, 0.85); }
.boss-theme-void .aura-ring { border-color: rgba(255, 208, 0, 0.45); box-shadow: 0 0 28px rgba(181, 23, 158, 0.4), inset 0 0 22px rgba(255, 208, 0, 0.25); }
.boss-theme-void .aura-core-glow { background: radial-gradient(circle, rgba(181, 23, 158, 0.4) 0%, rgba(255, 208, 0, 0.15) 55%, transparent 80%); }
.boss-theme-void .boss-avatar-img { filter: drop-shadow(0 0 20px rgba(181, 23, 158, 0.8)) drop-shadow(0 0 10px rgba(255, 208, 0, 0.7)); }



/* Boss Recoil Hit with Brightness Flash 4.0 */
.boss-avatar-frame.boss-recoil-hit {
  animation: bossRecoilHitAnim 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
  z-index: 150;
}

@keyframes bossRecoilHitAnim {
  0% { transform: scale(1) translateY(0); filter: brightness(1); }
  20% { transform: scale(0.8) translateY(-24px) rotate(-10deg); filter: brightness(4.0) contrast(1.4) drop-shadow(0 0 30px #ffffff); box-shadow: 0 0 45px #ffd000; }
  50% { transform: scale(1.2) translateY(8px) rotate(5deg); filter: brightness(1.8) drop-shadow(0 0 18px #ff5400); }
  80% { transform: scale(0.96) translateY(-2px); filter: brightness(1.2); }
  100% { transform: scale(1) translateY(0); filter: brightness(1); }
}

/* Floating 3D Damage & Regen Text (Centered inside Dragon Stage) */
.boss-damage-pop-3d {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-weight: 900;
  font-family: var(--font-main);
  font-size: clamp(1.5rem, 5.5vw, 2.3rem);
  color: #ffffff;
  text-shadow: 
    0 2px 0 #ff0055, 
    0 4px 0 #b3003b, 
    0 6px 14px rgba(0, 0, 0, 0.95), 
    0 0 25px rgba(255, 42, 95, 1);
  animation: bossPop3D 1.05s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  z-index: 500;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.boss-damage-pop-3d.crit {
  font-size: clamp(1.7rem, 6.5vw, 2.7rem);
  color: #fffbdf;
  text-shadow: 
    0 2px 0 #ff5400, 
    0 4px 0 #b83200, 
    0 8px 18px rgba(0, 0, 0, 0.95), 
    0 0 35px #ffd000, 
    0 0 20px #ff5400;
  animation: bossCritPop3D 1.15s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.boss-damage-pop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-weight: 900;
  font-family: var(--font-main);
  font-size: clamp(1.35rem, 4.8vw, 2.0rem);
  color: #ffffff;
  text-shadow: 
    0 2px 0 #00aa55, 
    0 4px 0 #006633, 
    0 6px 14px rgba(0, 0, 0, 0.95), 
    0 0 25px #00ff88;
  animation: bossFloatUp 1.05s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  z-index: 500;
  white-space: nowrap;
}

@keyframes bossPop3D {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.4) rotate(-5deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.35) rotate(0deg); }
  75% { opacity: 1; transform: translate(-50%, -85%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(0.85); }
}

@keyframes bossCritPop3D {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.3) rotate(-10deg); }
  25% { opacity: 1; transform: translate(-50%, -55%) scale(1.55) rotate(3deg); }
  75% { opacity: 1; transform: translate(-50%, -95%) scale(1.2) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -135%) scale(0.9); }
}

@keyframes bossFloatUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  75% { opacity: 1; transform: translate(-50%, -85%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(0.85); }
}

/* Elemental Sparks & Shockwaves */
.vfx-elemental-spark {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 8750;
  animation: vfxSparkFly 0.55s cubic-bezier(0.12, 0.82, 0.25, 1) forwards;
}

@keyframes vfxSparkFly {
  0% { transform: translate(-50%, -50%) scale(var(--scale, 1)); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0.1); opacity: 0; }
}

.vfx-crit-shockwave {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #ffd000;
  box-shadow: 0 0 20px #ffd000, inset 0 0 15px #ff5400;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: vfxShockwaveExpand 0.6s ease-out forwards;
  z-index: 8740;
}

@keyframes vfxShockwaveExpand {
  0% { width: 20px; height: 20px; opacity: 1; border-width: 4px; }
  100% { width: 280px; height: 280px; opacity: 0; border-width: 1px; }
}

.boss-impact-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff, #ffd000, #ff5400);
  box-shadow: 0 0 10px #ffd000, 0 0 20px #ff0055;
  pointer-events: none;
  z-index: 8700;
  animation: sparkBurst 0.45s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes sparkBurst {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0); opacity: 0; }
}

/* ==========================================================================
   ELEMENTAL BOSS COUNTER-ATTACK OVERLAYS (Ice, Fire, Poison, Void)
   ========================================================================== */

/* 1. Ice Freeze Overlay */
.ice-freeze-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8900;
  animation: iceOverlayAnim 0.75s ease-out forwards;
}

.ice-frost-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 100px rgba(185, 242, 255, 0.9), inset 0 0 45px #00f0ff;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.ice-shatter-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 320px;
  height: 320px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(185, 242, 255, 0.4) 45%, transparent 70%);
  border-radius: 50%;
  filter: drop-shadow(0 0 25px #00f0ff);
  animation: iceShatterAnim 0.75s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes iceOverlayAnim {
  0% { opacity: 0; transform: scale(0.95); }
  25% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes iceShatterAnim {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(0deg); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.2) rotate(15deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6) rotate(30deg); opacity: 0; }
}

/* 2. Fire Claw Overlay */
.fire-claw-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8900;
  animation: fireOverlayAnim 0.75s ease-out forwards;
}

.fire-flame-burst {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 84, 0, 0.45) 0%, rgba(255, 42, 95, 0.6) 60%, transparent 100%);
  mix-blend-mode: screen;
}

.fire-claw-mark {
  position: absolute;
  height: 10px;
  width: 340px;
  background: linear-gradient(90deg, transparent, #ff0055 15%, #ffffff 50%, #ffd000 85%, transparent 100%);
  box-shadow: 0 0 35px #ff5400, 0 0 15px #ffffff;
  top: 50%;
  left: 50%;
  border-radius: 5px;
}

.fire-claw-mark.claw-1 {
  transform: translate(-50%, -70px) rotate(-32deg) scaleX(0);
  animation: clawSlash 0.45s 0.05s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}
.fire-claw-mark.claw-2 {
  transform: translate(-50%, -50%) rotate(-32deg) scaleX(0);
  animation: clawSlash 0.45s 0.12s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}
.fire-claw-mark.claw-3 {
  transform: translate(-50%, -30px) rotate(-32deg) scaleX(0);
  animation: clawSlash 0.45s 0.19s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes fireOverlayAnim {
  0% { opacity: 0; }
  25% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes clawSlash {
  0% { transform: translate(-50%, var(--cy, -50%)) rotate(-32deg) scaleX(0); opacity: 0; }
  40% { transform: translate(-50%, var(--cy, -50%)) rotate(-32deg) scaleX(1.4); opacity: 1; }
  100% { transform: translate(-50%, var(--cy, -50%)) rotate(-32deg) scaleX(1.8); opacity: 0; }
}

/* 3. Acid Splash Overlay */
.acid-splash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8900;
  animation: acidOverlayAnim 0.75s ease-out forwards;
}

.acid-splatter-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(0, 255, 136, 0.3) 0%, rgba(168, 85, 247, 0.4) 65%, transparent 100%);
  box-shadow: inset 0 0 80px rgba(0, 255, 136, 0.75);
}

.acid-drip {
  position: absolute;
  width: 14px;
  background: linear-gradient(180deg, #00ff88, #39ff14, rgba(0, 255, 136, 0));
  border-radius: 8px;
  box-shadow: 0 0 15px #00ff88;
}

.acid-drip.drip-1 { left: 25%; top: 15%; height: 120px; animation: acidDripAnim 0.6s ease-in forwards; }
.acid-drip.drip-2 { left: 45%; top: 20%; height: 160px; animation: acidDripAnim 0.65s 0.08s ease-in forwards; }
.acid-drip.drip-3 { left: 65%; top: 10%; height: 140px; animation: acidDripAnim 0.58s 0.04s ease-in forwards; }
.acid-drip.drip-4 { left: 80%; top: 25%; height: 100px; animation: acidDripAnim 0.62s 0.12s ease-in forwards; }

@keyframes acidOverlayAnim {
  0% { opacity: 0; }
  25% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes acidDripAnim {
  0% { transform: scaleY(0.1); opacity: 0; }
  40% { transform: scaleY(1); opacity: 1; }
  100% { transform: translateY(80px) scaleY(1.3); opacity: 0; }
}

/* 4. Void Rift Overlay */
.void-rift-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8900;
  animation: voidOverlayAnim 0.75s ease-out forwards;
}

.void-gravity-lens {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 380px;
  height: 380px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #000000 25%, #4c1d95 60%, transparent 80%);
  border-radius: 50%;
  box-shadow: 0 0 70px rgba(192, 132, 252, 0.85);
  animation: voidGravityPulse 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.void-lightning-branch {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 4px;
  background: linear-gradient(90deg, #c084fc, #00f0ff, #ffffff);
  box-shadow: 0 0 25px #c084fc, 0 0 10px #fff;
}

.void-lightning-branch.branch-1 {
  transform: translate(-50%, -50%) rotate(45deg);
  animation: voidLightningFlash 0.4s ease-out forwards;
}

.void-lightning-branch.branch-2 {
  transform: translate(-50%, -50%) rotate(-55deg);
  animation: voidLightningFlash 0.4s 0.08s ease-out forwards;
}

@keyframes voidOverlayAnim {
  0% { opacity: 0; }
  25% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes voidGravityPulse {
  0% { transform: translate(-50%, -50%) scale(0.1); }
  45% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

@keyframes voidLightningFlash {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0.2); }
  30% { opacity: 1; transform: translate(-50%, -50%) scaleX(1.3); }
  100% { opacity: 0; }
}

/* ==========================================================================
   BERSERK ENRAGE & DEATH CINEMATIC STYLES
   ========================================================================== */

.boss-freeze-frame {
  filter: brightness(2.5) contrast(1.6) !important;
}

.enrage-shockwave-ring {
  position: fixed;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 4px solid var(--neon-red);
  box-shadow: 0 0 35px var(--neon-orange), inset 0 0 20px var(--neon-red);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8850;
  animation: enrageRingExpand 0.8s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes enrageRingExpand {
  0% { width: 30px; height: 30px; opacity: 1; border-width: 6px; }
  100% { width: 450px; height: 450px; opacity: 0; border-width: 1px; }
}

/* Death Cinematic */
.boss-death-freeze {
  filter: brightness(2.0) contrast(1.4) drop-shadow(0 0 30px #ffd000) !important;
  animation: none !important;
}

.divine-light-beams {
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 208, 0, 0.6) 40%, transparent 70%);
  box-shadow: 0 0 80px #ffd000, 0 0 140px #ff5400;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8860;
  animation: divineLightPulse 2.2s ease-out forwards;
}

@keyframes divineLightPulse {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.3) rotate(45deg); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1.6) rotate(90deg); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(2.0) rotate(140deg); opacity: 0; }
}

.boss-micro-blast {
  position: fixed;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff, #ffd000, #ff5400, transparent);
  box-shadow: 0 0 30px #ffd000, 0 0 50px #ff2a5f;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8870;
  animation: microBlastAnim 0.45s ease-out forwards;
}

@keyframes microBlastAnim {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

.boss-disintegrate-portal {
  animation: disintegratePortal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
}

@keyframes disintegratePortal {
  0% { transform: scale(1) rotate(0deg); filter: brightness(2) drop-shadow(0 0 20px #fff); opacity: 1; }
  50% { transform: scale(1.3) rotate(180deg); filter: brightness(4) blur(4px); opacity: 0.8; }
  100% { transform: scale(0.05) rotate(720deg); filter: brightness(8) blur(12px); opacity: 0; }
}

/* 3D Fountain Coins */
.treasure-coin-3d {
  position: fixed;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  pointer-events: none;
  z-index: 8990;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 14px rgba(255, 208, 0, 0.8));
  user-select: none;
  transform-style: preserve-3d;
}

/* ==========================================================================
   ROUND PROGRESS BAR / TRACKER (Standard & Blitz Modes)
   ========================================================================== */

.game-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
}

.game-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.game-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.hud-progress-pill {
  font-size: 0.78rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ==========================================================================
   QUESTION STAGE & EQUATION (Giant Neon Clamp Typography)
   ========================================================================== */

.question-stage {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  max-height: 82px;
  background: radial-gradient(circle at center, #1b213b 0%, #0e1222 100%);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.question-stage.streak-fire-stage {
  border-color: var(--neon-orange);
  box-shadow: 0 0 35px rgba(255, 84, 0, 0.5), inset 0 0 15px rgba(255, 84, 0, 0.15);
  animation: fireBorderPulse 1.2s infinite alternate;
}

@keyframes fireBorderPulse {
  from { border-color: var(--neon-orange); box-shadow: 0 0 20px rgba(255, 84, 0, 0.35); }
  to { border-color: var(--neon-pink); box-shadow: 0 0 40px rgba(255, 0, 127, 0.55); }
}

.question-equation {
  font-size: clamp(2.2rem, 7vh, 3.4rem);
  font-weight: 900;
  font-family: var(--font-main);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 12px);
  flex-wrap: nowrap;
  white-space: nowrap;
  max-width: 100%;
}

.question-equation #question-a,
.question-equation #question-b {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
}

.question-equation .op {
  color: var(--neon-pink);
  text-shadow: 0 0 18px rgba(255, 0, 127, 0.7);
  font-weight: 900;
}

.question-equation .q-mark {
  color: var(--neon-yellow);
  text-shadow: 0 0 20px rgba(255, 208, 0, 0.85);
  animation: float 2s infinite ease-in-out;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Numpad Inline Equation Display Box */
.numpad-answer-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: clamp(46px, 5.8vh, 54px);
  min-height: 46px;
  padding: 2px 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 2.5px dashed var(--neon-cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35), inset 0 0 10px rgba(0, 0, 0, 0.7);
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 5.5vw, 2.6rem);
  font-weight: 900;
  color: var(--neon-yellow);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.numpad-answer-box.correct-glow {
  border-color: var(--neon-green) !important;
  border-style: solid !important;
  color: var(--neon-green) !important;
  box-shadow: 0 0 32px rgba(0, 255, 136, 0.8), inset 0 0 14px rgba(0, 255, 136, 0.35) !important;
  transform: scale(1.08) !important;
}

.numpad-answer-box.wrong-glow {
  border-color: var(--neon-red) !important;
  border-style: solid !important;
  color: var(--neon-red) !important;
  box-shadow: 0 0 32px rgba(255, 42, 95, 0.8), inset 0 0 14px rgba(255, 42, 95, 0.35) !important;
  animation: wrongShake 0.35s ease;
}

/* ==========================================================================
   ROCK NUMPAD (Tactile 3D Convex Buttons & High Impact)
   ========================================================================== */

.numpad-container {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  flex-shrink: 0;
  animation: fadeIn 0.2s ease forwards;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.numpad-btn {
  background: linear-gradient(180deg, #222949 0%, #151a31 100%);
  border: 2px solid #333f6b;
  border-radius: var(--radius-md);
  color: #ffffff;
  min-height: clamp(58px, 8.5vh, 64px);
  font-size: clamp(1.6rem, 5.5vw, 2.1rem);
  font-weight: 800;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 #0d1020, 0 8px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, border-color 0.08s ease, background 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.numpad-btn:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .numpad-btn:hover {
    background: linear-gradient(180deg, #2b345c 0%, #1a203d 100%);
    border-color: var(--neon-cyan);
    box-shadow: 0 6px 0 #0d1020, 0 0 16px rgba(0, 240, 255, 0.35);
    transform: translateY(-2px);
  }
}

.numpad-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0d1020, 0 2px 6px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #1a213d 0%, #12162a 100%);
}

.numpad-btn.numpad-action {
  font-family: var(--font-main);
}

.numpad-btn.numpad-backspace {
  color: var(--neon-orange);
  border-color: rgba(255, 84, 0, 0.55);
  background: linear-gradient(180deg, rgba(255, 84, 0, 0.2) 0%, rgba(255, 84, 0, 0.08) 100%);
  box-shadow: 0 5px 0 #0d1020, 0 0 14px rgba(255, 84, 0, 0.25);
  font-size: 1.55rem;
}

@media (hover: hover) and (pointer: fine) {
  .numpad-btn.numpad-backspace:hover {
    border-color: var(--neon-orange);
    box-shadow: 0 6px 0 #0d1020, 0 0 20px rgba(255, 84, 0, 0.5);
  }
}

.numpad-btn.numpad-enter {
  color: var(--neon-green);
  border-color: rgba(0, 255, 136, 0.55);
  background: linear-gradient(180deg, rgba(0, 255, 136, 0.2) 0%, rgba(0, 255, 136, 0.08) 100%);
  box-shadow: 0 5px 0 #0d1020, 0 0 14px rgba(0, 255, 136, 0.25);
  font-size: 1.65rem;
}

@media (hover: hover) and (pointer: fine) {
  .numpad-btn.numpad-enter:hover {
    border-color: var(--neon-green);
    box-shadow: 0 6px 0 #0d1020, 0 0 20px rgba(0, 255, 136, 0.5);
  }
}

/* ==========================================================================
   4 CHOICES GRID (2x2 Thumb-Friendly Layout)
   ========================================================================== */

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  flex-shrink: 0;
  position: relative;
}

.answer-btn {
  background: linear-gradient(180deg, #222949 0%, #151a31 100%);
  border: 2px solid #333f6b;
  border-radius: var(--radius-lg);
  color: #ffffff;
  padding: 10px 8px;
  font-size: clamp(1.6rem, 5.5vw, 2.2rem);
  font-weight: 800;
  font-family: var(--font-mono);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 #0d1020, 0 8px 16px rgba(0, 0, 0, 0.4);
  min-height: clamp(60px, 9vh, 72px);
  transition: transform 0.08s ease, border-color 0.08s ease, background 0.08s ease, box-shadow 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  user-select: none;
}

.answer-btn:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .answer-btn:hover {
    background: linear-gradient(180deg, #2b345c 0%, #1a203d 100%);
    border-color: var(--neon-cyan);
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #0d1020, 0 0 18px rgba(0, 240, 255, 0.35);
  }
}

.answer-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0d1020, 0 2px 6px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #1a213d 0%, #12162a 100%);
}

.key-hint {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-main);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  padding: 2px 5px;
  border-radius: 5px;
}

.answer-btn.correct-glow {
  background: linear-gradient(135deg, #00b359, #00ff88) !important;
  border-color: #00ff88 !important;
  color: #0d2818 !important;
  box-shadow: var(--shadow-neon-green), 0 4px 0 #008f45 !important;
  transform: scale(1.04) translateY(-3px) !important;
}

.answer-btn.wrong-glow {
  background: linear-gradient(135deg, #b31034, #ff2a5f) !important;
  border-color: #ff2a5f !important;
  color: #ffffff !important;
  box-shadow: 0 0 24px rgba(255, 42, 95, 0.5), 0 4px 0 #850020 !important;
  animation: wrongShake 0.35s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25%, 75% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
}

/* Floating Score Pop */
.score-floating-pop {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px rgba(255, 208, 0, 0.8), 0 2px 4px #000;
  animation: floatUpFade 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 100;
}

@keyframes floatUpFade {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -22px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50px) scale(1); }
}

/* Badge Toast Popup */
.badge-toast-popup {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, #1c223b, #2b1738);
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 25px rgba(255, 208, 0, 0.5);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 6000;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  max-width: 90vw;
}

.badge-toast-popup.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Countdown Overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 22, 0.92);
  backdrop-filter: blur(12px);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.countdown-overlay.active { display: flex; }

.countdown-number {
  font-size: clamp(5.5rem, 24vw, 10rem);
  font-weight: 900;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: countdownPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.countdown-subtitle {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--neon-yellow);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 6px;
}

@keyframes countdownPop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   2-PLAYER DUEL SPLIT SCREEN ARENA & TARGET SELECTOR
   ========================================================================== */

.duel-target-section {
  background: rgba(14, 18, 36, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-top: 14px;
  animation: slideDown 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.duel-target-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 580px) {
  .duel-target-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.duel-target-card {
  background: #151a30;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s ease;
  user-select: none;
}

.duel-target-card:hover {
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.duel-target-card.active {
  border-color: var(--neon-yellow);
  background: radial-gradient(circle at center, rgba(255, 208, 0, 0.15), #18203c);
  box-shadow: 0 0 16px rgba(255, 208, 0, 0.4);
}

.duel-target-num {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: #fff;
}

.duel-target-card.active .duel-target-num {
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 208, 0, 0.6);
}

.duel-target-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
}

/* --- DUEL ARENA FULLSCREEN CONTAINER --- */
.duel-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #101528 0%, #050711 100%);
  z-index: 4000;
  touch-action: none;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.duel-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 8px 12px 6px;
  position: relative;
  touch-action: manipulation;
  box-sizing: border-box;
  overflow: hidden;
}

.duel-half.p2-half {
  background: linear-gradient(180deg, rgba(255, 0, 127, 0.1) 0%, rgba(13, 16, 32, 0.95) 100%);
  border-bottom: 2px solid rgba(255, 0, 127, 0.4);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.duel-half.p2-half.tabletop-flipped {
  transform: rotate(180deg);
}

.duel-half.p1-half {
  background: linear-gradient(0deg, rgba(0, 240, 255, 0.1) 0%, rgba(13, 16, 32, 0.95) 100%);
  border-top: 2px solid rgba(0, 240, 255, 0.4);
}

/* Player Headers */
.duel-player-header {
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  margin-top: 0;
  margin-bottom: max(2px, env(safe-area-inset-bottom));
  z-index: 5;
  flex-shrink: 0;
}

.duel-player-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.88rem;
}

.p1-theme .duel-player-name {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.p2-theme .duel-player-name {
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.6);
}

.duel-player-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.duel-score-pill {
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.duel-score-pill.p1-pill {
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.duel-score-pill.p2-pill {
  background: rgba(255, 0, 127, 0.15);
  border: 1px solid var(--neon-pink);
  color: var(--neon-pink);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
}

.duel-streak-badge {
  background: rgba(255, 208, 0, 0.2);
  border: 1px solid var(--neon-yellow);
  color: var(--neon-yellow);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  animation: pulse 1s infinite alternate;
}

/* Equations & Floating Pops */
.duel-equation-wrap {
  position: relative;
  margin-top: clamp(10px, 2.5vh, 22px);
  margin-bottom: auto;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(38px, 5vh, 50px);
  width: 100%;
  z-index: 10;
}

.duel-equation {
  font-size: clamp(1.8rem, 6.5vw, 2.6rem);
  font-weight: 900;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
  transition: transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.duel-eq-text {
  white-space: nowrap;
}

/* Dual Numpad Inline Equation Answer Box */
.duel-numpad-answer-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: clamp(34px, 4.6vh, 42px);
  min-height: 34px;
  padding: 0 8px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  color: var(--neon-yellow);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.p1-half .duel-numpad-answer-box {
  border: 2px dashed var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.p2-half .duel-numpad-answer-box {
  border: 2px dashed var(--neon-pink);
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.3);
}

.duel-numpad-answer-box.correct-glow {
  border-color: var(--neon-green) !important;
  border-style: solid !important;
  color: var(--neon-green) !important;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.8), inset 0 0 8px rgba(0, 255, 136, 0.3) !important;
  transform: scale(1.08) !important;
}

.duel-numpad-answer-box.wrong-glow {
  border-color: var(--neon-red) !important;
  border-style: solid !important;
  color: var(--neon-red) !important;
  box-shadow: 0 0 20px rgba(255, 42, 95, 0.8), inset 0 0 8px rgba(255, 42, 95, 0.3) !important;
  animation: wrongShake 0.35s ease;
}

.duel-pop-container {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  z-index: 50;
}

.duel-float-pop {
  font-weight: 900;
  font-family: var(--font-main);
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 16px currentColor;
  animation: duelPopAnim 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes duelPopAnim {
  0% { opacity: 0; transform: translateY(4px) scale(0.6); }
  25% { opacity: 1; transform: translateY(-8px) scale(1.25); }
  75% { opacity: 1; transform: translateY(-18px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-28px) scale(0.85); }
}

/* Middle Input Wrap: Choices or Numpad */
.duel-input-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: 6px;
  z-index: 5;
}

/* Choices Mode 2x2 Grid */
.duel-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  touch-action: manipulation;
}

.duel-btn {
  background: linear-gradient(180deg, #222944 0%, #15192c 100%);
  border: 2px solid #364268;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  font-weight: 900;
  font-family: var(--font-mono);
  padding: clamp(8px, 2.2vh, 14px) 6px;
  cursor: pointer;
  box-shadow: 0 4px 0 #0d101c, 0 6px 14px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  text-align: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.p1-half .duel-btn:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 4px 0 #0d101c, 0 0 16px rgba(0, 240, 255, 0.4);
}

.p2-half .duel-btn:hover {
  border-color: var(--neon-pink);
  box-shadow: 0 4px 0 #0d101c, 0 0 16px rgba(255, 0, 127, 0.4);
}

.duel-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0d101c;
}

.duel-btn.correct-flash {
  background: linear-gradient(180deg, #00ff88 0%, #00a855 100%) !important;
  border-color: #00ff88 !important;
  color: #000 !important;
  transform: scale(1.05);
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.9) !important;
}

.duel-btn.wrong-flash {
  background: linear-gradient(180deg, #ff2a5f 0%, #a00028 100%) !important;
  border-color: #ff2a5f !important;
  color: #fff !important;
  animation: wrongShake 0.4s ease;
}

/* Dual 3x4 Numpad Grid */
.duel-numpad {
  width: 100%;
  max-width: 290px;
  margin: 0 auto;
  flex-shrink: 0;
  touch-action: manipulation;
}

.duel-numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.duel-numpad-btn {
  background: linear-gradient(180deg, #222944 0%, #15192c 100%);
  border: 2px solid #364268;
  border-radius: var(--radius-sm);
  color: #ffffff;
  height: clamp(34px, 4.6vh, 42px);
  min-height: 34px;
  font-size: clamp(1.15rem, 3.8vw, 1.45rem);
  font-weight: 800;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #0d101c, 0 4px 8px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  transition: transform 0.06s ease, border-color 0.08s ease, background 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.duel-numpad-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0d101c;
}

.p1-half .duel-numpad-btn:hover {
  border-color: var(--neon-cyan);
}

.p1-half .duel-numpad-btn:active {
  border-color: var(--neon-cyan);
  background: linear-gradient(180deg, #1b354d 0%, #0d2238 100%);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.p2-half .duel-numpad-btn:hover {
  border-color: var(--neon-pink);
}

.p2-half .duel-numpad-btn:active {
  border-color: var(--neon-pink);
  background: linear-gradient(180deg, #4d1b35 0%, #380d22 100%);
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.4);
}

.duel-numpad-action.duel-numpad-backspace {
  background: linear-gradient(180deg, #3d1b28 0%, #250f18 100%);
  border-color: rgba(255, 42, 95, 0.4);
  color: var(--neon-red);
  font-size: 1.15rem;
}

.duel-numpad-action.duel-numpad-enter {
  background: linear-gradient(180deg, #1b3d2b 0%, #0f2518 100%);
  border-color: rgba(0, 255, 136, 0.4);
  color: var(--neon-green);
  font-size: 1.15rem;
}

/* Center Battle Console & Electric Tug-of-War */
.duel-center-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: linear-gradient(90deg, #0d1222 0%, #151a30 50%, #0d1222 100%);
  border-top: 2px solid rgba(0, 240, 255, 0.35);
  border-bottom: 2px solid rgba(255, 0, 127, 0.35);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.85);
  z-index: 20;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.duel-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #181f38;
  border: 1px solid #334066;
  border-radius: 8px;
  color: #cfdbfc;
  font-weight: 800;
  font-size: 0.74rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.duel-action-btn.exit:hover {
  border-color: var(--neon-red);
  color: var(--neon-red);
  box-shadow: 0 0 12px rgba(255, 42, 95, 0.4);
}

.duel-action-btn.flip:hover {
  border-color: var(--neon-yellow);
  color: var(--neon-yellow);
  box-shadow: 0 0 12px rgba(255, 208, 0, 0.4);
}

.duel-console-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.duel-live-score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 3px;
}

.p1-score-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.p2-score-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.6);
}

.duel-vs-pill {
  font-size: 0.68rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 208, 0, 0.15);
  border: 1px solid var(--neon-yellow);
  color: var(--neon-yellow);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.duel-tug-bar {
  width: 100%;
  max-width: 320px;
  height: 12px;
  background: #090c18;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  border: 1px solid #283358;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8);
  position: relative;
}

.duel-tug-p1 {
  background: linear-gradient(90deg, #00b4d8, #00f0ff);
  height: 100%;
  width: 50%;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.8);
}

.duel-tug-p2 {
  background: linear-gradient(90deg, #ff007f, #ff4081);
  height: 100%;
  width: 50%;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.8);
}

.duel-tug-divider {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  transform: translateX(-50%);
  opacity: 0.5;
  z-index: 2;
}

/* Custom Duel Victory Celebration Overlay */
.duel-victory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.94);
  backdrop-filter: blur(12px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.duel-victory-card {
  background: radial-gradient(circle at center, #1c223c 0%, #0e1120 100%);
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 40px rgba(255, 208, 0, 0.55);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 28px 20px;
  text-align: center;
  animation: countdownPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.duel-victory-icon {
  font-size: 4.2rem;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 18px rgba(255, 208, 0, 0.8));
  animation: float 2s infinite ease-in-out;
}

.duel-victory-title {
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--neon-yellow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.duel-victory-subtitle {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.duel-victory-score-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #141728;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 20px;
}

.duel-player-score-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.duel-player-score-tag.p1 span { font-size: 0.82rem; font-weight: 800; color: var(--neon-cyan); }
.duel-player-score-tag.p1 strong { font-size: 2.2rem; font-family: var(--font-mono); color: #fff; }

.duel-player-score-tag.p2 span { font-size: 0.82rem; font-weight: 800; color: var(--neon-pink); }
.duel-player-score-tag.p2 strong { font-size: 2.2rem; font-family: var(--font-mono); color: #fff; }

.duel-vs-text {
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--text-dim);
}

/* ==========================================================================
   RESULTS SCREEN (Mobile Fixed)
   ========================================================================== */

.results-card {
  text-align: center;
  padding: 24px 16px;
  padding-top: 24px;
}

.results-stars {
  font-size: 2.8rem;
  margin-top: 6px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  line-height: 1;
}

.results-stars span,
.results-stars .star {
  display: inline-block;
  user-select: none;
  animation: starPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  transform-origin: center center;
}

.results-stars span.gold,
.results-stars .star.gold {
  opacity: 1;
  filter: drop-shadow(0 0 14px rgba(255, 215, 0, 0.85)) drop-shadow(0 0 4px rgba(255, 240, 150, 0.9));
}

.results-stars span.dim,
.results-stars .star.dim {
  opacity: 0.2;
  filter: grayscale(100%) brightness(0.65);
}

.results-stars span:nth-child(1),
.results-stars .star:nth-child(1) {
  animation-delay: 0.12s;
}

.results-stars span:nth-child(2),
.results-stars .star:nth-child(2) {
  animation-delay: 0.28s;
}

.results-stars span:nth-child(3),
.results-stars .star:nth-child(3) {
  animation-delay: 0.44s;
}

@keyframes starPop {
  0% {
    transform: scale(0) rotate(-35deg);
  }
  70% {
    transform: scale(1.28) rotate(8deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.results-title {
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--neon-yellow);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.results-rank {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--neon-cyan);
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

@media (min-width: 580px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: #161b2e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-box .stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
}

.stat-box .stat-lbl {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.mistakes-review-box {
  background: #1e131d;
  border: 1px solid rgba(255, 42, 95, 0.3);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
  text-align: left;
}

.mistakes-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--neon-red);
  margin-bottom: 6px;
}

.mistake-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 42, 95, 0.15);
  border: 1px solid rgba(255, 42, 95, 0.4);
  padding: 4px 8px;
  border-radius: 8px;
  margin: 3px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
}

/* Action Buttons 2-Row Mobile Responsive */
.action-btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.action-sub-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.secondary-btn {
  background: #1b2038;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.secondary-btn:hover {
  background: #242b4a;
  border-color: var(--neon-cyan);
}

/* ==========================================================================
   MODALS (Mobile Scroll & Compact Tables)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--neon-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Leaderboard Mode Filter Tabs */
.leaderboard-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.lb-tab {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.lb-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lb-tab.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(255, 0, 127, 0.25));
  border-color: var(--neon-cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

/* Leaderboard Player Cell Structured Layout (Zero-Jitter Alignment) */
.lb-player-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 175px;
  max-width: 280px;
  text-align: left;
}

.lb-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.lb-rank-badge.rank-1 {
  font-size: 1.22rem;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.lb-rank-badge.rank-2 {
  font-size: 1.18rem;
  filter: drop-shadow(0 0 6px rgba(192, 192, 192, 0.5));
}

.lb-rank-badge.rank-3 {
  font-size: 1.12rem;
  filter: drop-shadow(0 0 6px rgba(205, 127, 50, 0.5));
}

.lb-rank-badge.rank-other {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
}

.lb-player-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.lb-name-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.lb-player-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

/* Player Badge Tag in Leaderboard */
.player-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 208, 0, 0.14);
  border: 1px solid rgba(255, 208, 0, 0.38);
  color: var(--neon-yellow);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  white-space: nowrap;
}

#modal-leaderboard .modal-content {
  max-width: 760px;
}

/* Leaderboard Explanatory Hint Banner */
.leaderboard-hint-banner {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.35;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.leaderboard-hint-banner .hint-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.leaderboard-hint-banner .hint-text strong {
  color: var(--neon-cyan);
}

/* Leaderboard Table Responsive Wrapper */
.records-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 4px;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  white-space: nowrap;
}

.records-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.3px;
}

.records-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-width: 480px) {
  .records-table th, .records-table td {
    padding: 7px 5px;
    font-size: 0.78rem;
  }
}

/* User Profile Modal: Create First Hierarchy */
.create-profile-top-box {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08) 0%, rgba(255, 0, 127, 0.08) 100%);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.create-profile-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.create-profile-title {
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.create-profile-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.existing-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.existing-users-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--neon-pink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.existing-users-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* User Selection Modal List */
.user-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin: 10px 0 6px;
}

.user-card-item {
  background: #191e33;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.user-card-item:hover {
  border-color: var(--neon-cyan);
  transform: translateY(-2px);
}

.user-card-item.active-user {
  border-color: var(--neon-pink);
  background: rgba(255, 0, 127, 0.2);
  box-shadow: var(--shadow-neon-pink);
}

/* Heatmap Grid */
.heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.heatmap-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  text-align: center;
}

.heatmap-cell {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-cell:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
  z-index: 2;
}

.heatmap-cell.status-unseen { background: #1b2035; color: var(--text-dim); }
.heatmap-cell.status-master { background: rgba(0, 255, 136, 0.3); border: 1px solid var(--neon-green); color: #00ff88; }
.heatmap-cell.status-learning { background: rgba(255, 208, 0, 0.25); border: 1px solid var(--neon-yellow); color: #ffd000; }
.heatmap-cell.status-struggling { background: rgba(255, 42, 95, 0.3); border: 1px solid var(--neon-red); color: #ff2a5f; }

/* Tiered Badges Container */
.badge-tier-section {
  margin-bottom: 18px;
}

.badge-tier-header {
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-bronze { color: #cd7f32; }
.tier-silver { color: #c0c0c0; }
.tier-gold { color: var(--neon-yellow); text-shadow: 0 0 8px rgba(255, 208, 0, 0.5); }
.tier-diamond { color: var(--neon-diamond); text-shadow: 0 0 12px rgba(0, 240, 255, 0.8); }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.badge-item {
  background: #171b30;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
  position: relative;
}

.badge-item.tier-diamond-card {
  border-color: rgba(0, 240, 255, 0.4);
  background: radial-gradient(circle at top, rgba(0, 240, 255, 0.1), #15192c);
}

.badge-item:hover {
  border-color: var(--neon-yellow);
  transform: translateY(-2px);
}

.badge-item.locked {
  background: #111424;
  border: 1px dashed rgba(95, 115, 160, 0.45);
}

.badge-item.locked .badge-icon {
  filter: grayscale(0.5);
  opacity: 0.75;
}

.badge-item.locked .badge-name {
  color: #e6edff;
  font-weight: 700;
}

.badge-item.locked .badge-desc {
  color: #9bb0dc;
  font-size: 0.72rem;
  line-height: 1.25;
}

.badge-item.locked .badge-reward {
  background: rgba(255, 208, 0, 0.12);
  color: var(--neon-yellow);
  opacity: 0.95;
}

.badge-item .badge-icon { font-size: 2rem; margin-bottom: 2px; }
.badge-item .badge-name { font-weight: 800; font-size: 0.82rem; color: #fff; }
.badge-item .badge-desc { font-size: 0.68rem; color: var(--text-secondary); line-height: 1.2; }
.badge-item .badge-reward {
  background: rgba(255, 208, 0, 0.15);
  color: var(--neon-yellow);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-top: 4px;
}

/* Hearthstone Dragon Badges */
.badge-dragon-img-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
  margin-bottom: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-dragon-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-item.locked .badge-dragon-img-wrap {
  filter: grayscale(0.85) opacity(0.5);
  border-color: var(--border-color);
  box-shadow: none;
}

.badge-item.badge-dragon-item {
  background: radial-gradient(circle at top, rgba(0, 240, 255, 0.09), #161b30);
  border-color: rgba(0, 240, 255, 0.35);
}

.badge-item.badge-dragon-item.locked {
  background: #111424;
  border-color: rgba(95, 115, 160, 0.35);
}

/* Dragon Leaderboard Rank Tags */
.dragon-rank-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.dragon-rank-tag.diff-easy { background: rgba(0, 255, 136, 0.15); color: var(--neon-green); border: 1px solid var(--neon-green); }
.dragon-rank-tag.diff-medium { background: rgba(255, 208, 0, 0.15); color: var(--neon-yellow); border: 1px solid var(--neon-yellow); }
.dragon-rank-tag.diff-hard { background: rgba(157, 78, 221, 0.2); color: var(--neon-purple); border: 1px solid var(--neon-purple); }
.dragon-rank-tag.diff-nightmare { background: rgba(255, 42, 95, 0.25); color: var(--neon-red); border: 1px solid var(--neon-red); }

/* Admin PIN & Player Deletion */
.user-card-item {
  position: relative;
  overflow: hidden;
}

.user-card-item.holding-admin {
  border-color: var(--neon-red) !important;
  box-shadow: 0 0 20px rgba(255, 42, 95, 0.7) !important;
  animation: adminCardPulse 0.4s infinite alternate;
}

.user-card-item .admin-hold-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--neon-red);
  width: 0%;
  transition: width 5s linear;
}

@keyframes adminCardPulse {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

.admin-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 12px 0 18px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: #101322;
  transition: all 0.18s ease;
}

.pin-dot.filled {
  border-color: var(--neon-yellow);
  background: var(--neon-yellow);
  box-shadow: 0 0 12px rgba(255, 208, 0, 0.8);
  transform: scale(1.2);
}

.admin-pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 250px;
  margin: 0 auto;
}

.pin-key {
  background: #171b30;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  padding: 12px 0;
  cursor: pointer;
  transition: all 0.12s ease;
}

.pin-key:active {
  background: var(--bg-card-hover);
  border-color: var(--neon-cyan);
  transform: scale(0.92);
}

.pin-key-empty {
  visibility: hidden;
}

.pin-key-back {
  font-size: 1.2rem;
  color: var(--neon-pink);
}

/* Avatar Grid */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0;
}

.avatar-opt {
  font-size: 1.55rem;
  background: #191e33;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.avatar-opt:hover { 
  border-color: var(--neon-cyan); 
  transform: scale(1.08);
}

.avatar-opt.selected {
  border-color: var(--neon-pink);
  background: rgba(255, 0, 127, 0.25);
  box-shadow: var(--shadow-neon-pink);
  transform: scale(1.05);
}

.input-field {
  width: 100%;
  background: #121524;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
}

.input-field:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}

.input-field.input-error {
  border-color: var(--neon-red);
  box-shadow: 0 0 14px rgba(255, 42, 95, 0.4);
  animation: wrongShake 0.35s ease;
}

/* ==========================================================================
   GAMEPLAY SCREEN FOCUS & MOBILE RESPONSIVENESS (320px - 430px)
   ========================================================================== */

/* Automatically focus screen on active gameplay: hide top-nav */
body:has(#screen-game.active) .top-nav,
body:has(#screen-duel[style*="display: flex"]) .top-nav {
  display: none !important;
}

@media (max-width: 600px) {
  .app-container {
    padding: 10px 8px;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 8px 6px;
  }
  .top-nav {
    padding: 4px 6px;
    gap: 4px;
    margin-bottom: 10px;
  }
  .profile-pill {
    padding: 2px 6px 2px 2px;
    gap: 4px;
    max-width: 55%;
  }
  .avatar-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 1rem;
  }
  .player-name {
    font-size: 0.78rem;
    max-width: 58px;
  }
  .player-coins {
    font-size: 0.64rem;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }
  .nav-actions {
    gap: 3px;
  }
  .cloud-status-pill {
    padding: 2px 6px;
    font-size: 0.62rem;
  }
  .table-grid {
    gap: 5px;
  }
  .table-btn {
    padding: 8px 2px;
    font-size: 1.1rem;
  }
  .table-btn span.label {
    font-size: 0.6rem;
  }
  .hero-title {
    font-size: 1.65rem;
  }
  .hero-subtitle {
    font-size: 0.82rem;
  }

  /* Game Screen Mobile Sizing (Large Thumb-Friendly Arcade Feel) */
  .game-hud {
    height: 44px;
    min-height: 44px;
    padding: 0 6px 0 10px;
  }
  .hud-time-wrap .hud-value,
  .hud-streak-box .hud-value,
  .hud-score-val {
    font-size: 1.1rem;
  }
  .hud-diff-tag,
  .streak-multiplier {
    font-size: 0.58rem;
    padding: 1px 4px;
  }
  .exit-hud-btn,
  .game-hud .icon-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 0.8rem;
  }

  /* Boss Arena Mobile Sizing (Full Circle 125-165px Dragon) */
  .boss-arena-stage {
    padding: 8px 10px 6px;
    min-height: 185px;
  }
  .boss-avatar-frame {
    width: clamp(120px, 19vh, 165px);
    height: clamp(120px, 19vh, 165px);
  }
  .boss-name-text {
    font-size: 0.92rem;
  }
  .boss-phase-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
  }
  .player-hearts-defense {
    font-size: 1.05rem;
  }
  .boss-hp-bar-wrap {
    height: 16px;
  }
  .boss-hp-text {
    font-size: 0.72rem;
  }

  /* Question & Controls Mobile Sizing */
  .question-stage {
    padding: 6px 10px;
    min-height: 60px;
    max-height: 76px;
  }
  .question-equation {
    font-size: clamp(2rem, 6.5vh, 3rem);
    gap: 6px;
  }
  .numpad-answer-box {
    min-width: 74px;
    height: clamp(42px, 5.2vh, 50px);
    min-height: clamp(42px, 5.2vh, 50px);
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    padding: 2px 8px;
  }
  .answers-grid {
    gap: clamp(4px, 1vh, 8px);
    max-width: 100%;
    margin-top: auto;
  }
  .answer-btn {
    min-height: clamp(44px, 6vh, 54px);
    height: clamp(44px, 6vh, 54px);
    font-size: clamp(1.35rem, 2.4vh, 1.6rem);
  }
  .numpad-container {
    max-width: 100%;
    margin-top: auto;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
  .numpad-grid {
    gap: clamp(4px, 0.8vh, 7px);
  }
  .numpad-btn {
    min-height: clamp(42px, 5.8vh, 52px);
    height: clamp(42px, 5.8vh, 52px);
    font-size: clamp(1.3rem, 2.3vh, 1.55rem);
  }
  .numpad-btn.numpad-action {
    font-size: 1.3rem;
  }
}

/* Ultra-Compact Screens (iPhone SE / 320px - 375px) */
@media (max-width: 375px) {
  .app-container {
    padding: 4px 3px;
  }
  .game-hud {
    height: 38px;
    min-height: 38px;
    padding: 0 4px 0 6px;
  }
  .hud-time-wrap .hud-value,
  .hud-streak-box .hud-value,
  .hud-score-val {
    font-size: 0.92rem;
  }
  .hud-icon,
  .hud-streak-flame,
  .hud-coin-icon {
    font-size: 0.88rem;
  }
  .exit-hud-btn,
  .game-hud .icon-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    font-size: 0.72rem;
  }
  .boss-arena-stage {
    padding: 6px 8px 4px;
    min-height: 165px;
  }
  .boss-avatar-frame {
    width: clamp(110px, 17vh, 145px);
    height: clamp(110px, 17vh, 145px);
  }
  .boss-name-text {
    font-size: 0.84rem;
  }
  .player-hearts-defense {
    font-size: 0.95rem;
  }
  .boss-hp-bar-wrap {
    height: 15px;
  }
  .boss-hp-text {
    font-size: 0.65rem;
  }
  .question-stage {
    padding: 4px 8px;
    min-height: 52px;
    max-height: 66px;
  }
  .question-equation {
    font-size: clamp(1.8rem, 6vh, 2.5rem);
    gap: 4px;
  }
  .numpad-answer-box {
    min-width: 66px;
    height: 42px;
    min-height: 42px;
    font-size: 1.55rem;
  }
  .answer-btn {
    min-height: 46px;
    height: 46px;
    font-size: 1.4rem;
  }
  .numpad-grid {
    gap: 4px;
  }
  .numpad-btn {
    min-height: clamp(38px, 5.2vh, 46px);
    height: clamp(38px, 5.2vh, 46px);
    font-size: 1.3rem;
  }
  .numpad-btn.numpad-action {
    font-size: 1.2rem;
  }
}

/* Height-Constrained Optimization (Prevents scroll on short screens like iPhone SE 667px) */
@media (max-height: 720px) and (orientation: portrait) {
  #screen-game {
    gap: 4px;
  }
  .game-hud {
    height: 38px;
    min-height: 38px;
  }
  .boss-arena-stage {
    padding: 4px 6px 3px;
    min-height: 150px;
  }
  .boss-avatar-frame {
    width: clamp(100px, 15.5vh, 135px);
    height: clamp(100px, 15.5vh, 135px);
  }
  .question-stage {
    padding: 3px 6px;
    min-height: 48px;
    max-height: 60px;
  }
  .question-equation {
    font-size: clamp(1.75rem, 5.8vh, 2.4rem);
  }
  .numpad-answer-box {
    height: 40px;
    min-height: 40px;
    min-width: 64px;
    font-size: 1.5rem;
  }
  .answers-grid {
    gap: 4px;
  }
  .answer-btn {
    min-height: clamp(42px, 6vh, 48px);
    height: clamp(42px, 6vh, 48px);
  }
  .numpad-grid {
    gap: 4px;
  }
  .numpad-btn {
    min-height: clamp(38px, 5.2vh, 46px);
    height: clamp(38px, 5.2vh, 46px);
  }
}
