:root {
  --bg: #060908;
  --panel: rgba(10, 20, 15, 0.9);
  --panel-border: rgba(104, 196, 136, 0.4);
  --neon: #84ffab;
  --muted: #9cb6a7;
  --danger: #ff5b6f;
  --success: #2cff89;
  --warning: #ffdf54;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 15% 15%, #12231a, transparent 30%),
    radial-gradient(circle at 90% 5%, #141d27, transparent 25%),
    linear-gradient(180deg, #040605 0%, #090d0b 100%);
  color: #eafaf0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  padding: 8px;
  overflow: hidden;
}

.menu-theme {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 18% 20%, rgba(54, 255, 160, 0.2), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(80, 160, 255, 0.2), transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(30, 60, 50, 0.6), transparent 55%),
    linear-gradient(180deg, #050805 0%, #0a100c 50%, #0e1713 100%);
}

.menu-shell {
  width: min(1100px, 96%);
  min-height: min(92vh, 780px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 24px;
  background: linear-gradient(130deg, rgba(9, 18, 14, 0.98), rgba(8, 14, 18, 0.98));
  border-radius: 28px;
  border: 1px solid rgba(120, 210, 160, 0.35);
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.55);
  padding: 28px 28px 28px 34px;
  position: relative;
  overflow: hidden;
}

.menu-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 10% 50%, rgba(132, 255, 171, 0.12), transparent 50%),
    repeating-linear-gradient(90deg, rgba(30, 50, 45, 0.3), rgba(30, 50, 45, 0.3) 2px, transparent 2px, transparent 14px);
  opacity: 0.75;
  pointer-events: none;
}

.menu-left,
.menu-right {
  position: relative;
  z-index: 1;
}

.menu-logo {
  display: flex;
  flex-direction: column;
  font-size: 52px;
  font-weight: 800;
  line-height: 0.9;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 18px;
  text-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.menu-logo-top {
  color: #8bffb4;
}

.menu-logo-mid {
  color: #e4f3ff;
}

.menu-logo-bottom {
  color: #ff7b6c;
}

.menu-badge {
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(12, 24, 20, 0.85);
  border: 1px solid rgba(132, 255, 171, 0.25);
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.menu-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, #b4ffd2, #59c98c);
  display: grid;
  place-items: center;
  font-size: 28px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.menu-badge-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #d9ffe9;
}

.menu-badge-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: #bcd2c6;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.menu-button {
  border: none;
  border-radius: 18px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  background: linear-gradient(180deg, #d74b42, #b12c2a);
  color: #fff4e5;
  box-shadow: 0 8px 0 #6f1c1b, 0 14px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.menu-button.primary {
  background: linear-gradient(180deg, #38ff9b, #16c874);
  color: #0a291a;
  box-shadow: 0 8px 0 #0b6a3a, 0 14px 24px rgba(0, 0, 0, 0.35);
}

.menu-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35), 0 18px 28px rgba(0, 0, 0, 0.4);
}

.menu-button:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4), 0 10px 22px rgba(0, 0, 0, 0.4);
}

.menu-hint {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(210, 232, 222, 0.7);
}

.menu-right {
  display: flex;
  align-items: stretch;
}

.menu-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  background: rgba(10, 18, 14, 0.92);
  border-radius: 18px;
  border: 1px solid rgba(132, 255, 171, 0.25);
  padding: 18px 18px;
  min-height: 100%;
  position: relative;
  overflow: hidden;
}

.menu-panel.is-active {
  display: flex;
}

.menu-panel-title {
  margin: 0;
  font-size: 16px;
  color: #e4f9ef;
  font-weight: 700;
}

.menu-panel-sub {
  margin: 0;
  color: #bcd2c6;
  font-size: 13px;
  line-height: 1.5;
}

.menu-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.menu-stat {
  background: rgba(132, 255, 171, 0.08);
  border: 1px solid rgba(132, 255, 171, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-stat span {
  font-size: 12px;
  color: #b8d6c5;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.menu-stat strong {
  font-size: 20px;
  color: var(--neon);
}

.menu-detail {
  margin: 0;
  color: #c9d7ce;
  line-height: 1.5;
  font-size: 14px;
}

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

.level-grid-hero {
  margin-top: 6px;
}

.level-pill {
  position: relative;
  border: 1px solid rgba(132, 255, 171, 0.3);
  border-radius: 16px;
  padding: 16px 0;
  background: linear-gradient(180deg, rgba(20, 34, 26, 0.95), rgba(10, 18, 14, 0.9));
  color: #c9d7ce;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.level-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, rgba(35, 60, 50, 0.45), rgba(35, 60, 50, 0.45) 6px, transparent 6px, transparent 12px);
  opacity: 0.35;
}

.level-pill.is-selected,
.level-pill:hover {
  border-color: rgba(132, 255, 171, 0.85);
  color: #0d2517;
  background: linear-gradient(180deg, #6bffb0, #2bd681);
  box-shadow: 0 10px 18px rgba(44, 246, 138, 0.35);
}

.menu-selected {
  margin: 0;
  color: #c9d7ce;
  font-size: 13px;
}

.menu-selected strong {
  color: var(--neon);
}

@media (max-width: 900px) {
  .menu-shell {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .menu-right {
    order: -1;
  }
}

@media (max-width: 640px) {
  .menu-shell {
    min-height: auto;
  }

  .menu-logo {
    font-size: 40px;
  }

  .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.game-shell {
  width: min(1320px, 100%);
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 12px;
  flex-shrink: 0;
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.hud span {
  color: var(--neon);
  font-weight: 700;
  font-size: 16px;
}

.health-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.health-wrap > span {
  color: #d7e8de;
  font-weight: 600;
  min-width: 56px;
  font-size: 13px;
}

.health-track {
  height: 14px;
  flex: 1;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.health-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2cff89, #8effaf);
  transition: width 0.2s ease;
}

.status-text {
  color: #ccd8d0;
  min-height: 22px;
  font-size: 13px;
  line-height: 1.3;
}

.canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(123, 201, 153, 0.3);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.35);
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 9;
  background: #0a0d0d;
  max-height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 7, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #eafaf0;
  z-index: 4;
}

.win-overlay {
  background: rgba(8, 6, 6, 0.88);
}

.complete-card {
  width: min(520px, 92%);
  background: rgba(18, 22, 24, 0.95);
  border-radius: 16px;
  padding: 22px 22px 20px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.45);
}

.win-card {
  width: min(520px, 92%);
  background: linear-gradient(135deg, #ff2b2b, #ff9a28);
  border-radius: 18px;
  padding: 24px 22px 20px;
  border: 3px solid #ffe08a;
  color: #1d0e06;
  text-align: center;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.45);
}

.win-eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(34, 12, 4, 0.8);
}

.win-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
}

.win-title-top,
.win-title-bottom {
  display: inline-block;
  padding: 8px 18px;
  font-weight: 900;
  font-size: 44px;
  letter-spacing: 2px;
  text-transform: uppercase;
  transform: skewX(-6deg);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.35);
}

.win-title-top {
  background: #111;
  color: #ffffff;
}

.win-title-bottom {
  background: #ffdf3f;
  color: #111;
}

.win-sub {
  margin: 0 0 16px;
  color: rgba(34, 12, 4, 0.85);
  font-weight: 600;
}

.win-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.menu-overlay {
  background: radial-gradient(circle at 8% 10%, rgba(80, 255, 170, 0.18), transparent 38%),
    radial-gradient(circle at 92% 18%, rgba(120, 180, 255, 0.14), transparent 42%),
    rgba(2, 6, 5, 0.9);
  padding: 20px;
}

.menu-card {
  width: min(680px, 94%);
  background: rgba(8, 16, 12, 0.93);
  border: 1px solid rgba(132, 255, 171, 0.35);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 26px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  color: rgba(140, 255, 190, 0.75);
}

.menu-header h1 {
  margin: 0;
  font-size: 30px;
  color: var(--neon);
}

.menu-sub {
  margin: 0;
  color: #c9d7ce;
  line-height: 1.5;
  font-size: 14px;
}


.overlay h1,
.overlay h2 {
  margin: 0 0 10px;
  color: var(--neon);
}

.overlay p {
  margin: 6px 0;
  color: #c8d9cf;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.level-stats {
  color: #1b1b1b;
  background: rgba(255, 255, 255, 0.82);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
}

.level-stats span {
  color: #101010;
}

#restartButton {
  margin-top: 16px;
  border: 2px solid #8effaf;
  border-radius: 8px;
  background: linear-gradient(120deg, #2cf68a, #93ffba);
  color: #103621;
  padding: 12px 24px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(44, 246, 138, 0.3);
}

#restartButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(44, 246, 138, 0.5);
  background: linear-gradient(120deg, #4cffaa, #a3ffca);
}

#restartButton:active {
  transform: translateY(0);
}

#nextLevelButton {
  margin-top: 16px;
  border: 2px solid #66b8ff;
  border-radius: 8px;
  background: linear-gradient(120deg, #4a9eff, #7fb8ff);
  color: #0f1f3c;
  padding: 12px 24px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 184, 255, 0.3);
}

#nextLevelButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 184, 255, 0.5);
  background: linear-gradient(120deg, #6aafff, #8fc8ff);
}

#nextLevelButton:active {
  transform: translateY(0);
}

#backToMenuButton,
#winBackToMenuButton {
  margin-top: 10px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: linear-gradient(180deg, #1a2026, #11161b);
  color: #e9f2ff;
  padding: 12px 24px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#backToMenuButton:hover,
#winBackToMenuButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
  background: linear-gradient(180deg, #242b33, #171d23);
}

#backToMenuButton:active,
#winBackToMenuButton:active {
  transform: translateY(0);
}

#winNextLevelButton {
  margin-top: 10px;
  border: 2px solid #23110a;
  border-radius: 999px;
  background: linear-gradient(180deg, #121618, #2c1a10);
  color: #ffe8a6;
  padding: 12px 28px;
  font-weight: 800;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#winNextLevelButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
  background: linear-gradient(180deg, #1b2024, #3a2114);
}

#winNextLevelButton:active {
  transform: translateY(0);
}

.hidden {
  display: none;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  flex-shrink: 0;
}

.controls p {
  margin: 0;
  color: #c7d6cd;
  font-size: 13px;
}

.control-keys {
  display: inline-block;
  background: rgba(132, 255, 171, 0.15);
  border: 1px solid rgba(132, 255, 171, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  margin: 0 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--neon);
}

.hint-text {
  font-size: 13px;
  opacity: 0.85;
}

@media (max-width: 860px) {
  .hud {
    grid-template-columns: 1fr;
  }

  .control-keys {
    display: inline;
  }

  .controls {
    padding: 10px 12px;
  }

  .controls p {
    font-size: 13px;
  }
}
