:root {
  --bg: #050712;
  --text: #f3f7ff;
  --muted: #9eb2d8;
  --cyan: #00e5ff;
  --magenta: #d500f9;
  --pink: #ff2a9d;
  --gold: #ffbe26;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: #03040c;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(130, 60, 255, 0.2);
}

#lab-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.lab-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(4, 7, 20, 0.14) 0%, rgba(3, 5, 14, 0.45) 100%);
  z-index: 1;
  pointer-events: none;
}

.screen {
  position: relative;
  z-index: 2;
  flex: 1;
  display: none;
  flex-direction: column;
  padding: calc(8px + var(--safe-top)) 14px 6px;
  overflow: hidden;
}

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

/* Studio Top Header */
.menu-topbar {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
}

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

.aenrox-mark { width: 22px; height: 20px; filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.6)); }
.studio-top { font-size: 12px; font-weight: 900; letter-spacing: 2px; line-height: 1; }
.studio-bot { font-size: 7px; letter-spacing: 2.5px; color: var(--muted); }

/* Profile & Currency Row */
.profile-currency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 3px;
  border-radius: 99px;
  background: rgba(12, 18, 42, 0.78);
  border: 1px solid rgba(155, 130, 255, 0.45);
  cursor: pointer;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #3a236b, #0c1026);
  border: 1.5px solid #ff4081;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.p-name { font-size: 11px; font-weight: 800; line-height: 1.1; }
.p-lv { font-size: 9px; color: #ffbe26; font-weight: 800; }
.p-xp-bar { width: 42px; height: 4px; background: rgba(255,255,255,0.16); border-radius: 99px; margin-top: 2px; overflow: hidden; }
.p-xp-fill { height: 100%; width: 55%; background: linear-gradient(90deg, #ffbe26, #00e5ff); }

.currency-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.curr-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 99px;
  background: rgba(14, 20, 46, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.curr-plus {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-size: 12px;
  line-height: 15px;
  text-align: center;
  font-weight: 900;
}

.circle-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(155, 190, 255, 0.45);
  background: rgba(14, 22, 52, 0.8);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.24);
}

.red-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1px solid #fff;
}

/* Main Menu Logo */
.hero-logo-block {
  text-align: center;
  margin-top: 2px;
  flex-shrink: 0;
}

.crown-badge {
  font-size: 26px;
  line-height: 0.9;
  filter: drop-shadow(0 0 12px rgba(255, 190, 38, 0.8));
}

.liquid-title {
  font-size: clamp(42px, 11vw, 54px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.92;
  background: linear-gradient(135deg, #ffffff 18%, #7af3ff 56%, #ff57c8 92%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(170, 50, 255, 0.55));
}

.sort-subtitle {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #e6f2ff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
  margin-top: 2px;
}

.sort-tagline {
  font-size: 9px;
  letter-spacing: 3px;
  color: #cfe0ff;
  font-weight: 700;
  margin-top: 2px;
}

/* Menu Live Showcase Canvas */
.showcase-wrap {
  flex: 1;
  min-height: 155px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#menu-showcase-canvas {
  width: 100%;
  height: 100%;
}

/* Menu CTA & 4 Shortcuts */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  padding-bottom: 6px;
}

.play-pill-btn {
  align-self: center;
  width: 78%;
  height: 50px;
  border-radius: 99px;
  border: 2px solid rgba(255, 180, 255, 0.75);
  background: linear-gradient(90deg, #ff4fd8 0%, #8c1eff 50%, #5e35ff 100%);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(224, 64, 251, 0.65), inset 0 2px 6px rgba(255, 255, 255, 0.5);
  transition: transform 0.1s ease;
}

.play-pill-btn:active { transform: scale(0.96); }

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

.tile-btn {
  position: relative;
  height: 66px;
  border-radius: 14px;
  background: rgba(14, 22, 52, 0.76);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.tile-blue { border: 1.5px solid #38bdf8; box-shadow: 0 0 14px rgba(56, 189, 248, 0.35); }
.tile-mag { border: 1.5px solid #e040fb; box-shadow: 0 0 14px rgba(224, 64, 251, 0.35); }
.tile-cyan { border: 1.5px solid #00e5ff; box-shadow: 0 0 14px rgba(0, 229, 255, 0.35); }
.tile-indigo { border: 1.5px solid #818cf8; box-shadow: 0 0 14px rgba(129, 140, 248, 0.35); }

.tile-ico { font-size: 20px; line-height: 1; }
.tile-lbl { font-size: 8.5px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.1; text-align: center; }

.tile-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 17px;
  text-align: center;
  border: 1px solid #fff;
}

/* Bottom Nav */
.bottom-nav {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 0 10px calc(8px + var(--safe-bot));
  padding: 5px;
  border-radius: 18px;
  background: rgba(11, 16, 40, 0.9);
  border: 1px solid rgba(130, 110, 255, 0.38);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.bnav-btn.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(213, 0, 249, 0.45), rgba(110, 40, 255, 0.38));
  border-color: rgba(235, 130, 255, 0.75);
  box-shadow: 0 0 16px rgba(213, 0, 249, 0.4);
}

.bnav-ico { font-size: 16px; line-height: 1; }
.bnav-lbl { font-size: 8px; font-weight: 800; letter-spacing: 0.4px; }

/* GAMEPLAY HUD (Reference Image 2) */
.game-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 0.95;
}
.mini-crown { font-size: 11px; margin-left: 14px; }
.mini-liquid {
  font-size: 17px;
  font-weight: 900;
  font-style: italic;
  background: linear-gradient(135deg, #fff, #6ef3ff, #ff6bd6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mini-sort { font-size: 8px; font-weight: 900; letter-spacing: 2.5px; color: #dbeafe; margin-left: 6px; }

.hud-level-center {
  text-align: center;
}
.hud-level-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}
.hud-stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 14px;
  margin-top: 2px;
  border-radius: 99px;
  background: rgba(18, 14, 42, 0.78);
  border: 1px solid rgba(213, 0, 249, 0.55);
  box-shadow: 0 0 14px rgba(213, 0, 249, 0.3);
}
.star { font-size: 14px; color: rgba(255, 255, 255, 0.25); }
.star.on { color: #ffbe26; text-shadow: 0 0 8px rgba(255, 190, 38, 0.8); }

.lab-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 4px 0;
}

#game-board-canvas {
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

/* Bottom 4 Circular Powerup Buttons */
.bottom-powerups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 4px 8px calc(8px + var(--safe-bot));
  flex-shrink: 0;
}

.power-btn {
  position: relative;
  background: transparent;
  border: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.power-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(18, 22, 48, 0.82);
  border: 2px solid #c084fc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(192, 132, 252, 0.5), inset 0 0 12px rgba(255, 255, 255, 0.14);
}
.glow-cyan .power-circle { border-color: #38bdf8; box-shadow: 0 0 18px rgba(56, 189, 248, 0.55), inset 0 0 12px rgba(255, 255, 255, 0.14); }
.glow-pink .power-circle { border-color: #f472b6; box-shadow: 0 0 18px rgba(244, 114, 182, 0.55), inset 0 0 12px rgba(255, 255, 255, 0.14); }
.power-btn:active .power-circle { transform: scale(0.92); }

.power-badge {
  position: absolute;
  top: -2px;
  right: 12px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 99px;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.power-lbl { font-size: 11px; font-weight: 700; color: #eaf2ff; text-shadow: 0 1px 4px #000; }

/* Sub-screens & Modals */
.sub-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}
.sub-topbar h2 { font-size: 18px; font-weight: 900; letter-spacing: 1.5px; color: #7af3ff; }
.sub-scroll { flex: 1; overflow-y: auto; padding: 10px 2px 16px; display: flex; flex-direction: column; gap: 10px; }

.glass-card {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(12, 18, 42, 0.82);
  border: 1px solid rgba(155, 190, 255, 0.25);
}

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

.lv-tile {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px solid rgba(0, 229, 255, 0.55);
  background: rgba(15, 24, 56, 0.85);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lv-tile.locked { opacity: 0.35; border-color: rgba(255,255,255,0.12); cursor: not-allowed; }
.lv-tile small { font-size: 9px; color: #ffbe26; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(3, 5, 14, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  max-height: 85dvh;
  overflow-y: auto;
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(160deg, rgba(18, 26, 62, 0.96), rgba(9, 12, 30, 0.98));
  border: 1.5px solid rgba(213, 0, 249, 0.65);
  box-shadow: 0 0 36px rgba(213, 0, 249, 0.3);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(213, 0, 249, 0.65);
  background: linear-gradient(90deg, #ff4fd8, #8c1eff);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.modal-btn.sec { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.modal-btn.danger { background: rgba(239,68,68,0.22); border-color: rgba(239,68,68,0.65); }

.toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(14, 20, 48, 0.95);
  border: 1px solid #00e5ff;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}
