:root {
  --accent-blue: #38bdf8;
  --accent-blue-dark: #0284c7;
  --accent-red: #f43f5e;
  --accent-yellow: #fbbf24;
  --glow-blue: rgba(56, 189, 248, 0.6);
  --glow-red: rgba(244, 63, 94, 0.5);
  --bg-main: #02040a;
  --panel-bg: linear-gradient(145deg, rgba(15, 23, 42, 0.85), rgba(2, 6, 23, 0.95));
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #94a3b8;
  --text-bright: #f8fafc;
  --overlay-bg: rgba(2, 4, 10, 0.6);
  --font-main: 'Inter', sans-serif;
  --font-header: 'Syne', sans-serif;
  --font-mono: 'Chakra Petch', sans-serif;
}

body.light-mode {
  --bg-main: #f1f5f9;
  --panel-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.98));
  --border-color: rgba(0, 0, 0, 0.1);
  --text-main: #475569;
  --text-bright: #0f172a;
  --overlay-bg: rgba(255, 255, 255, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
}

body,
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  /* Promote canvas to its own GPU compositing layer for smooth fullscreen rendering */
  will-change: transform;
  image-rendering: pixelated;
}

#minimap {
  width: 160px;
  height: 160px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: block;
}

@media (max-width: 768px) {
  #minimap {
    width: 100px;
    height: 100px;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--overlay-bg);
  z-index: 100;
  backdrop-filter: blur(6px);
  transition: opacity 0.4s ease;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

#ui-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.3s;
}

#ui-overlay>* {
  pointer-events: auto;
}

/* CRT/vignette overlays removed: fixed full-viewport pseudo-elements at z-index 999+
   force an extra GPU composite pass every frame in fullscreen — major perf cost.
   Visual depth is preserved by the canvas background and panel glass effects. */

.glass-panel {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 100px rgba(56, 189, 248, 0.05);
  width: 440px;
  max-width: 95%;
  backdrop-filter: blur(24px) saturate(180%);
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.glass-panel::-webkit-scrollbar,
.scrollable::-webkit-scrollbar {
  display: none;
}

.scrollable {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.glass-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
}

.title-text {
  font-family: var(--font-header);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: var(--text-bright);
  font-weight: 900;
  letter-spacing: -1px;
  text-transform: uppercase;
  width: 100%;
}

.title-text.small {
  font-size: 1.5rem;
  margin-bottom: 25px;
  letter-spacing: 2px;
}

.highlight {
  color: var(--accent-blue);
  text-shadow: 0 0 20px var(--glow-blue);
}

.tagline {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-yellow);
  margin: 10px 0 30px;
  letter-spacing: 1px;
  font-weight: 700;
}

.panel-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.top-badges {
  display: flex;
  gap: 8px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.live-badge {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.2);
}

.season-badge {
  color: var(--accent-blue);
  border-color: rgba(56, 189, 248, 0.2);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.hero-title {
  margin: 20px 0 5px;
  filter: drop-shadow(0 0 30px var(--glow-blue));
}

.compact-hints {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.hints-header {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 4px;
}

.hint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-bright);
}

.hint-item span {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.action-area {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.mode-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  width: 100%;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  padding: 12px 0;
  font-family: var(--font-mono);
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.mode-btn:last-child {
  border-right: none;
}

.mode-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 0 15px var(--glow-blue) inset;
}

.online-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 1px;
}

.pulse-btn {
  position: relative;
  overflow: hidden;
}

.pulse-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  animation: sweep 3s infinite;
}

@keyframes sweep {
  0% {
    left: -120%;
  }

  100% {
    left: 120%;
  }
}

.loading-content {
  width: 380px;
}

.progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), #10b981);
  box-shadow: 0 0 15px var(--glow-blue);
  transition: width 0.3s ease;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Show/hide based on device type */
.desktop-only { display: flex; }
.mobile-only  { display: none; }

.set-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
}

.toggle-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 4px 12px var(--glow-blue);
}

.small-btn {
  padding: 12px 24px;
  font-size: 0.9rem;
  border-radius: 12px;
  width: auto;
  min-width: 140px;
}

.primary-btn {
  background: linear-gradient(180deg, var(--accent-blue) 0%, var(--accent-blue-dark) 100%);
  color: white;
  border: none;
  padding: 18px 32px;
  border-radius: 16px;
  font-family: var(--font-header);
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  width: 100%;
  font-size: 1.1rem;
  letter-spacing: 1px;
  box-shadow: 0 10px 30px var(--glow-blue);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

@media (pointer: coarse) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }
}

.primary-btn:active {
  transform: scale(0.98);
}

.hud-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

#leaderboard {
  min-width: 200px;
  font-size: 0.85rem;
  border-color: rgba(56, 189, 248, 0.3);
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-header);
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#leaderboard ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#leaderboard li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-score {
  font-weight: 800;
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

#leaderboard.collapsed ol {
  display: none;
}

.xp-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 5px;
}

.xp-bar-fill {
  height: 100%;
  background: var(--accent-blue);
  width: 0%;
  transition: width 0.3s;
}

.top-left {
  position: absolute;
  top: 15px;
  left: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 110;
}

.top-right {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 110;
}

.top-center {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
}

.hud-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  color: var(--text-bright);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-header);
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-blue);
}

.bottom-center {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  text-align: center;
}

#joystick-wrapper {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 120px;
  height: 120px;
  z-index: 200;
}

#joystick-base {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-knob {
  width: 50px;
  height: 50px;
  background: var(--accent-blue);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--glow-blue);
}

#mobile-controls {
  position: absolute;
  bottom: 40px;
  right: 40px;
  z-index: 200;
}

.dash-trigger {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--accent-blue);
  background: rgba(56, 189, 248, 0.2);
  color: white;
  font-family: var(--font-header);
  font-weight: 900;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .bottom-center {
    width: 85%;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 30px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 15px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-box span {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  display: block;
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.4);
}

.stat-box h2 {
  font-family: var(--font-header);
  font-size: 1.5rem;
  color: var(--text-bright);
}

.border-red {
  border-color: rgba(244, 63, 94, 0.4) !important;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 100px rgba(244, 63, 94, 0.1) !important;
}

.border-red::before {
  background: linear-gradient(90deg, transparent, #f43f5e, transparent) !important;
}

.text-red {
  color: #f43f5e !important;
  text-shadow: 0 0 20px rgba(244, 63, 94, 0.5);
}

.btn-red {
  background: linear-gradient(180deg, #f43f5e 0%, #9f1239 100%) !important;
  box-shadow: 0 10px 30px rgba(244, 63, 94, 0.4) !important;
}

.btn-red:hover {
  box-shadow: 0 15px 40px rgba(244, 63, 94, 0.6) !important;
}

.currency-badge {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--accent-yellow);
  display: flex;
  align-items: center;
  gap: 5px;
}

.shop-content {
  width: 500px;
}

.shop-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.shop-tab {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 10px;
  font-family: var(--font-mono);
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.shop-tab.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 0 10px var(--glow-blue);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 25px;
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 5px;
}

.skin-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.skin-card.equipped {
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px var(--glow-blue);
}

.skin-preview {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-preview {
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-header);
  font-size: 1rem;
  color: var(--accent-yellow);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  text-align: center;
}

.skin-name {
  font-family: var(--font-header);
  font-size: 1rem;
  color: var(--text-bright);
  text-align: center;
}

.skin-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.skin-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.skin-btn.buy {
  background: rgba(251, 191, 36, 0.2);
  color: var(--accent-yellow);
  font-weight: bold;
}

.skin-btn.equip {
  background: var(--accent-blue);
  color: white;
  font-weight: bold;
}

.skin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.daily-content {
  width: min(450px, 95vw);
}

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

.daily-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 15px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0.5;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.daily-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: skewX(-20deg);
  transition: 0.5s;
}

.daily-card.active {
  opacity: 1;
  border-color: var(--accent-yellow);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.2), inset 0 0 15px rgba(251, 191, 36, 0.1);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.15) 0%, rgba(251, 191, 36, 0.02) 100%);
  transform: scale(1.05);
  z-index: 2;
}

.daily-card.active::before {
  left: 200%;
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

.daily-card.claimed {
  opacity: 0.4;
  border-color: #10b981;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
}

.daily-card .day-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94a3b8;
  letter-spacing: 1px;
}

.daily-card .reward-amt {
  font-family: var(--font-header);
  font-size: 1.3rem;
  color: var(--accent-yellow);
  text-shadow: 0 2px 10px rgba(251, 191, 36, 0.4);
}

.secondary-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-bright);
  padding: 12px 24px;
  border-radius: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mt-10 {
  margin-top: 10px;
}

#claim-daily:disabled {
  filter: grayscale(1);
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}

#claim-daily:disabled::after {
  display: none;
}

#start-screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 20px;
}

.menu-wrapper {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 30px;
  width: 100%;
  max-width: 900px;
  margin: auto 0;
}

.main-panel {
  margin: 0 !important;
  position: relative !important;
  left: auto !important;
  top: auto !important;
}

.side-panel {
  width: 320px;
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: relative !important;
  left: auto !important;
  top: auto !important;
}

@media (max-width: 850px) {
  .menu-wrapper {
    flex-direction: column;
    align-items: center;
  }
}

.start-bottom-grid {
  display: flex;
  flex-direction: column;
}

.sl-header {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-yellow);
  margin-bottom: 8px;
  text-align: center;
}

#start-leaderboard-list {
  list-style: none;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 0;
  overflow-y: auto;
  padding-right: 5px;
}

.scrollable::-webkit-scrollbar {
  width: 6px;
}

.scrollable::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.scrollable::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 4px;
}

#start-leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.sl-name {
  color: var(--text-bright);
}

.sl-coins {
  color: var(--accent-yellow);
  font-weight: bold;
  font-family: var(--font-mono);
}

.sl-you {
  border: 1px solid var(--accent-blue);
  background: rgba(56, 189, 248, 0.1) !important;
}

/* Styles for CrazyGames Profile Pictures on Leaderboard */
.sl-pfp {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-height: 700px) {
  .glass-panel {
    padding: 10px 15px;
    border-radius: 16px;
  }
  .title-text {
    font-size: 1.5rem;
  }
  .title-text.small {
    margin-bottom: 5px;
  }
  .hero-title {
    margin: 5px 0 2px;
    font-size: 1.6rem;
  }
  .tagline {
    margin: 2px 0 10px;
    font-size: 0.8rem;
  }
  .compact-hints {
    margin-bottom: 10px;
    padding: 8px;
  }
  .action-area {
    gap: 8px;
  }
  .primary-btn {
    padding: 10px 20px;
    font-size: 0.95rem;
    border-radius: 10px;
  }
  .small-btn {
    min-width: 100px;
    padding: 8px 16px;
    font-size: 0.8rem;
  }
  .mode-selector {
    border-radius: 8px;
  }
  .mode-btn {
    padding: 8px 0;
  }
  #mode-desc {
    margin: 5px 0 !important;
    font-size: 0.75rem !important;
  }
  .panel-top-bar {
    margin-bottom: 12px;
  }
}

/* ============================================================
   MOBILE RESPONSIVENESS — phones, tablets, landscape modes
   ============================================================ */

/* Fix shop panel hardcoded width breaking narrow screens */
.shop-content {
  width: min(500px, 95vw);
}

/* Start screen: single column on mobile */
@media (max-width: 768px) {
  /* ---- Start screen: scroll from top so coins/shop/settings are always reachable ---- */
  #start-screen {
    align-items: flex-start;   /* Don't center — panel top must be reachable */
    overflow-y: auto;          /* Allow scrolling if content is taller than screen */
    padding: 12px 12px 20px;   /* Breathing room top & bottom */
  }

  /* Prevent panel from stretching off-screen; let it grow naturally */
  #start-screen .glass-panel {
    width: 100%;
    max-width: 480px;
    max-height: none;          /* Remove max-height so nothing gets clipped */
    margin: 0 auto;            /* Keep centered horizontally */
  }

  .menu-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0;
    margin: 0 auto;
  }

  .main-panel {
    width: 100%;
    max-width: 480px;
  }

  /* Panels fill the safe area on notched devices */
  .overlay {
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
      env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  }

  .glass-panel {
    max-height: 92dvh;
  }

  /* Tutorial: ensure button always visible by letting panel scroll */
  #tutorial-screen .glass-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    max-height: 92dvh;
    overflow-y: auto;
  }

  #tutorial-screen h1 {
    font-size: clamp(1.2rem, 6vw, 1.8rem);
    margin-bottom: 8px;
  }

  #tutorial-screen div[style*="font-size: 1.1rem"] {
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    margin: 10px 0 !important;
  }

  #tutorial-start-btn {
    flex-shrink: 0;
    margin-top: 10px;
  }

  /* Death screen stats grid: tighter on mobile */
  .stats-grid {
    gap: 8px;
    margin: 15px 0;
  }

  .stat-box {
    padding: 10px;
  }

  .stat-box h2 {
    font-size: 1.2rem;
  }

  /* Joystick: slightly smaller on narrow phones */
  #joystick-wrapper {
    bottom: 20px;
    left: 20px;
    width: 100px;
    height: 100px;
  }

  #joystick-knob {
    width: 40px;
    height: 40px;
  }

  #mobile-controls {
    bottom: 20px;
    right: 20px;
  }

  .dash-trigger {
    width: 80px;
    height: 80px;
    font-size: 0.85rem;
  }

  /* HUD adjustments for small screens */
  .top-left {
    top: 8px;
    left: 8px;
  }

  .top-right {
    top: 8px;
    right: 8px;
  }

  .top-center {
    top: 8px;
  }

  .bottom-center {
    bottom: 10px;
    width: 75%;
  }

  /* Very small phones: hide server/season badges to save space */
  @media (max-height: 680px) {
    .top-badges { display: none; }
    .hero-title { margin: 6px 0 4px; }
    .tagline { font-size: 0.78rem; margin: 4px 0 16px; }
    .compact-hints { padding: 10px; gap: 6px; margin-bottom: 16px; }
    .hint-item { font-size: 0.82rem; }
  }
}

/* Landscape phone: ultra-compact layout */
@media (max-height: 500px) and (orientation: landscape) {
  .glass-panel {
    padding: 10px 16px;
    border-radius: 14px;
    max-height: 96dvh;
    overflow-y: auto;
  }

  .title-text {
    font-size: clamp(1rem, 4vw, 1.5rem);
    margin-bottom: 4px;
  }

  .title-text.small {
    font-size: 1rem;
    margin-bottom: 8px;
  }

  .tagline {
    font-size: 0.7rem;
    margin: 4px 0 8px;
  }

  .compact-hints {
    display: none; /* Hide long controls list in landscape to save space */
  }

  .action-area {
    gap: 6px;
  }

  .primary-btn {
    padding: 9px 18px;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  /* Tutorial screen in landscape: side-by-side content + button */
  #tutorial-screen .glass-panel {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    max-width: 95vw;
  }

  #tutorial-screen div[style*="font-size: 1.1rem"] {
    font-size: 0.78rem !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    flex: 1;
  }

  #tutorial-start-btn {
    min-width: 110px;
    white-space: nowrap;
  }

  #tutorial-screen h1 {
    display: none; /* Title takes too much space in landscape */
  }

  /* Start screen in landscape: compress vertical spacing */
  .hero-title {
    margin: 2px 0 2px;
    font-size: 1.4rem;
  }

  #mode-desc {
    height: auto !important;
    margin: 4px 0 !important;
    font-size: 0.7rem !important;
  }

  .panel-top-bar {
    margin-bottom: 8px;
  }

  /* Pause / death screen compact */
  .stats-grid {
    margin: 10px 0;
    gap: 8px;
  }

  .stat-box {
    padding: 8px;
  }

  .stat-box h2 {
    font-size: 1rem;
  }

  /* Joystick: smaller in landscape phone (less screen height) */
  #joystick-wrapper {
    bottom: 10px;
    left: 15px;
    width: 90px;
    height: 90px;
  }

  #joystick-knob {
    width: 36px;
    height: 36px;
  }

  #mobile-controls {
    bottom: 10px;
    right: 15px;
  }

  .dash-trigger {
    width: 72px;
    height: 72px;
    font-size: 0.8rem;
  }
}

/* Very small phones (iPhone SE, Galaxy A series) */
@media (max-width: 380px) {
  .glass-panel {
    padding: 14px;
    border-radius: 16px;
  }

  .primary-btn {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .shop-content {
    width: 98vw;
  }
}

/* CrazyGames Banners */
.overlay-layout-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 30px;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  box-sizing: border-box;
}

.crazygames-side-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 300px;
  height: 600px;
  max-height: 80vh;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

/* Hide side banners flanking the menu on smaller viewports */
@media (max-width: 1024px) {
  .crazygames-side-banner {
    display: none !important;
  }
}

.crazygames-banner-container-small {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 300px;
  height: 250px;
  max-width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin: 20px auto 0;
}

@media (max-width: 360px) {
  .crazygames-banner-container-small {
    width: 100%;
    height: 50px;
  }
}