/* ------------------------------------------------------------------ *
 * Menu screens
 *
 * `.menu-screen` is the ONLY scroll container for a screen. Nested
 * `overflow` scrollers were the reason how-to-play / level-select could
 * not be scrolled on phones — the outer flex+overflow box clipped the
 * content above the scroll origin, so there was nothing to scroll to.
 * ------------------------------------------------------------------ */
.menu-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.menu-screen.active {
  opacity: 1;
  pointer-events: all;
}

/* `margin: auto` centres the block while still allowing it to overflow in a
   scrollable flex container (the classic `justify-content: center` trap). */
.menu-content {
  position: relative;
  z-index: 1;
  margin: auto;
  text-align: center;
  max-width: 600px;
  width: 100%;
  overflow: visible;
  touch-action: pan-y;
}

.menu-content > * {
  max-width: 100%;
}

.game-title {
  font-size: clamp(1.5rem, 6.2vw, 3rem);
  font-weight: 900;
  color: #c0d0e0;
  line-height: 1.1;
  letter-spacing: clamp(2px, 1.2vw, 6px);
  text-transform: uppercase;
  margin: 0;
}

.title-highlight {
  color: #00ccff;
  text-shadow: 0 0 30px rgba(0, 200, 255, 0.4);
}

.title-tagline {
  font-size: clamp(8px, 2.4vw, 12px);
  color: rgba(0, 200, 255, 0.5);
  letter-spacing: clamp(3px, 1.4vw, 8px);
  margin-top: 12px;
  text-transform: uppercase;
}

.menu-logo {
  margin-bottom: clamp(18px, 4vh, 40px);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6vh, 12px);
  align-items: center;
}

.menu-btn {
  background: rgba(0, 200, 255, 0.06);
  border: 1px solid rgba(0, 200, 255, 0.2);
  color: #a0c0d0;
  padding: 14px 32px;
  font-size: clamp(12px, 3.2vw, 14px);
  text-transform: uppercase;
  letter-spacing: clamp(1.5px, 0.8vw, 3px);
  cursor: pointer;
  border-radius: 4px;
  min-width: min(280px, 86vw);
  max-width: 100%;
  min-height: 48px;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
  font-family: inherit;
  outline: none;
  /* Allow the tap to begin a vertical scroll so long lists stay swipeable,
     while still removing the 300ms double-tap-zoom delay. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  -webkit-user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.2;
  white-space: nowrap;
}

#btn-fullscreen .fs-icon {
  font-size: 1.1em;
  line-height: 1;
}

#btn-fullscreen .fs-label {
  line-height: 1;
}

.menu-btn:hover {
  background: rgba(0, 200, 255, 0.12);
  border-color: rgba(0, 200, 255, 0.4);
  color: #00ccff;
  transform: translateY(-1px);
}

.menu-btn:focus {
  outline: 2px solid rgba(255, 204, 68, 0.9);
  outline-offset: 2px;
  border-color: rgba(255, 204, 68, 0.7);
  color: #ffcc44;
}

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

.primary-btn {
  background: rgba(0, 200, 255, 0.15);
  border-color: rgba(0, 200, 255, 0.5);
  color: #00ccff;
}

.danger-btn {
  border-color: rgba(255, 50, 70, 0.3);
  color: rgba(255, 80, 100, 0.7);
}

.danger-btn:hover {
  border-color: rgba(255, 50, 70, 0.6);
  color: #ff4466;
  background: rgba(255, 50, 70, 0.1);
}

.menu-footer {
  font-size: clamp(9px, 2.4vw, 11px);
  color: rgba(160, 176, 192, 0.3);
  margin-top: clamp(14px, 3vh, 30px);
  letter-spacing: 1px;
}

.section-title {
  font-size: clamp(1.1rem, 4.6vw, 1.5rem);
  color: #00ccff;
  text-transform: uppercase;
  letter-spacing: clamp(2px, 1.2vw, 6px);
  margin-bottom: clamp(12px, 2.5vh, 24px);
  font-weight: 600;
}

.back-btn {
  min-width: 160px;
  margin-top: 20px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: clamp(5px, 1.4vw, 8px);
  margin: 0 auto 20px;
  max-width: 560px;
  padding: 4px;
  touch-action: pan-y;
}

.level-tile {
  aspect-ratio: 1;
  background: rgba(0, 200, 255, 0.04);
  border: 1px solid rgba(0, 200, 255, 0.12);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: clamp(12px, 3.2vw, 14px);
  color: rgba(160, 176, 192, 0.5);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
  padding: 0;
}

.level-tile[disabled] {
  cursor: default;
  opacity: 0.55;
}

.level-tile.unlocked {
  color: #00ccff;
  border-color: rgba(0, 200, 255, 0.3);
  cursor: pointer;
}

.level-tile.unlocked:hover {
  background: rgba(0, 200, 255, 0.12);
  border-color: rgba(0, 200, 255, 0.5);
}

.level-tile:focus {
  outline: 2px solid rgba(255, 204, 68, 0.9);
  outline-offset: 2px;
  background: rgba(0, 200, 255, 0.15);
}

.level-tile.completed {
  color: rgba(0, 255, 136, 0.5);
  border-color: rgba(0, 255, 136, 0.2);
}

.level-tile.current {
  border-color: #00ccff;
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.2);
}

.settings-list {
  max-width: 400px;
  margin: 0 auto;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 200, 255, 0.06);
}

.setting-row > span {
  font-size: clamp(11px, 3vw, 13px);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
}

.toggle-btn {
  background: rgba(0, 200, 255, 0.06);
  border: 1px solid rgba(0, 200, 255, 0.2);
  color: #a0c0d0;
  padding: 8px 20px;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  min-width: 64px;
  min-height: 44px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  -webkit-user-select: none;
  flex: 0 0 auto;
}

.toggle-btn.active {
  background: rgba(0, 200, 255, 0.15);
  border-color: rgba(0, 200, 255, 0.5);
  color: #00ccff;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.6vw, 12px);
  margin-bottom: 20px;
}

.instruction-card {
  background: rgba(0, 200, 255, 0.03);
  border: 1px solid rgba(0, 200, 255, 0.08);
  border-radius: 6px;
  padding: clamp(10px, 2.4vw, 16px);
  text-align: left;
}

.instruction-card h3 {
  color: #00ccff;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 6px 0;
}

.instruction-card p {
  font-size: clamp(11px, 2.8vw, 12px);
  color: rgba(160, 180, 200, 0.7);
  line-height: 1.5;
  margin: 0;
}

.instruction-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.complete-icon,
.gameover-icon,
.victory-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.complete-title {
  color: #00ff88;
  font-size: 1.4rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0 0 8px 0;
}

.complete-level {
  color: rgba(0, 255, 136, 0.5);
  font-size: 14px;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

.complete-rewards {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 12px;
}

.reward {
  font-size: 13px;
  color: rgba(200, 210, 220, 0.6);
}

.reward-label {
  color: #ffcc00;
  font-weight: bold;
}

.complete-location {
  font-size: 11px;
  color: rgba(0, 200, 255, 0.4);
  letter-spacing: 2px;
  margin-bottom: 20px;
}

.gameover-icon {
  color: #ff3344;
}

.gameover-title {
  color: #ff3344;
  font-size: 1.4rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.gameover-text {
  color: rgba(255, 100, 120, 0.6);
  font-size: 13px;
  margin-bottom: 20px;
}

.victory-decoration {
  color: rgba(0, 200, 255, 0.2);
  letter-spacing: 4px;
  font-size: 12px;
}

.victory-icon {
  color: #ffcc00;
  font-size: 64px;
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
}

.victory-title {
  color: #00ccff;
  font-size: 2rem;
  letter-spacing: 6px;
  margin: 12px 0 4px 0;
}

.victory-subtitle {
  color: rgba(0, 200, 255, 0.5);
  font-size: 14px;
  letter-spacing: 6px;
  margin-bottom: 20px;
}

.victory-stats {
  margin: 16px 0;
}

.victory-stat {
  font-size: 13px;
  color: rgba(200, 210, 220, 0.6);
  margin: 6px 0;
  letter-spacing: 2px;
}
