/* ==========================================================================
   Arkanoid: Quantum Breach - High-Octane Cyberpunk Stylesheet
   Responsive Adaptive Layout for Mobile (360px) to 4K Displays (3840px)
   ========================================================================== */

:root {
  --bg-dark: #060813;
  --bg-darker: #03040a;
  --bg-card: rgba(13, 18, 36, 0.88);
  --bg-glass: rgba(9, 14, 30, 0.92);
  --border-neon: rgba(0, 240, 255, 0.3);
  --border-neon-bright: #00f0ff;
  --primary-neon: #00f0ff;
  --accent-pink: #ff007f;
  --accent-purple: #a855f7;
  --accent-gold: #ffe600;
  --accent-green: #00ff88;
  --accent-red: #ff3344;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Plus Jakarta Sans', sans-serif;
  --font-heading: 'Space Grotesk', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Ambient Synthwave Background */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-glow-1 {
  position: absolute;
  top: -20%;
  left: 20%;
  width: 60vw;
  height: 60vw;
  max-width: 800px;
  max-height: 800px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.09) 0%, rgba(0,0,0,0) 70%);
}

.ambient-glow-2 {
  position: absolute;
  bottom: -20%;
  right: 15%;
  width: 65vw;
  height: 65vw;
  max-width: 900px;
  max-height: 900px;
  background: radial-gradient(circle, rgba(255, 0, 127, 0.08) 0%, rgba(0,0,0,0) 70%);
}

/* Header & Nav */
.game-header {
  width: 100%;
  height: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
  z-index: 100;
  border-bottom: 1px solid var(--border-neon);
  background: rgba(6, 8, 19, 0.85);
  backdrop-filter: blur(12px);
  gap: 12px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-heading);
  font-size: clamp(0.95rem, 1.4vw, 1.2rem);
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary-neon), var(--accent-pink));
  color: #03040a;
  font-weight: 900;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 4px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Tactile 3D Button Component */
.btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.03) 100%), rgba(13, 18, 36, 0.85);
  border: 1px solid var(--border-neon);
  border-bottom: 2px solid rgba(0, 240, 255, 0.45);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 10, 25, 0.8), 0 5px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
  pointer-events: none;
}

.btn:hover::before {
  left: 140%;
}

.btn:hover {
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.2) 0%, rgba(0, 240, 255, 0.08) 100%), rgba(13, 18, 36, 0.95);
  border-color: var(--primary-neon);
  box-shadow: 0 4px 0 rgba(0, 20, 45, 0.9), 0 0 16px rgba(0, 240, 255, 0.4);
  transform: translateY(-2px);
  color: #ffffff;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 10, 25, 0.9), 0 0 8px rgba(0, 240, 255, 0.25);
}

.btn-primary {
  background: linear-gradient(180deg, #00d8ff 0%, #0066ff 100%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-bottom: 2px solid #0044bb;
  color: #fff;
  box-shadow: 0 4px 0 #003388, 0 6px 16px rgba(0, 198, 255, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #33e1ff 0%, #1a7bff 100%);
  border-color: #ffffff;
  box-shadow: 0 5px 0 #003388, 0 0 24px rgba(0, 240, 255, 0.7);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #003388, 0 2px 8px rgba(0, 240, 255, 0.3);
}

.btn-accent {
  background: linear-gradient(180deg, #ff1a8c 0%, #9900ee 100%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-bottom: 2px solid #660099;
  color: #fff;
  box-shadow: 0 4px 0 #550080, 0 6px 16px rgba(255, 0, 127, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-accent:hover {
  background: linear-gradient(180deg, #ff3399 0%, #aa11ff 100%);
  border-color: #ffffff;
  box-shadow: 0 5px 0 #550080, 0 0 24px rgba(255, 0, 127, 0.7);
  transform: translateY(-2px);
}

.btn-accent:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #550080, 0 2px 8px rgba(255, 0, 127, 0.3);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn.active {
  border-color: var(--accent-green);
  color: var(--accent-green);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.4);
}

/* Main Cabinet Wrapper */
.game-viewport-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  position: relative;
  z-index: 5;
  overflow: hidden;
  box-sizing: border-box;
}

/* Scalable Responsive Arcade Cabinet */
.game-cabinet {
  height: 100%;
  max-height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 800 / 735;
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.15);
  margin: 0 auto;
  box-sizing: border-box;
  overflow: hidden;
}

/* HUD Overlay Bar */
.hud-bar {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-neon);
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
  font-family: var(--font-mono);
  gap: 8px;
  flex-wrap: nowrap;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

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

.hud-label {
  font-size: clamp(0.55rem, 0.8vw, 0.68rem);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.hud-value {
  font-size: clamp(0.85rem, 1.2vw, 1.15rem);
  font-weight: 800;
  color: var(--primary-neon);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  white-space: nowrap;
}

.hud-badges-container {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.powerup-badge {
  font-size: clamp(0.65rem, 0.9vw, 0.75rem);
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6), inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4);
  animation: pulseBadge 1.8s ease-in-out infinite alternate;
  backdrop-filter: blur(4px);
  letter-spacing: 0.5px;
}

.powerup-badge.laser   { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 50%), linear-gradient(135deg, #ff0055, #cc0033); color: #fff; text-shadow: 0 1px 2px #000; }
.powerup-badge.shield  { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), transparent 50%), linear-gradient(135deg, #00ffcc, #00aa88); color: #050811; }
.powerup-badge.missile { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), transparent 50%), linear-gradient(135deg, #ffe600, #ff9900); color: #050811; }
.powerup-badge.catch   { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 50%), linear-gradient(135deg, #b026ff, #6600cc); color: #fff; text-shadow: 0 1px 2px #000; }
.powerup-badge.slow    { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 50%), linear-gradient(135deg, #8338ec, #441199); color: #fff; text-shadow: 0 1px 2px #000; }

@keyframes pulseBadge {
  0% { transform: scale(0.96); box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3); }
  100% { transform: scale(1.04); box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.8), 0 0 12px currentColor; }
}

/* Canvas Viewport Frame */
.canvas-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  background: #070a14;
  border-left: 1px solid var(--border-neon);
  border-right: 1px solid var(--border-neon);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Instructions Sub-bar */
.game-instructions-bar {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-neon);
  border-top: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 0 0 8px 8px;
  font-size: clamp(0.65rem, 0.9vw, 0.78rem);
  color: var(--text-muted);
  font-family: var(--font-mono);
  gap: 8px;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.lock-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--border-neon);
  color: var(--primary-neon);
  font-size: clamp(0.65rem, 0.85vw, 0.75rem);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.lock-status-pill:hover {
  background: rgba(0, 240, 255, 0.22);
  border-color: var(--primary-neon);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

.lock-status-pill.locked {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--accent-green);
  color: var(--accent-green);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

/* Mobile Controls */
.mobile-controls-layer {
  display: none;
  width: 100%;
  margin-top: 6px;
  justify-content: center;
}

@media (max-width: 768px), (pointer: coarse) {
  .mobile-controls-layer {
    display: flex;
  }
}

.mobile-action-btn {
  width: 100%;
  max-width: 380px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-neon), var(--accent-pink));
  color: #fff;
  border: none;
  border-radius: 22px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 1px;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
  cursor: pointer;
}

/* ==========================================================================
   Modals & Overlays Polish — Glassmorphism & Tactile Acrylic Cards
   ========================================================================== */

.game-modal {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(13, 22, 45, 0.92) 0%, rgba(4, 6, 15, 0.96) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

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

.modal-content {
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%), rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 16px;
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 0.3),
    inset 0 -2px 6px rgba(0, 0, 0, 0.5),
    0 16px 40px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(0, 240, 255, 0.15);
  transform: scale(0.92) translateY(10px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 3.8vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 1.5px;
  line-height: 1.15;
  background: linear-gradient(135deg, #00f0ff 10%, #ff007f 90%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 240, 255, 0.3));
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: clamp(0.85rem, 1.15vw, 1rem);
  line-height: 1.6;
}

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

.modal-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(4, 8, 20, 0.6);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.modal-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-stat-val {
  font-family: var(--font-mono);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(255, 230, 0, 0.5);
}

/* Level Select Modal */
.level-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  width: 100%;
}

.level-select-card {
  background: rgba(13, 18, 36, 0.9);
  border: 1px solid var(--border-neon);
  border-radius: 6px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.level-select-card:hover {
  border-color: var(--primary-neon);
  transform: translateY(-2px);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
}

.level-select-card.boss-card {
  border-color: var(--accent-pink);
  background: rgba(255, 0, 127, 0.06);
}

.lvl-num {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-neon);
}

.lvl-title {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lvl-zone {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Level Designer / Editor Modal */
.editor-modal-wrap {
  max-width: 820px !important;
  width: 95% !important;
  max-height: 90vh;
  overflow-y: auto;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-neon);
}

.editor-palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
  justify-content: center;
}

.palette-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 4px 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
}

.palette-btn.active {
  border-color: var(--primary-neon);
  box-shadow: 0 0 8px var(--primary-neon);
}

.brush-color-swatch {
  width: 13px;
  height: 13px;
  border-radius: 2px;
}

.editor-canvas-grid {
  display: grid;
  gap: 3px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-neon);
  margin: 8px 0;
}

.editor-cell {
  aspect-ratio: 4 / 2;
  border-radius: 2px;
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
}

.editor-cell:hover {
  outline: 2px solid #fff;
}

.editor-io-box {
  width: 100%;
  height: 42px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: var(--primary-neon);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 6px;
  resize: none;
}

/* ==========================================================================
   Responsive Breakpoints & Media Queries
   ========================================================================== */

/* Mobile & Small Tablet Tweaks (< 720px) */
@media (max-width: 720px) {
  .game-header {
    padding: 0 8px;
  }

  .brand-title span:not(.brand-badge) {
    font-size: 0.9rem;
  }

  /* Compact button styling on mobile */
  .btn-text-hide {
    display: none;
  }

  .header-controls .btn {
    padding: 5px 8px;
  }

  .hud-bar {
    padding: 6px 10px;
  }

  .game-instructions-bar {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .lock-status-pill {
    padding: 2px 6px;
  }
}

/* Large Displays / 4K (> 1600px) */
@media (min-width: 1600px) {
  .game-cabinet {
    max-width: min(calc(100vw - 60px), calc((100vh - 120px) * (800 / 650)), 1500px);
  }

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

  .btn {
    font-size: 0.92rem;
    padding: 8px 16px;
  }
}
