/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
  --panel-bg: rgba(255, 255, 255, 0.8);
  --glass-bg: rgba(0, 0, 0, 0.03);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-glow: rgba(0, 0, 0, 0.12);
  --glass-uncheck: rgba(32, 16, 214, 0.71);

  --primary-glow: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --accent-pink: #db2777;
  --accent-gold: #d97706;
  --accent-blue: #0284c7;
  --accent-green: #15803d;
  --accent-red: #dc2626;

  --text-primary: #0f172a;
  --text-secondary: #36455a;
  --text-dim: #94a3b8;

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Outfit', sans-serif;
}

/* Base Settings */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-main);
}

body {
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  /* overflow-y: auto; */
  position: relative;
  /* flex-direction: column;
  padding: 24px; */
}

/* Background animated glow orbs */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.06;
  pointer-events: none;
  animation: float 20s infinite ease-in-out;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: #4f46e5;
  top: -10%;
  left: -10%;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: #db2777;
  bottom: -15%;
  right: -10%;
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: #06b6d4;
  top: 40%;
  left: 30%;
  animation-delay: -10s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(50px, 30px) scale(1.1);
  }
}

/* Main Game Wrapper Container */
#game-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 800px;
  position: relative;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

@media (min-width: 481px) {
  #game-container {
    border-radius: 32px;
    height: 90vh;
  }
}

/* Screens Common Styles */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(0.96);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* Button & Interactive styles */
.btn-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--glass-glow);
  transform: translateY(-2px);
}

.btn-glass:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary-glow);
  border: none;
  color: #ffffff !important;
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #334155 0%, #475569 100%);
  box-shadow: 0 12px 28px rgba(30, 41, 59, 0.25);
  transform: translateY(-3px);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
}

/* 1. Main Menu Screen */
#screen-menu {
  justify-content: center;
  align-items: center;
  gap: 32px;
}

.menu-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.menu-logo {
  font-weight: 800;
  font-size: 3rem;
  letter-spacing: -1px;
  /* background: linear-gradient(135deg, #f8fafc 30%, #94a3b8 100%); */
  background: linear-gradient(135deg, #d8b4fe 0%, #c4b5fd 45%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: #3f3f3f4a;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-transform: uppercase;
}

.menu-logo .escape {
  background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 3.5rem;
}

.menu-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 2px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 80%;
  max-width: 280px;
}

.btn-play {
  font-size: 1.3rem;
  padding: 16px 32px;
  border-radius: 20px;
}

/* Bottom Container inside Main Menu */
.menu-bottom-container {
  position: absolute;
  bottom: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.menu-copyright {
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: auto;
}

.menu-info-wrapper {
  position: relative;
  pointer-events: auto;
}

.btn-info {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-dropdown {
  position: absolute;
  bottom: 52px;
  right: 0;
  min-width: 180px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

/* Hover on desktop */
@media (hover: hover) {
  .menu-info-wrapper:hover .info-dropdown {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
}

/* Toggle via class active for click/tap */
.info-dropdown.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.info-dropdown-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 16px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
}

.info-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--accent-blue);
  padding-left: 20px;
}

/* Mobile and small screens styling for bottom container, copyright, and info dropdown */
@media (max-width: 480px) {
  .menu-bottom-container {
    gap: 10px;
    bottom: 58px;
    left: 16px;
    right: 16px;
    align-items: center;
    justify-content: space-between;
  }
}

@keyframes btnPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.5);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(129, 140, 248, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0);
  }
}

/* Content Screen Layout */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.content-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
}

.content-scroll {
  flex: 1;
  overflow-y: hidden;
  padding-right: 4px;
  padding-top: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

@media (max-width: 1344px) {
  .content-scroll {
    overflow-y: auto;
  }
}

.content-scroll::-webkit-scrollbar {
  width: 4px;
}

.content-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.content-body {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
  user-select: text;
  -webkit-user-select: text;
}

.content-body h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 12px;
}

.content-body p {
  margin-bottom: 8px;
}

.content-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-body strong {
  color: var(--text-primary);
}

.content-body a {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.content-body a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* 2. Level Select Screen */
#screen-levels {
  justify-content: flex-start;
}

.levels-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.levels-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
}

.levels-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  padding-top: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.levels-scroll::-webkit-scrollbar {
  width: 4px;
}

.levels-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.levels-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.biome-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 16px;
  transition: var(--transition-smooth);
}

.biome-card.locked {
  opacity: 0.6;
}

.biome-card.unlocked {
  border-color: rgba(6, 182, 212, 0.25);
}

.biome-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.biome-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.biome-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.biome-level-btn {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  color: var(--text-secondary);
}

.biome-level-btn.locked {
  opacity: 0.3;
  cursor: not-allowed;
}

.biome-level-btn.unlocked:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--accent-blue);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.biome-level-btn.completed {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.05);
  color: #22c55e;
}

.biome-level-btn.highlighted {
  border-color: var(--accent-blue);
  background: rgba(6, 182, 212, 0.15);
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
  animation: pulse-highlight 1.5s infinite;
}

@keyframes pulse-highlight {
  0% {
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.2);
  }

  50% {
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.5);
  }

  100% {
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.2);
  }
}

.biome-level-btn .star-indicator {
  display: flex;
  gap: 1px;
  margin-top: 2px;
}

.biome-level-btn .star-indicator svg {
  width: 7px;
  height: 7px;
  fill: var(--text-dim);
}

.biome-level-btn.completed .star-indicator svg.active {
  fill: var(--accent-gold);
}

.biome-lock-icon {
  width: 14px;
  height: 14px;
  fill: var(--text-secondary);
}

/* 3. Game HUD (Play Screen) */
#screen-game {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.game-hud {
  padding: 16px 24px 4px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
  z-index: 10;
}

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

.hud-info {
  display: flex;
  flex-direction: column;
}

.hud-level-name {
  font-size: 1.2rem;
  font-weight: 800;
}

.hud-arrows-left {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.hud-lives {
  display: flex;
  gap: 6px;
}

.heart-icon {
  width: 24px;
  height: 24px;
  fill: var(--accent-red);
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.5));
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.heart-icon.lost {
  fill: var(--text-dim);
  filter: none;
  opacity: 0.3;
  animation: breakHeart 0.5s ease forwards;
}

@keyframes breakHeart {
  0% {
    transform: scale(1.3);
  }

  50% {
    transform: scale(0.8) rotate(-15deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

.canvas-container {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 4px 12px 12px 12px;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 480px;
  background: #ffffff;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.04);
  display: block;
}

/* Modals / Overlays Overlay System */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  width: 85%;
  max-width: 360px;
  background: #ffffff;
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.overlay.active .overlay-content {
  transform: translateY(0) scale(1);
}

/* 4. Level Completed Overlay */
.star-container {
  display: flex;
  gap: 12px;
  margin: 12px 0;
}

.star-icon {
  width: 42px;
  height: 42px;
  fill: var(--text-dim);
  transform: scale(0.7);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.overlay.active .star-icon.active {
  fill: var(--accent-gold);
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.6));
  transform: scale(1.1);
  opacity: 1;
}

.overlay.active .star-1.active {
  transition-delay: 0.2s;
}

.overlay.active .star-2.active {
  transition-delay: 0.45s;
}

.overlay.active .star-3.active {
  transition-delay: 0.7s;
}

.win-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-actions {
  display: flex;
  gap: 16px;
  width: 100%;
}

.overlay-actions button {
  flex: 1;
}

/* 5. Level Failed Overlay */
.fail-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fail-graphic {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  /* margin: 12px 0; */
}

.fail-heart {
  width: 64px;
  height: 64px;
  fill: var(--text-dim);
  opacity: 0.4;
  animation: shakeFail 1.5s infinite ease-in-out;
}

@keyframes shakeFail {

  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-5deg);
  }

  75% {
    transform: rotate(5deg);
  }
}

/* 6. Settings Panel Overlay */
.settings-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.settings-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.settings-row span {
  font-weight: 600;
  color: var(--text-primary);
}

/* Custom Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
  background: var(--glass-uncheck);
  border-color: transparent;
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* Slider Volume Control */
.volume-slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
}

.volume-slider-container .slider-label-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.volume-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: 2px solid #334155;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-reset {
  margin-top: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

.btn-reset:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--accent-red);
  transform: translateY(-2px);
}

/* Screen shake effect class */
.shake-screen {
  animation: screenShake 0.4s ease;
}

@keyframes screenShake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translate(-4px, -2px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translate(4px, 2px);
  }
}

/* SEO Content Section Styling */
.seo-content-section {
  width: 100%;
  max-width: 480px;
  margin-top: 24px;
  padding: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  margin-bottom: 40px;
  z-index: 10;
  display: block;
}

.seo-content-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--text-primary);
  user-select: text;
  -webkit-user-select: text;
}

.seo-content-container h2 {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
  text-transform: none;
  letter-spacing: normal;
}

.seo-content-container h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 8px;
}

.seo-content-container p,
.seo-content-container ul {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.seo-content-container ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: text;
  -webkit-user-select: text;
}

.seo-content-container li {
  user-select: text;
  -webkit-user-select: text;
}

.seo-content-container strong {
  color: var(--text-primary);
}

@media (min-width: 1024px) {
  /* body {
    flex-direction: row !important;
    gap: 40px;
    align-items: flex-start;
    justify-content: center;
    padding: 40px;
  } */

  .seo-content-section {
    margin-top: 0;
    max-width: 500px;
  }
}