@font-face {
  font-family: "Noto Sans Bengali";
  src: url("fonts/NotoSansBengali-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --text: #14231a;
  --muted: #4d5f55;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-border: rgba(30, 70, 45, 0.25);
  --green: #1f9d55;
  --green-dark: #167a41;
  --blue: #2563c9;
  --blue-dark: #1b4fa6;
  --danger: #d6342b;
  --shadow: 0 10px 30px rgba(10, 40, 25, 0.22);
  --radius: 18px;
  --gap: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Noto Sans", sans-serif;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #a1e9ff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  color: var(--text);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* Shown until the game's scripts and 3D library have loaded */
.loading-screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  white-space: pre-line;
  color: var(--green-dark);
  z-index: 10;
}

.loading-screen .logo {
  font-size: 64px;
  animation: pulse-key 0.8s ease-in-out infinite alternate;
}

body.loading .loading-screen {
  display: flex;
}

body.loading #menu,
body.loading .toolbar {
  visibility: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid #ffbf3c;
  outline-offset: 2px;
}

.primary,
.secondary {
  min-height: 52px;
  padding: 0 28px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  transition: transform 0.1s, background 0.15s;
}

.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 0 var(--blue-dark);
}

.primary:hover {
  background: #2f72de;
}

.secondary {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--text);
}

.secondary:hover {
  background: #e7f6ec;
}

.primary:active,
.secondary:active,
.icon-button:active,
.difficulty:active {
  transform: translateY(2px);
}

/* Heads-up display */
.hud {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  padding: 10px 16px 12px;
  min-width: 170px;
  z-index: 2;
}

.hud .score {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.hud .level {
  font-weight: 700;
  color: var(--green-dark);
}

.hud .effects div {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}

.toolbar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 4;
}

.icon-button,
.chip {
  height: 46px;
  min-width: 46px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  font-size: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.chip {
  padding: 0 14px;
  font-size: 16px;
  font-weight: 600;
}

.icon-button:hover,
.chip:hover {
  background: #fff;
}

.camera-buttons {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  z-index: 2;
}

.camera-buttons .icon-button {
  height: 54px;
  min-width: 54px;
  font-size: 26px;
}

/* Messages over the board */
.danger,
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}

.danger {
  top: 34%;
  background: rgba(214, 52, 43, 0.92);
  color: #fff;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

.toast {
  top: calc(80px + env(safe-area-inset-top));
  background: rgba(20, 35, 26, 0.85);
  color: #fff;
  animation: toast-in 0.25s ease-out;
}

/* Sits above the board's center so the snake stays visible underneath */
.countdown {
  position: fixed;
  top: 26%;
  left: 50%;
  width: 130px;
  height: 130px;
  margin: -65px 0 0 -65px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 88px;
  font-weight: 800;
  z-index: 3;
  pointer-events: none;
}

.countdown.pop {
  animation: count-pop 0.7s ease-out;
}

/* Full-screen menus */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(70px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  z-index: 3;
  animation: fade-in 0.25s ease-out;
}

.overlay.dim {
  background: rgba(8, 20, 14, 0.5);
}

.dialog {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 26px;
  text-align: center;
  border-radius: var(--radius);
  color: var(--text);
}

.dialog h1,
.dialog h2,
.dialog h3,
.dialog p {
  color: inherit;
}

.dialog.compact {
  width: min(440px, 100%);
}

/* Start Menu Dialog */
.menu-dialog {
  width: min(460px, 100%);
  padding: 20px 22px 22px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.45) inset;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  display: flex;
  flex-direction: column;
  gap: 13px;
  text-align: center;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body[data-theme="night"] .menu-dialog,
body[data-theme="lava"] .menu-dialog,
body[data-theme="space"] .menu-dialog {
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

/* Leaderboard Corner Badge */
.corner-leaderboard-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.14);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  color: #b45309;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
  z-index: 5;
}

.corner-leaderboard-btn:hover {
  transform: translateY(-1.5px) scale(1.03);
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.28);
  color: #92400e;
}

.corner-leaderboard-btn:active {
  transform: translateY(0);
}

body[data-theme="night"] .corner-leaderboard-btn,
body[data-theme="lava"] .corner-leaderboard-btn,
body[data-theme="space"] .corner-leaderboard-btn {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

body[data-theme="night"] .corner-leaderboard-btn:hover,
body[data-theme="lava"] .corner-leaderboard-btn:hover,
body[data-theme="space"] .corner-leaderboard-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

/* Header & Brand (Always at the Top) */
.menu-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 14px;
  margin: 0;
  padding-right: 90px;
}

.logo-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(16, 185, 129, 0.08));
  border: 1.5px solid rgba(34, 197, 94, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px -2px rgba(34, 197, 94, 0.25);
  flex-shrink: 0;
  animation: logo-float 3s ease-in-out infinite alternate;
}

@keyframes logo-float {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-3px) scale(1.03); }
}

.logo-badge .logo {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.brand-text {
  text-align: left;
}

.brand-text h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.6px;
  line-height: 1.15;
}

.brand-text .subtitle {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
  font-weight: 500;
}

/* Mode Switcher Tabs */
.mode-switcher {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body[data-theme="night"] .mode-switcher,
body[data-theme="lava"] .mode-switcher,
body[data-theme="space"] .mode-switcher {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mode-tab .tab-icon {
  font-size: 15px;
}

.mode-tab:hover:not(.selected) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.4);
}

body[data-theme="night"] .mode-tab:hover:not(.selected),
body[data-theme="lava"] .mode-tab:hover:not(.selected),
body[data-theme="space"] .mode-tab:hover:not(.selected) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.mode-tab.selected {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

body[data-theme="night"] .mode-tab.selected,
body[data-theme="lava"] .mode-tab.selected,
body[data-theme="space"] .mode-tab.selected {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Mode Sections */
.mode-section {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* Missions Campaign List */
.missions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: -4px;
}

.missions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 255px;
  overflow-y: auto;
  padding: 2px 3px 2px 1px;
}

.missions-list::-webkit-scrollbar {
  width: 5px;
}

.missions-list::-webkit-scrollbar-track {
  background: transparent;
}

.missions-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
}

body[data-theme="night"] .missions-list::-webkit-scrollbar-thumb,
body[data-theme="lava"] .missions-list::-webkit-scrollbar-thumb,
body[data-theme="space"] .missions-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.mission-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
}

.mission-card:hover.unlocked {
  background: rgba(255, 255, 255, 0.92);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.mission-card.selected {
  background: rgba(255, 255, 255, 0.98);
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(31, 157, 85, 0.35), 0 6px 18px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.mission-card.locked {
  opacity: 0.52;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.03);
  filter: grayscale(0.7);
}

.mission-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.05);
  display: grid;
  place-items: center;
  font-size: 21px;
  flex-shrink: 0;
}

.mission-info {
  flex: 1;
  min-width: 0;
}

.mission-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mission-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.mission-badges-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mission-star-icons {
  font-size: 11px;
  letter-spacing: 1px;
  color: #f59e0b;
  line-height: 1;
}

.mission-star-goals {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
  animation: fade-in 0.2s ease-out;
}

body[data-theme="night"] .mission-star-goals,
body[data-theme="lava"] .mission-star-goals,
body[data-theme="space"] .mission-star-goals {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.star-goal {
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.3;
}

.star-goal.achieved {
  color: #b45309;
  font-weight: 700;
}

body[data-theme="night"] .star-goal.achieved,
body[data-theme="lava"] .star-goal.achieved,
body[data-theme="space"] .star-goal.achieved {
  color: #fbbf24;
}

.mission-badge.badge-completed {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.mission-badge.badge-open {
  background: rgba(34, 197, 94, 0.16);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.mission-badge.badge-locked {
  background: rgba(100, 116, 139, 0.14);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.25);
}

/* Dark Theme Missions */
body[data-theme="night"] .mission-card,
body[data-theme="lava"] .mission-card,
body[data-theme="space"] .mission-card {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

body[data-theme="night"] .mission-card:hover.unlocked,
body[data-theme="lava"] .mission-card:hover.unlocked,
body[data-theme="space"] .mission-card:hover.unlocked {
  background: rgba(255, 255, 255, 0.14);
}

body[data-theme="night"] .mission-card.selected,
body[data-theme="lava"] .mission-card.selected,
body[data-theme="space"] .mission-card.selected {
  background: rgba(255, 255, 255, 0.18);
  border-color: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
}

body[data-theme="night"] .mission-icon,
body[data-theme="lava"] .mission-icon,
body[data-theme="space"] .mission-icon {
  background: rgba(255, 255, 255, 0.1);
}

body[data-theme="night"] .mission-title,
body[data-theme="lava"] .mission-title,
body[data-theme="space"] .mission-title {
  color: #f8fafc;
}

body[data-theme="night"] .mission-desc,
body[data-theme="lava"] .mission-desc,
body[data-theme="space"] .mission-desc {
  color: #94a3b8;
}

body[data-theme="night"] .mission-badge.badge-completed,
body[data-theme="lava"] .mission-badge.badge-completed,
body[data-theme="space"] .mission-badge.badge-completed {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}

body[data-theme="night"] .mission-badge.badge-open,
body[data-theme="lava"] .mission-badge.badge-open,
body[data-theme="space"] .mission-badge.badge-open {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.45);
}

body[data-theme="night"] .mission-badge.badge-locked,
body[data-theme="lava"] .mission-badge.badge-locked,
body[data-theme="space"] .mission-badge.badge-locked {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.25);
}

/* In-game Mission Objective HUD */
.mission-hud {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
  animation: toast-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: nowrap;
}

.mission-hud-icon {
  font-size: 16px;
  animation: logo-float 2s ease-in-out infinite alternate;
}

.mission-hud-text {
  letter-spacing: 0.2px;
}

/* Menu Sections */
.menu-section {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  padding-left: 2px;
}

/* Difficulties */
.difficulties {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.difficulty {
  min-height: 52px;
  padding: 8px 6px;
  border-radius: 14px;
  border: 1.5px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

body[data-theme="night"] .difficulty,
body[data-theme="lava"] .difficulty,
body[data-theme="space"] .difficulty {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.difficulty .diff-icon {
  font-size: 17px;
  line-height: 1;
}

.difficulty .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}

.difficulty .best {
  display: none !important;
}

.difficulty:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.difficulty[data-difficulty="EASY"].selected {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border-color: #059669 !important;
  color: #fff !important;
  box-shadow: 0 6px 20px -2px rgba(16, 185, 129, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-2px);
}

.difficulty[data-difficulty="MEDIUM"].selected {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
  border-color: #d97706 !important;
  color: #fff !important;
  box-shadow: 0 6px 20px -2px rgba(245, 158, 11, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-2px);
}

.difficulty[data-difficulty="HARD"].selected {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
  border-color: #dc2626 !important;
  color: #fff !important;
  box-shadow: 0 6px 20px -2px rgba(239, 68, 68, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-2px);
}

.difficulty.selected .name {
  color: #fff !important;
}

/* Theme Selector */
.theme-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 0;
}

.theme-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 12px;
  border: 1.5px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

body[data-theme="night"] .theme-chip,
body[data-theme="lava"] .theme-chip,
body[data-theme="space"] .theme-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

.theme-chip:hover {
  transform: translateY(-1.5px);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body[data-theme="night"] .theme-chip:hover,
body[data-theme="lava"] .theme-chip:hover,
body[data-theme="space"] .theme-chip:hover {
  background: rgba(255, 255, 255, 0.12);
}

.theme-chip[data-theme-id="meadow"].selected {
  background: linear-gradient(135deg, #10b981, #047857) !important;
  border-color: #047857 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45) !important;
}

.theme-chip[data-theme-id="desert"].selected {
  background: linear-gradient(135deg, #f59e0b, #b45309) !important;
  border-color: #b45309 !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45) !important;
}

.theme-chip[data-theme-id="ice"].selected {
  background: linear-gradient(135deg, #0ea5e9, #0369a1) !important;
  border-color: #0369a1 !important;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.45) !important;
}

.theme-chip[data-theme-id="night"].selected {
  background: linear-gradient(135deg, #6366f1, #4338ca) !important;
  border-color: #4338ca !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45) !important;
}

.theme-chip[data-theme-id="lava"].selected {
  background: linear-gradient(135deg, #f97316, #c2410c) !important;
  border-color: #c2410c !important;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45) !important;
}

.theme-chip[data-theme-id="space"].selected {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
  border-color: #6d28d9 !important;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.45) !important;
}

.theme-chip.selected {
  color: #fff !important;
  transform: translateY(-1.5px) scale(1.02);
}

/* Menu Actions */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 4px;
}

.play-button {
  width: 100%;
  min-height: 52px;
  font-size: 16.5px;
  font-weight: 800;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 0 #047857, 0 12px 24px -4px rgba(16, 185, 129, 0.45);
  cursor: pointer;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.play-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: skewX(-20deg);
  transition: 0.6s ease;
}

.play-button:hover::before {
  left: 150%;
}

.play-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #047857, 0 16px 28px -4px rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #13be85 0%, #06a374 100%);
}

.play-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857, 0 6px 14px rgba(16, 185, 129, 0.35);
}

.play-button .play-arrow {
  font-size: 15px;
  transition: transform 0.2s ease;
}

.play-button:hover .play-arrow {
  transform: translateX(3px) scale(1.15);
}

.daily {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.09);
  border: 1.5px solid rgba(245, 158, 11, 0.32);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

body[data-theme="night"] .daily,
body[data-theme="lava"] .daily,
body[data-theme="space"] .daily {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}

.daily:hover {
  transform: translateY(-1.5px);
  background: rgba(245, 158, 11, 0.16);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
}

.daily:active {
  transform: translateY(1px);
}

.daily-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.daily-info {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: rgba(245, 158, 11, 0.18);
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.1px;
}

body[data-theme="night"] .daily-info,
body[data-theme="lava"] .daily-info,
body[data-theme="space"] .daily-info {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.25);
}

.guide-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 2px auto 0;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.guide-trigger-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

body[data-theme="night"] .guide-trigger-btn,
body[data-theme="lava"] .guide-trigger-btn,
body[data-theme="space"] .guide-trigger-btn {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

body[data-theme="night"] .guide-trigger-btn:hover,
body[data-theme="lava"] .guide-trigger-btn:hover,
body[data-theme="space"] .guide-trigger-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

/* How to Play Guide Modal */
.guide-dialog {
  width: min(480px, 100%);
  padding: 22px 24px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.guide-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
}

.guide-close-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.guide-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  transform: scale(1.08);
}

body[data-theme="night"] .guide-close-btn,
body[data-theme="lava"] .guide-close-btn,
body[data-theme="space"] .guide-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
}

.guide-body {
  overflow-y: auto;
  max-height: min(420px, calc(100dvh - 220px));
  padding-right: 4px;
  scrollbar-width: thin;
}

.guide-body::-webkit-scrollbar {
  width: 4px;
}
.guide-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.instructions li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  font-weight: 500;
}

body[data-theme="night"] .instructions li,
body[data-theme="lava"] .instructions li,
body[data-theme="space"] .instructions li {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.instructions li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--green);
}

.guide-play-btn {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 14px;
}

/* Online leaderboard */
.submit-form {
  margin-top: 18px;
  text-align: left;
}

.submit-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}

.submit-row {
  display: flex;
  gap: 8px;
}

.submit-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  font: inherit;
  font-size: 17px;
  user-select: text;
  -webkit-user-select: text;
}

.submit-row input:focus {
  outline: none;
  border-color: var(--blue);
}

.submit-row .primary {
  min-height: 48px;
  padding: 0 18px;
}

.submit-status {
  margin: 10px 0 0;
  font-weight: 600;
}

.submit-status.success {
  color: var(--green-dark);
}

.submit-status.error {
  color: var(--danger);
}

.top-scores h2 {
  margin-top: 18px;
}

.top-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  text-align: left;
  color: var(--text);
}

.top-list li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--text);
}

.top-list li:nth-child(odd) {
  background: rgba(0, 0, 0, 0.04);
}

.top-list li::before {
  content: counter(rank);
  min-width: 22px;
  font-weight: 800;
  color: var(--green);
}

.top-list .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}

.top-list .points {
  font-weight: 700;
  color: var(--text);
}

.board-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0 10px;
}

.board-tab {
  min-height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--panel-border);
  font-weight: 600;
}

.board-tab.selected {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
}

#leaderboardClose,
#accountClose {
  width: 100%;
  margin-top: 16px;
}

/* Accounts */
.account-chip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.playing #accountButton {
  display: none;
}

.sign-in-to-save {
  width: 100%;
  margin-top: 16px;
}

.board-tabs.two {
  grid-template-columns: repeat(2, 1fr);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
  color: var(--muted);
}

.field input {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  font: inherit;
  font-size: 17px;
  color: var(--text);
  user-select: text;
  -webkit-user-select: text;
}

.field input:focus {
  outline: none;
  border-color: var(--blue);
}

.auth-form .primary {
  width: 100%;
  margin-top: 4px;
}

.auth-form .submit-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

.account-name {
  margin: 4px 0 14px;
  font-size: 20px;
  font-weight: 700;
}

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

.stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 12px;
  background: rgba(31, 157, 85, 0.1);
  font-size: 12px;
  color: var(--muted);
}

.stats strong {
  font-size: 20px;
  color: var(--text);
}

.bests,
.history {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.bests li,
.history li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
}

.bests li:nth-child(odd),
.history li:nth-child(odd) {
  background: rgba(31, 157, 85, 0.08);
}

.history {
  max-height: 220px;
  overflow-y: auto;
  font-size: 14px;
}

#signOutButton {
  width: 100%;
  margin-top: 16px;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* First-game hints */
.tutorial {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 18px;
  background: rgba(20, 35, 26, 0.85);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  width: max-content;
  max-width: calc(100vw - 32px);
  z-index: 3;
  pointer-events: none;
  animation: toast-in 0.3s ease-out;
}

.tutorial-icon {
  font-size: 30px;
}

.tutorial-icon.swipe {
  animation: swipe-hint 1.4s ease-in-out infinite;
}

.tutorial-icon.keys {
  animation: pulse-key 1s ease-in-out infinite alternate;
}

@keyframes swipe-hint {
  0% { transform: translate(-14px, 10px); opacity: 0.4; }
  40% { opacity: 1; }
  70% { transform: translate(14px, -10px); opacity: 1; }
  100% { transform: translate(14px, -10px); opacity: 0; }
}

@keyframes pulse-key {
  to { transform: scale(1.15); }
}

.final-score {
  margin: 18px 0 4px;
  font-size: 30px;
  font-weight: 800;
}

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

.actions button {
  flex: 1;
  padding: 0 12px;
  white-space: nowrap;
}

.pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-align: center;
}

.pause-content h1 {
  color: #fff;
  font-size: 54px;
  margin: 0;
}

.pause-content .primary,
.pause-content .secondary {
  min-width: 220px;
}

.pause-content .secondary {
  color: var(--text);
}

.hint {
  margin: 0;
  opacity: 0.85;
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
}

@keyframes pulse {
  to { transform: translateX(-50%) scale(1.06); }
}

@keyframes count-pop {
  from { transform: scale(1.5); opacity: 0.3; }
  to { transform: scale(1); opacity: 1; }
}

/* ================= THEME STYLES ================= */
body {
  transition: background 0.6s ease;
}

body[data-theme="desert"] {
  --text: #2d1808;
  --muted: #735032;
  --panel: rgba(255, 246, 230, 0.9);
  --panel-border: rgba(204, 137, 51, 0.45);
  --shadow: 0 10px 30px rgba(120, 70, 20, 0.28);
  --green: #d97706;
  --green-dark: #b45309;
  --blue: #d97706;
  --blue-dark: #b45309;
}
body[data-theme="desert"] #hud {
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 6px 24px rgba(217, 119, 6, 0.25);
}
body[data-theme="desert"] .hud .score {
  color: #b45309;
  text-shadow: 0 2px 8px rgba(217, 119, 6, 0.2);
}

body[data-theme="ice"] {
  --text: #0c2333;
  --muted: #416880;
  --panel: rgba(240, 249, 255, 0.9);
  --panel-border: rgba(56, 189, 248, 0.5);
  --shadow: 0 10px 30px rgba(14, 116, 144, 0.28);
  --green: #0284c7;
  --green-dark: #0369a1;
  --blue: #0284c7;
  --blue-dark: #0369a1;
}
body[data-theme="ice"] #hud {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.3);
}
body[data-theme="ice"] .hud .score {
  color: #0284c7;
  text-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}

body[data-theme="night"] {
  --text: #e2e8f0;
  --muted: #94a3b8;
  --panel: rgba(15, 23, 42, 0.9);
  --panel-border: rgba(129, 140, 248, 0.4);
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.6);
  --green: #6366f1;
  --green-dark: #4f46e5;
  --blue: #6366f1;
  --blue-dark: #4f46e5;
}
body[data-theme="night"] #hud {
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
}
body[data-theme="night"] .hud .score {
  color: #a5b4fc;
  text-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

body[data-theme="lava"] {
  --text: #fef2f2;
  --muted: #fca5a5;
  --panel: rgba(28, 12, 10, 0.92);
  --panel-border: rgba(239, 68, 68, 0.55);
  --shadow: 0 10px 35px rgba(185, 28, 28, 0.45);
  --green: #ea580c;
  --green-dark: #c2410c;
  --blue: #dc2626;
  --blue-dark: #991b1b;
}
body[data-theme="lava"] #hud {
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: 0 6px 28px rgba(239, 68, 68, 0.4);
}
body[data-theme="lava"] .hud .score {
  color: #f97316;
  text-shadow: 0 2px 10px rgba(249, 115, 22, 0.5);
}

body[data-theme="space"] {
  --text: #f8fafc;
  --muted: #cbd5e1;
  --panel: rgba(13, 11, 33, 0.92);
  --panel-border: rgba(192, 132, 252, 0.5);
  --shadow: 0 10px 35px rgba(88, 28, 135, 0.5);
  --green: #8b5cf6;
  --green-dark: #7c3aed;
  --blue: #a855f7;
  --blue-dark: #9333ea;
}
body[data-theme="space"] #hud {
  border-color: rgba(192, 132, 252, 0.65);
  box-shadow: 0 6px 28px rgba(192, 132, 252, 0.4);
}
body[data-theme="space"] .hud .score {
  color: #c084fc;
  text-shadow: 0 2px 10px rgba(192, 132, 252, 0.45);
}

/* ================= DARK THEMES (Night, Lava, Space) VISIBILITY & CONTRAST ================= */
body[data-theme="night"],
body[data-theme="lava"],
body[data-theme="space"] {
  color: var(--text);
}

body[data-theme="night"] .dialog,
body[data-theme="lava"] .dialog,
body[data-theme="space"] .dialog {
  color: var(--text);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}

body[data-theme="night"] .dialog h1,
body[data-theme="night"] .dialog h2,
body[data-theme="night"] .dialog h3,
body[data-theme="night"] .dialog p,
body[data-theme="lava"] .dialog h1,
body[data-theme="lava"] .dialog h2,
body[data-theme="lava"] .dialog h3,
body[data-theme="lava"] .dialog p,
body[data-theme="space"] .dialog h1,
body[data-theme="space"] .dialog h2,
body[data-theme="space"] .dialog h3,
body[data-theme="space"] .dialog p {
  color: var(--text);
}

body[data-theme="night"] .dialog .muted,
body[data-theme="lava"] .dialog .muted,
body[data-theme="space"] .dialog .muted,
body[data-theme="night"] .dialog .subtitle,
body[data-theme="lava"] .dialog .subtitle,
body[data-theme="space"] .dialog .subtitle {
  color: var(--muted);
}

body[data-theme="night"] .top-list,
body[data-theme="lava"] .top-list,
body[data-theme="space"] .top-list {
  color: var(--text);
}

body[data-theme="night"] .top-list .name,
body[data-theme="night"] .top-list .points,
body[data-theme="lava"] .top-list .name,
body[data-theme="lava"] .top-list .points,
body[data-theme="space"] .top-list .name,
body[data-theme="space"] .top-list .points {
  color: var(--text);
}

body[data-theme="night"] .top-list li:nth-child(odd),
body[data-theme="lava"] .top-list li:nth-child(odd),
body[data-theme="space"] .top-list li:nth-child(odd) {
  background: rgba(255, 255, 255, 0.07);
}

body[data-theme="night"] .top-list li::before {
  color: #a5b4fc;
}

body[data-theme="lava"] .top-list li::before {
  color: #fdba74;
}

body[data-theme="space"] .top-list li::before {
  color: #c084fc;
}

body[data-theme="night"] .secondary,
body[data-theme="lava"] .secondary,
body[data-theme="space"] .secondary {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff !important;
}

body[data-theme="night"] .secondary:hover,
body[data-theme="lava"] .secondary:hover,
body[data-theme="space"] .secondary:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff !important;
}

body[data-theme="night"] .board-tab,
body[data-theme="lava"] .board-tab,
body[data-theme="space"] .board-tab {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--muted);
}

body[data-theme="night"] .board-tab.selected,
body[data-theme="lava"] .board-tab.selected,
body[data-theme="space"] .board-tab.selected {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff !important;
}

body[data-theme="night"] .field,
body[data-theme="lava"] .field,
body[data-theme="space"] .field {
  color: var(--muted);
}

body[data-theme="night"] .field input,
body[data-theme="lava"] .field input,
body[data-theme="space"] .field input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

body[data-theme="night"] .stats div,
body[data-theme="lava"] .stats div,
body[data-theme="space"] .stats div {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

body[data-theme="night"] .stats strong,
body[data-theme="lava"] .stats strong,
body[data-theme="space"] .stats strong {
  color: #ffffff;
}

body[data-theme="night"] .bests li:nth-child(odd),
body[data-theme="night"] .history li:nth-child(odd),
body[data-theme="lava"] .bests li:nth-child(odd),
body[data-theme="lava"] .history li:nth-child(odd),
body[data-theme="space"] .bests li:nth-child(odd),
body[data-theme="space"] .history li:nth-child(odd) {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

body[data-theme="night"] .icon-button:hover,
body[data-theme="night"] .chip:hover,
body[data-theme="lava"] .icon-button:hover,
body[data-theme="lava"] .chip:hover,
body[data-theme="space"] .icon-button:hover,
body[data-theme="space"] .chip:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* World Announcement Banner */
.world-card {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-25px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  background: var(--panel);
  border: 1.5px solid var(--panel-border);
  border-radius: 999px;
  box-shadow: var(--shadow), 0 0 25px rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.world-card.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.world-card-icon {
  font-size: 28px;
  line-height: 1;
}
.world-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.world-card-subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}

/* PC / Large screens: keep cards perfectly proportioned and centered */
@media (min-width: 820px) {
  .menu-dialog {
    width: 460px;
    padding: 22px 24px 24px;
  }
}

/* Mobile & Small Screens (< 520px) */
@media (max-width: 520px) {
  .overlay {
    padding: calc(52px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
  }

  .dialog {
    padding: 16px 14px 18px;
  }

  .menu-dialog {
    width: 100%;
    padding: 14px 12px 16px;
    border-radius: 20px;
    gap: 9px;
  }

  .corner-leaderboard-btn {
    top: 12px;
    right: 12px;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    gap: 4px;
  }

  .menu-header {
    gap: 10px;
    padding-right: 74px;
    margin-bottom: 0;
  }

  .logo-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .logo-badge .logo {
    font-size: 24px;
  }

  .brand-text h1 {
    font-size: 21px;
    letter-spacing: -0.4px;
  }

  .brand-text .subtitle {
    font-size: 11px;
    margin-top: 1px;
  }

  .section-label {
    font-size: 10px;
  }

  .difficulties {
    gap: 5px;
  }

  .difficulty {
    min-height: 46px;
    padding: 5px 3px;
    border-radius: 11px;
  }

  .difficulty .diff-icon {
    font-size: 14px;
  }

  .difficulty .name {
    font-size: 12px;
  }

  .theme-selector {
    gap: 5px;
  }

  .theme-chip {
    padding: 6px 3px;
    font-size: 10.5px;
    border-radius: 10px;
    gap: 4px;
  }

  .play-button {
    min-height: 46px;
    font-size: 15px;
    border-radius: 14px;
  }

  .daily {
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 11px;
  }

  .daily-title {
    font-size: 11.5px;
  }

  .daily-info {
    font-size: 9.5px;
    padding: 2px 6px;
  }

  .guide-trigger-btn {
    padding: 5px 12px;
    font-size: 11.5px;
  }

  .mode-switcher {
    padding: 3px;
    gap: 4px;
  }

  .mode-tab {
    height: 33px;
    font-size: 12px;
    gap: 5px;
  }

  .missions-list {
    max-height: 180px;
    gap: 6px;
  }

  .mission-card {
    padding: 7px 10px;
    gap: 9px;
    border-radius: 12px;
  }

  .mission-icon {
    width: 32px;
    height: 32px;
    font-size: 17px;
    border-radius: 9px;
  }

  .mission-title {
    font-size: 12px;
  }

  .mission-desc {
    font-size: 10px;
  }

  .mission-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  .mission-hud {
    top: calc(10px + env(safe-area-inset-top));
    padding: 6px 14px;
    font-size: 12px;
  }

  .hud {
    min-width: 0;
    padding: 8px 12px 10px;
  }

  .hud .score {
    font-size: 22px;
  }

  .hud .small {
    font-size: 12px;
  }

  .danger,
  .toast {
    font-size: 15px;
  }

  body.playing #languageButton {
    display: none;
  }
}

/* ==========================================================================
   1v1 APEX DUEL: COBRA VS MONGOOSE STYLES
   ========================================================================== */

.duel-header {
  text-align: center;
  margin-bottom: 16px;
}

.duel-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 4px;
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 50%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.duel-desc {
  font-size: 0.85rem;
  color: var(--color-muted, #94a3b8);
  margin: 0;
}

.duel-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.duel-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.duel-card:hover {
  border-color: rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.duel-card.highlight {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.12);
}

.duel-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.duel-card-desc {
  font-size: 0.78rem;
  color: #475569;
  margin: 0;
  line-height: 1.35;
  flex-grow: 1;
}

.duel-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.play-button.full-width {
  width: 100%;
}

.online-lobby {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.lobby-create-row button {
  width: 100%;
}

.room-active-box {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px dashed #d97706;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-code-display {
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: #b45309;
}

.room-code-display strong {
  font-size: 1.35rem;
  font-family: monospace;
}

.online-status {
  font-size: 0.78rem;
  color: #334155;
  margin: 0;
  font-style: italic;
}

.lobby-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #64748b;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.lobby-divider::before,
.lobby-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.lobby-divider span {
  padding: 0 8px;
}

.lobby-join-row {
  display: flex;
  gap: 8px;
}

.join-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: #0f172a;
  font-family: monospace;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.join-input:focus {
  outline: none;
  border-color: #f59e0b;
}

.duel-controls-guide {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  line-height: 1.5;
  color: #334155;
}

/* Dark Theme Duel Adjustments */
body[data-theme="night"] .duel-card,
body[data-theme="lava"] .duel-card,
body[data-theme="space"] .duel-card {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

body[data-theme="night"] .duel-card:hover,
body[data-theme="lava"] .duel-card:hover,
body[data-theme="space"] .duel-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

body[data-theme="night"] .duel-card.highlight,
body[data-theme="lava"] .duel-card.highlight,
body[data-theme="space"] .duel-card.highlight {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.15);
}

body[data-theme="night"] .duel-card-title,
body[data-theme="lava"] .duel-card-title,
body[data-theme="space"] .duel-card-title {
  color: #f8fafc;
}

body[data-theme="night"] .duel-card-desc,
body[data-theme="lava"] .duel-card-desc,
body[data-theme="space"] .duel-card-desc {
  color: #94a3b8;
}

body[data-theme="night"] .room-active-box,
body[data-theme="lava"] .room-active-box,
body[data-theme="space"] .room-active-box {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(245, 158, 11, 0.5);
}

body[data-theme="night"] .room-code-display,
body[data-theme="lava"] .room-code-display,
body[data-theme="space"] .room-code-display {
  color: #fbbf24;
}

body[data-theme="night"] .online-status,
body[data-theme="lava"] .online-status,
body[data-theme="space"] .online-status {
  color: #cbd5e1;
}

body[data-theme="night"] .lobby-divider::before,
body[data-theme="night"] .lobby-divider::after,
body[data-theme="lava"] .lobby-divider::before,
body[data-theme="lava"] .lobby-divider::after,
body[data-theme="space"] .lobby-divider::before,
body[data-theme="space"] .lobby-divider::after {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="night"] .join-input,
body[data-theme="lava"] .join-input,
body[data-theme="space"] .join-input {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

body[data-theme="night"] .duel-controls-guide,
body[data-theme="lava"] .duel-controls-guide,
body[data-theme="space"] .duel-controls-guide {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

/* --- In-Game 1v1 Duel HUD --- */
.duel-hud {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 840px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 100;
  pointer-events: none;
}

.fighter-card {
  flex: 1;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.cobra-card {
  border-left: 4px solid #10b981;
}

.mongoose-card {
  border-right: 4px solid #f59e0b;
}

.fighter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fighter-name {
  font-weight: 800;
  font-size: 0.9rem;
  color: #ffffff;
}

.ability-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-weight: 600;
}

.ability-badge.ready {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.5);
  animation: pulse-ready 1.5s infinite;
}

@keyframes pulse-ready {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}

.duel-meter {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  transition: width 0.1s linear;
}

.spine-fill {
  background: linear-gradient(90deg, #ef4444, #22c55e);
}

.stamina-fill {
  background: #f59e0b;
}

.toxicity-fill {
  background: linear-gradient(90deg, #a855f7, #ec4899);
}

.agility-fill {
  background: #06b6d4;
}

.duel-center {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.duel-timer {
  font-size: 1.4rem;
  font-weight: 900;
  font-family: monospace;
  color: #fbbf24;
}

.duel-score {
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
}

.duel-round {
  font-size: 0.68rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Venom Blur Fullscreen Overlay */
.venom-blur-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: radial-gradient(circle, transparent 40%, rgba(34, 197, 94, 0.4) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: venom-pulse 1.2s infinite alternate;
}

@keyframes venom-pulse {
  from { opacity: 0.6; }
  to { opacity: 0.95; }
}

/* --- Mobile Duel Touch Controls --- */
.duel-touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 110;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}

.touch-cluster {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.touch-cluster.left-cluster {
  width: 140px;
}

.touch-cluster .touch-row {
  display: flex;
  gap: 32px;
}

.touch-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.touch-btn:active {
  background: rgba(245, 158, 11, 0.85);
  transform: scale(0.92);
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, 60px);
  gap: 10px;
}

.action-btn {
  width: 60px;
  height: 60px;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}

.action-btn.strike-btn {
  background: rgba(239, 68, 68, 0.85);
  border-color: rgba(239, 68, 68, 1);
}

.action-btn.bite-btn {
  background: rgba(245, 158, 11, 0.85);
  border-color: rgba(245, 158, 11, 1);
}

.action-btn.dodge-btn {
  background: rgba(6, 182, 212, 0.85);
}

.action-btn.spit-btn {
  background: rgba(34, 197, 94, 0.85);
}

@media (max-width: 600px) {
  .duel-hud {
    width: 96vw;
    gap: 6px;
  }
  .fighter-card {
    padding: 6px 8px;
  }
  .fighter-name {
    font-size: 0.78rem;
  }
  .duel-timer {
    font-size: 1.1rem;
  }
  .stat-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Keep match instructions and essential actions available without covering the arena. */
.duel-tools { display: flex; gap: 8px; justify-content: center; margin-top: 6px; pointer-events: auto; }
.duel-state { font-size: 12px; max-width: 270px; margin: 6px auto; }
.duel-hint { display: none; position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(700px, 90vw); padding: 10px 14px; border-radius: 12px; background: rgba(20, 24, 18, .88); color: white; font-size: 13px; text-align: center; z-index: 25; pointer-events: none; }
body.playing:has(#duelHud:not(.hidden)) .duel-hint { display: block; }
.touch-btn { touch-action: none; user-select: none; -webkit-user-select: none; }
@media (pointer: coarse) { body.playing:has(#duelHud:not(.hidden)) .duel-hint { bottom: 190px; font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { .venom-blur-overlay { animation: none; } }

.duel-state { color: #e2e8f0; }
.duel-tools .chip { font-size: 12px; padding: 7px 9px; min-height: 36px; }
.duel-hud { top: calc(64px + env(safe-area-inset-top)); align-items: flex-start; }
.duel-center { max-width: 220px; }
@media (max-width: 600px) {
  .duel-hud { display: grid; grid-template-columns: 1fr 1fr; }
  .duel-center { grid-column: 1 / -1; grid-row: 2; max-width: none; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 6px 12px; padding: 5px 8px; }
  .duel-state { flex-basis: 100%; margin: 0; font-size: 11px; }
  .duel-tools { margin: 0; }
  .fighter-header { flex-wrap: wrap; gap: 4px; }
  .fighter-card { min-width: 0; }
  .duel-hint { font-size: 11px; }
}
body.playing:has(#duelHud:not(.hidden)) #countdown { top: 43%; z-index: 115; }
body.playing:has(#duelHud:not(.hidden)) #pause,
body.playing:has(#duelHud:not(.hidden)) #gameOver { z-index: 130; }
/* Compact setup: choose a mode, choose a fighter, then one primary action. */
.duel-setup-title { margin: 4px 0 20px; font-size: 22px; font-weight: 700; color: var(--text); text-align: left; }
.duel-choice { display: flex; gap: 6px; padding: 4px; border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(80,100,90,.06); }
.duel-choice button { flex: 1; padding: 10px 7px; min-height: 44px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.duel-choice button[aria-pressed="true"] { background: var(--panel); border-color: #679a82; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.duel-setup-hint, .duel-role-hint { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 12px 0 22px; }
.duel-role-hint { margin-bottom: 18px; }
#duelRoleLabel { display: block; margin-bottom: 8px; }
#duelSection .primary { background: #286149; color: white; box-shadow: none; }
#duelSection .full-width { min-height: 48px; }
.duel-join-row { display: flex; gap: 8px; margin-top: 12px; }
.duel-join-row input { min-width: 0; flex: 1; }
.duel-help { border-top: 1px solid var(--panel-border); margin-top: 22px; padding-top: 14px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.duel-help summary { cursor: pointer; font-weight: 600; }
.duel-room-code { display: block; font-size: 28px; letter-spacing: 3px; padding: 10px 0; }
#duelSection .room-actions { display: flex; gap: 8px; justify-content: center; }
.duel-tools { flex-wrap: wrap; }
#mongooseFeintBadge { display: none; }
.spine-fill, .toxicity-fill { background: #66b996; }
.toolbar .icon-button { width: auto; min-width: 48px; padding: 0 12px; font-size: 12px; }
.logo-badge, .tab-icon, .diff-icon, .play-arrow { display: none; }
.menu-header { gap: 0; }

.snake-style-field { text-align: left; }
.snake-style-field label { display: block; margin-bottom: 8px; }
#snakeStyle { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text); background: var(--panel); font: inherit; font-weight: 600; }
.snake-style-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.challenge-hud { max-width: 250px; margin-top: 8px; font-size: 13px; line-height: 1.5; }
.combo-meter { height: 4px; margin-top: 5px; border-radius: 2px; overflow: hidden; background: rgba(0,0,0,.12); }
#comboFill { height: 100%; width: 0; background: #b26c22; }
