* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 110, 199, 0.22), transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(110, 231, 255, 0.16), transparent 45%),
    linear-gradient(160deg, #1a0830 0%, #0a0618 55%, #140820 100%);
  font-family: 'Press Start 2P', monospace;
  color: #fff8ef;
  image-rendering: pixelated;
}

#game-container {
  position: relative;
  border: 4px solid #ff6ec7;
  border-radius: 8px;
  box-shadow:
    0 0 0 4px #0a0618,
    0 0 40px rgba(255, 110, 199, 0.35),
    inset 0 0 60px rgba(0, 0, 0, 0.3);
  background: #0a0618;
}

#home-link {
  position: absolute;
  top: -28px;
  left: 0;
  font-size: 7px;
  color: #ffd166;
  text-decoration: none;
  z-index: 2;
}

#home-link:hover {
  color: #fff;
}

#fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 30;
  font-family: inherit;
  font-size: 10px;
  line-height: 1;
  padding: 8px 10px;
  color: #fff8ef;
  background: #ff6ec7;
  border: 2px solid #ffd166;
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

#fullscreen-btn:hover,
#fullscreen-btn:focus-visible {
  background: #ffd166;
  color: #1a0830;
  text-shadow: none;
}

#game-container:fullscreen,
#game-container:-webkit-full-screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #0a0618;
}

#game-container:fullscreen #game,
#game-container:-webkit-full-screen #game {
  width: min(100vw, calc(100vh * 800 / 480));
  height: min(100vh, calc(100vw * 480 / 800));
}

#game-container:fullscreen #home-link,
#game-container:-webkit-full-screen #home-link {
  display: none;
}

#game {
  display: block;
  cursor: pointer;
  touch-action: none;
}

#death-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: rgba(255, 50, 80, 0.48);
  opacity: 0;
  transition: opacity 0.12s;
}

#death-flash.on {
  opacity: 1;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud.hidden,
.overlay.hidden,
#hint-bar.hidden {
  display: none !important;
}

#progress-wrap {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 48px;
  height: 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6ec7, #ffd166, #6ee7ff);
}

#hud-meta {
  position: absolute;
  top: 24px;
  left: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#attempt-label,
#level-label,
#mode-badge {
  font-size: 7px;
  line-height: 1.4;
  color: #c4b5fd;
  background: rgba(10, 6, 18, 0.75);
  padding: 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.12);
}

#mode-badge:empty {
  display: none;
}

#mode-badge {
  color: #ffd166;
}

#pct-label {
  position: absolute;
  top: 24px;
  right: 8px;
  font-size: 11px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

#hint-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6px;
  line-height: 1.6;
  background: rgba(10, 6, 18, 0.82);
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  max-width: 94%;
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 20%, rgba(255, 80, 180, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 55% at 85% 75%, rgba(80, 220, 255, 0.2), transparent 50%),
    linear-gradient(160deg, #1a0830 0%, #0d1028 50%, #180a20 100%);
  animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(40deg); }
}

.menu-content {
  position: relative;
  z-index: 1;
  max-width: 520px;
  width: 92%;
  text-align: center;
  padding: 12px 0 8px;
}

.cube-preview {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border: 3px solid #fff;
  background: conic-gradient(from 0deg, #ff6ec7, #ffd166, #6ee7ff, #b794f6, #4ade80, #ff6ec7);
  animation: cubeSpin 2.2s linear infinite;
  box-shadow: 0 0 18px rgba(255, 110, 199, 0.5);
}

@keyframes cubeSpin {
  to { transform: rotate(360deg); }
}

.brand {
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ff6ec7, #ffd166, #6ee7ff, #b794f6, #ff6ec7);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbowText 4s linear infinite;
  margin-bottom: 8px;
  text-shadow: none;
}

.win-brand {
  font-size: 14px;
}

@keyframes rainbowText {
  to { background-position: 200% center; }
}

.subtitle {
  font-size: 8px;
  letter-spacing: 2px;
  color: #c4b5fd;
  margin-bottom: 10px;
}

.tagline {
  font-size: 7px;
  line-height: 1.8;
  color: #d8c8f8;
  margin-bottom: 14px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  text-align: left;
}

.level-card {
  font-family: inherit;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  background: rgba(20, 12, 32, 0.7);
  color: #fff8ef;
  text-align: left;
}

.level-card:hover:not(:disabled) {
  border-color: #ffd166;
  transform: translateY(-1px);
}

.level-card.selected {
  border-color: #6ee7ff;
  background: rgba(110, 231, 255, 0.12);
}

.level-card:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.level-card .num {
  font-size: 8px;
  color: #ffd166;
  display: block;
  margin-bottom: 6px;
}

.level-card .name {
  font-size: 7px;
  line-height: 1.5;
}

.level-card .diff {
  font-size: 6px;
  color: #a898c8;
  margin-top: 6px;
  line-height: 1.5;
}

.level-card .lock-tag {
  font-size: 6px;
  color: #ff9de0;
  margin-top: 6px;
  line-height: 1.5;
}

.controls-line {
  font-size: 6px;
  color: #b8a8d8;
  margin-bottom: 12px;
  line-height: 1.7;
}

.controls-line span {
  color: #ffd166;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.cta {
  font-family: inherit;
  font-size: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: linear-gradient(135deg, #ff6ec7, #6ee7ff);
  color: #1a0830;
}

.cta:hover {
  filter: brightness(1.08);
}

.cta.secondary {
  background: transparent;
  color: #fff8ef;
  border: 2px solid rgba(255, 255, 255, 0.28);
}

#controls-help {
  margin-top: 14px;
  text-align: center;
  font-size: 6px;
  color: #c4b5fd;
  line-height: 1.8;
}

#controls-help kbd {
  background: #2a1448;
  padding: 2px 4px;
  border-radius: 2px;
  border: 1px solid #ff6ec7;
}

@media (max-width: 840px) {
  #game {
    width: 100%;
    max-width: 800px;
    height: auto;
  }
}
