/* Noe's Energy Surge - Game Stylesheet */

@font-face {
  font-family: 'HKGrotesk';
  src: url('../fonts/hkgrotesk/HKGrotesk-Regular.otf') format('opentype');
  font-weight: normal;
}

@font-face {
  font-family: 'HKGrotesk-Bold';
  src: url('../fonts/hkgrotesk/HKGrotesk-Bold.otf') format('opentype');
  font-weight: bold;
}

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

html {
  overflow: hidden;
}

body {
  background-color: black;
  color: #e0e6ed;
  font-family: 'HKGrotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 15px;
}

/* Header & Controls */
.game-header {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 15px;
  margin-bottom: 12px;
  padding: 0 5px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  color: white;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.2s ease, color 0.2s ease;
  border: 1px solid white;
  padding: 5px 12px;
  border-radius: 20px;
}

.back-link:hover {
  color: #ffffff;
  background: black;
  transform: translateX(-3px);
  box-shadow: 0 0 10px black;
}

.game-title {
  font-family: 'HKGrotesk-Bold', sans-serif;
  font-size: 1.4rem;
  color: white;
  letter-spacing: 1px;
}

.toggles-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 15px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: white;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: black;
  transition: 0.3s;
  border-radius: 22px;
  border: 1px solid white;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #cbd5e0;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #f857e7;
  box-shadow: 0 0 8px rgba(248, 87, 231, 0.5);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

/* CRT Cabinet Container */
.crt-cabinet {
  position: relative;
  width: 100%;
  max-width: 900px;
  background: black;
  border: 3px solid white;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* HUD Header */
.hud-bar {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  align-items: center;
  gap: 15px;
  background: black;
  padding: 10px 20px;
  border-bottom: 2px solid black;
  font-size: 0.9rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: white;
  letter-spacing: 1px;
  font-weight: bold;
}

.hud-value {
  font-family: 'HKGrotesk-Bold', monospace;
  font-size: 1.1rem;
  color: #ffffff;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.energy-container {
  width: 100%;
  height: 16px;
  background: #0d0f17;
  border-radius: 8px;
  border: 1px solid #2d3748;
  overflow: hidden;
  position: relative;
}

.energy-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #39ffba, #00ddff);
  box-shadow: 0 0 10px #39ffba;
  transition: width 0.2s ease-out, background 0.3s ease;
  border-radius: 8px;
}

.energy-fill.warning {
  background: linear-gradient(90deg, #ffb839, #ff7a00);
  box-shadow: 0 0 10px #ffb839;
}

.energy-fill.critical {
  background: linear-gradient(90deg, #ff3b5c, #ff0044);
  box-shadow: 0 0 12px #ff3b5c;
  animation: pulse-critical 0.6s infinite alternate;
}

@keyframes pulse-critical {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* Canvas Viewport */
.viewport-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #080910;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

/* CRT Screen Overlays */
.crt-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 20;
}

.crt-overlay.scanlines.vignette {
  opacity: 1;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.18),
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(
      circle at center,
      transparent 65%,
      rgba(0, 0, 0, 0.6) 100%
    );
}

.crt-overlay.crt-flicker-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  animation: crt-flicker-anim 0.15s infinite alternate;
  background: rgba(255, 255, 255, 0.05);
}

.scanlines {
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.18),
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.8;
}

.vignette {
  background: radial-gradient(
    circle at center,
    transparent 65%,
    rgba(0, 0, 0, 0.6) 100%
  );
}

.crt-flicker-overlay {
  background: none;
}

@keyframes crt-flicker-anim {
  0% { opacity: 0.02; }
  100% { opacity: 0.05; }
}

/* Overlay Menus / Modals */
.modal-screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 9, 16, 0.88);
  backdrop-filter: blur(6px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 15px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  font-family: 'HKGrotesk-Bold', sans-serif;
  font-size: 2.2rem;
  color: #39ffba;
  text-shadow: 0 0 15px rgba(57, 255, 186, 0.7);
}

.modal-subtitle {
  font-size: 1.05rem;
  color: #a0aec0;
  max-width: 500px;
  line-height: 1.5;
}

.btn-primary {
  background: linear-gradient(135deg, #39ffba, #00ddff);
  color: #080910;
  font-family: 'HKGrotesk-Bold', sans-serif;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 12px 36px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(57, 255, 186, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-top: 10px;
}

.btn-primary:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(57, 255, 186, 0.8);
}

.btn-primary:active {
  transform: scale(0.98);
}

.controls-hint {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: white;
}

.key-badge {
  background: #1a1d2e;
  border: 1px solid #2d3748;
  color: #39ffba;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
}

/* Stats Summary */
.stats-summary {
  background: rgba(26, 29, 46, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 15px 25px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 30px;
  text-align: left;
  margin: 10px 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.stat-label { color: #a0aec0; }
.stat-val { color: #ffffff; font-weight: bold; font-family: monospace; }

/* Responsive adjustments */
@media (max-width: 650px) {
  .game-header {
    justify-content: center;
    text-align: center;
  }

  .brand-section {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .hud-bar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 8px 12px;
  }

  .game-title {
    font-size: 1.1rem;
  }

  .modal-title {
    font-size: 1.6rem;
  }

  .modal-subtitle {
    font-size: 0.95rem;
  }

  .controls-hint {
    flex-direction: column;
    gap: 8px;
  }

  .stats-summary {
    grid-template-columns: 1fr;
    padding: 12px 18px;
  }
}

/* Small phones */
@media (max-width: 420px) {
  body {
    padding: 8px;
  }

  .game-header {
    margin-bottom: 8px;
  }

  .back-link {
    font-size: 0.8rem;
    padding: 4px 10px;
  }

  .game-title {
    font-size: 0.95rem;
  }

  .toggle-item {
    font-size: 0.75rem;
    gap: 6px;
  }

  .toggle-switch {
    width: 36px;
    height: 20px;
  }

  .slider:before {
    height: 14px;
    width: 14px;
  }

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

  .hud-value {
    font-size: 0.95rem;
  }

  .modal-screen {
    padding: 14px;
    gap: 10px;
  }

  .modal-title {
    font-size: 1.3rem;
  }

  .modal-subtitle {
    font-size: 0.85rem;
    line-height: 1.4;
  }

  .btn-primary {
    font-size: 0.95rem;
    padding: 10px 26px;
  }

  .key-badge {
    font-size: 0.8rem;
  }
}

/* Short / landscape viewports (limited vertical space) */
@media (max-height: 480px) {
  body {
    padding: 8px;
  }

  .game-header {
    margin-bottom: 6px;
  }

  .viewport-wrapper {
    aspect-ratio: 16 / 7;
  }

  .modal-title {
    font-size: 1.3rem;
  }

  .modal-subtitle {
    font-size: 0.85rem;
  }

  .modal-screen {
    padding: 10px;
    gap: 8px;
  }

  .controls-hint {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    font-size: 0.75rem;
  }

  .stats-summary {
    padding: 10px 16px;
    gap: 6px 20px;
  }
}

/* Taller portrait phones: give the play field more vertical room */
@media (max-width: 650px) and (orientation: portrait) {
  .viewport-wrapper {
    aspect-ratio: 3 / 4;
  }
}
