/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
}

:root {
  --color-bg: #030310;
  --color-primary: #00f0ff;      /* Cyan */
  --color-secondary: #bd00ff;    /* Purple */
  --color-accent: #ff007a;       /* Pink */
  --color-success: #39ff14;      /* Neon Green */
  --color-danger: #ff3131;       /* Neon Red */
  --color-surface: #0a0a20;
  --color-surface-border: #1a1a40;
  --color-text: #e2e8f0;
  --color-text-muted: #64748b;
  --font-title: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Starfield Background Canvas */
#stars-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* App Wrapper & Responsive 9:16 Viewport */
#app-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  /* Lock to strict 9:16 aspect ratio on desktop, occupying full viewport height */
  height: calc(min(100vh, 100vw * 16 / 9));
  width: calc(min(100vh, 100vw * 16 / 9) * 9 / 16);
  max-width: calc(100vh * 9 / 16);
  max-height: 100vh;
  background: rgba(4, 4, 16, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid var(--color-surface-border);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.15), inset 0 0 20px rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, backdrop-filter 0.3s ease;
}

#game-container.show-bg {
  background: rgba(4, 4, 16, 0.25);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.08), inset 0 0 20px rgba(0, 0, 0, 0.9);
}

/* Fullscreen on Mobile devices with bottom margin spacing */
@media ((max-width: 480px) or (max-height: 720px)) and (orientation: portrait) {
  #app-wrapper {
    align-items: flex-start; /* align container to top */
  }
  #game-container {
    width: 100vw;
    height: calc(100vh - 36px); /* leave room for bottom margin spacing */
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    margin-bottom: 36px; /* 36px margin at the bottom of mobile screen */
  }
}

/* Generic Screen Layouts */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 2;
}

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

.screen.hidden {
  display: none !important;
}

.screen-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-surface-border);
  padding-bottom: 12px;
}

.screen-header h2 {
  font-family: var(--font-title);
  font-size: 20px;
  color: var(--color-primary);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  letter-spacing: 2px;
  flex-grow: 1;
  text-align: center;
  margin-right: 32px; /* balance out the back button */
}

/* Back Button styling */
.btn-back {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: transform 0.2s, text-shadow 0.2s;
}

.btn-back:hover {
  transform: translateX(-4px);
  text-shadow: 0 0 10px var(--color-primary);
}

/* General Button Styles */
.btn {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 1.5px;
  padding: 16px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(1px) scale(0.97);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.svg-icon,
.btn-icon-img {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
}

/* Specific size adjustments for visual balance */
#btn-level-select {
  padding-top: 4px;
  padding-bottom: 4px;
}
#btn-level-select .btn-icon-img {
  width: 55px;
  height: 55px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #00a8ff);
  color: #030310;
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.4);
  font-weight: 900;
}

.btn-primary:hover {
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.7);
  background: linear-gradient(135deg, #33f3ff, #00f0ff);
}

.btn-primary:hover .btn-icon {
  animation: bouncePlay 0.6s infinite alternate;
}

.btn-primary:hover .btn-icon-img {
  filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.4)) brightness(1.1);
}

@keyframes bouncePlay {
  0% { transform: scale(1); }
  100% { transform: scale(1.2) rotate(5deg); }
}

.btn-secondary {
  background: rgba(10, 10, 32, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid var(--color-surface-border);
  color: var(--color-text);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

/* Customized Home Menu Theme Buttons */
.btn-sectors {
  border-color: rgba(189, 0, 255, 0.35);
  background: rgba(189, 0, 255, 0.04);
}

.btn-sectors:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
  box-shadow: 0 0 20px rgba(189, 0, 255, 0.5), inset 0 0 10px rgba(189, 0, 255, 0.15);
  background: rgba(189, 0, 255, 0.08);
}

.btn-sectors:hover .btn-icon {
  transform: scale(1.15) rotate(-10deg);
}

.btn-sectors:hover .btn-icon-img {
  filter: drop-shadow(0 0 5px var(--color-secondary)) brightness(1.2);
}

.btn-hangar {
  border-color: rgba(255, 0, 122, 0.35);
  background: rgba(255, 0, 122, 0.04);
}

.btn-hangar:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: 0 0 20px rgba(255, 0, 122, 0.5), inset 0 0 10px rgba(255, 0, 122, 0.15);
  background: rgba(255, 0, 122, 0.08);
}

.btn-hangar:hover .btn-icon {
  animation: launchRocket 0.8s ease-in-out infinite;
}

.btn-hangar:hover .btn-icon-img {
  filter: drop-shadow(0 0 5px var(--color-accent)) brightness(1.2);
}

@keyframes launchRocket {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-8deg); }
}

.btn-config {
  border-color: rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.04);
}

.btn-config:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.5), inset 0 0 10px rgba(0, 240, 255, 0.15);
  background: rgba(0, 240, 255, 0.08);
}

.btn-config:hover .btn-icon {
  animation: spinGear 2s linear infinite;
}

.btn-config:hover .btn-icon-img {
  filter: drop-shadow(0 0 5px var(--color-primary)) brightness(1.2);
}

@keyframes spinGear {
  100% { transform: rotate(360deg); }
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-danger), #b31010);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 49, 49, 0.4);
}

.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(255, 49, 49, 0.6);
}

/* Glow Button (Cyber Accent) */
.glow-btn {
  position: relative;
}

.glow-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: all 0.6s ease;
}

.glow-btn:hover::after {
  left: 100%;
}

.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* MAIN MENU SCREEN */
#screen-main-menu {
  justify-content: space-between;
  padding: 32px 24px 32px 24px;
}

.menu-header {
  text-align: center;
  margin-top: 0;
}

.menu-header .subtitle {
  font-family: var(--font-title);
  color: var(--color-secondary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 5px;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(189, 0, 255, 0.5);
}

.menu-header .main-title {
  font-family: var(--font-title);
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.menu-header .main-title span {
  color: var(--color-primary);
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
}

.menu-logo {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  margin-top: 0;
  filter: drop-shadow(0 0 15px rgba(0, 240, 255, 0.45));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}


.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.menu-footer {
  text-align: center;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--color-text-muted);
}

/* LEVEL SELECT SCREEN */
.levels-scroll-container {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 8px;
}

/* Custom Scrollbar for Sci-Fi Feel */
.levels-scroll-container::-webkit-scrollbar {
  width: 6px;
}
.levels-scroll-container::-webkit-scrollbar-track {
  background: var(--color-bg);
}
.levels-scroll-container::-webkit-scrollbar-thumb {
  background: var(--color-surface-border);
  border-radius: 3px;
}
.levels-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-bottom: 24px;
}

.level-card {
  aspect-ratio: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.level-card .level-num {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}

.level-card .level-status {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Level States */
.level-card.unlocked {
  border-color: rgba(0, 240, 255, 0.3);
}
.level-card.unlocked:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
  transform: translateY(-2px);
}
.level-card.unlocked .level-num {
  color: var(--color-primary);
}

.level-card.completed {
  border-color: rgba(57, 255, 20, 0.4);
}
.level-card.completed .level-num {
  color: var(--color-success);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(10, 10, 32, 0.3);
}
.level-card.locked .level-num {
  color: var(--color-text-muted);
}

/* SHOP SCREEN (HANGAR) */
.shop-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  flex-grow: 1;
}

.jet-preview-box {
  background: rgba(10, 10, 32, 0.5);
  border: 1px solid var(--color-surface-border);
  border-radius: 12px;
  width: 100%;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.05);
}

.jet-preview-box img {
  height: 90px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.4));
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}

.jet-preview-box:hover img {
  transform: translateY(-6px) scale(1.05);
}

.jet-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  text-align: center;
}

.jet-unlock-info {
  font-size: 13px;
  color: var(--color-accent);
  letter-spacing: 1px;
}

.shop-thumbnails {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 24px 0;
}

.shop-thumb {
  flex: 1;
  aspect-ratio: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 8px;
  transition: all 0.2s ease;
}

.shop-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: filter 0.2s;
}

.shop-thumb:hover {
  border-color: rgba(0, 240, 255, 0.5);
}

.shop-thumb.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 0.05);
}

.shop-thumb.locked img {
  filter: brightness(0.2) grayscale(1);
}

.shop-thumb .badge-lock {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
}

#btn-equip-jet {
  width: 100%;
  max-width: 280px;
  margin-bottom: 12px;
}

/* SETTINGS SCREEN */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-grow: 1;
  margin-top: 10px;
}

.setting-item {
  background: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-info h3 {
  font-family: var(--font-title);
  font-size: 15px;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.setting-info p {
  font-size: 12px;
  color: var(--color-text-muted);
}

.btn-toggle {
  min-width: 70px;
  padding: 8px 12px;
  font-size: 12px;
  background: #1e1e3f;
  color: var(--color-text-muted);
  border: 1px solid var(--color-surface-border);
}

.btn-toggle.active {
  background: rgba(57, 255, 20, 0.15);
  border-color: var(--color-success);
  color: var(--color-success);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.2);
}

.reset-data-item {
  margin-top: auto;
  border-color: rgba(255, 49, 49, 0.2);
  background: rgba(255, 49, 49, 0.02);
}

#btn-reset-data {
  padding: 10px 16px;
  font-size: 13px;
}

.settings-footer {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

/* GAMEPLAY SCREEN */
#screen-gameplay {
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 8px 16px;
  background: linear-gradient(to bottom, rgba(4, 4, 16, 0.95), rgba(4, 4, 16, 0.8));
  border-bottom: 1px solid var(--color-surface-border);
  z-index: 10;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
}

.hud-value {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.hud-center {
  flex-grow: 1;
  margin: 0 20px;
  text-align: center;
  max-width: 160px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #11112a;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #22224d;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  box-shadow: 0 0 8px var(--color-primary);
  width: 100%;
  transition: width 0.3s ease;
}

.hearts-container {
  display: flex;
  gap: 3px;
}

.heart {
  font-size: 16px;
  filter: grayscale(1) opacity(0.3);
  transition: all 0.2s ease;
}

.heart.active {
  filter: none;
  text-shadow: 0 0 8px rgba(255, 49, 49, 0.6);
}

.score-hud {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px;
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: 1px;
  color: #fff;
  border-bottom: 1px solid rgba(26, 26, 64, 0.5);
  background: rgba(4, 4, 16, 0.6);
  z-index: 10;
}

.score-hud span {
  color: var(--color-primary);
}

.canvas-wrapper {
  flex-grow: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
}

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

/* VIRTUAL KEYBOARD */
#keyboard-container {
  padding: 10px 8px calc(36px + env(safe-area-inset-bottom, 0px)) 8px;
  background: linear-gradient(to top, rgba(4, 4, 16, 0.98), rgba(10, 10, 32, 0.95));
  border-top: 2px solid var(--color-surface-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.key {
  flex: 1;
  max-width: 42px;
  height: 48px;
  background: rgba(26, 26, 64, 0.4);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 4px;
  color: var(--color-text);
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 360px) {
  .key {
    height: 42px;
    font-size: 12px;
  }
}

.key:active, .key.pressed {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #000;
  box-shadow: 0 0 10px var(--color-primary);
  transform: translateY(2px);
}

.key.locked-key {
  opacity: 0.3;
}

/* GAME OVER & LEVEL COMPLETE SCREENS */
#screen-game-over, #screen-level-complete {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(3, 3, 16, 0.95);
  z-index: 100;
}

.status-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.screen-title {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.text-red {
  color: var(--color-danger);
  text-shadow: 0 0 15px rgba(255, 49, 49, 0.5);
}

.text-green {
  color: var(--color-success);
  text-shadow: 0 0 15px rgba(57, 255, 20, 0.5);
}

.screen-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 30px;
}

.stats-box {
  background: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 36px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  letter-spacing: 1px;
}

.stat-line span:first-child {
  color: var(--color-text-muted);
}

.stat-val {
  font-family: var(--font-title);
  font-weight: 700;
  color: #fff;
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.animate-pulse {
  animation: pulse 2s infinite ease-in-out;
}

@keyframes glow {
  0% { text-shadow: 0 0 10px rgba(57, 255, 20, 0.4); }
  50% { text-shadow: 0 0 25px rgba(57, 255, 20, 0.8); }
  100% { text-shadow: 0 0 10px rgba(57, 255, 20, 0.4); }
}

.animate-glow {
  animation: glow 2s infinite ease-in-out;
}

/* AD OVERLAY SCREEN STYLING */
#screen-ad-overlay {
  background: rgba(3, 3, 16, 0.98);
  justify-content: space-between;
  align-items: center;
  z-index: 500; /* above all else */
}

.ad-screen-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-grow: 1;
  padding: 10px 0;
}

.ad-info-title {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--color-accent);
  text-shadow: 0 0 10px rgba(255, 0, 122, 0.4);
  margin-bottom: 20px;
}

#ad-placeholder-banner {
  flex-grow: 1;
  width: 100%;
  max-height: 380px;
  min-height: 260px;
  background: rgba(10, 10, 32, 0.6);
  border: 2px dashed var(--color-surface-border);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  box-sizing: border-box;
}

.ad-partner-logo {
  font-size: 48px;
  margin-bottom: 16px;
  text-shadow: 0 0 15px var(--color-primary);
  animation: pulse 1.5s infinite ease-in-out;
}

.ad-partner-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.ad-partner-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: 280px;
}

.ad-timer-wrapper {
  margin-top: 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 60px;
  justify-content: center;
}

#ad-countdown-text {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-primary);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

#ad-timer-secs {
  color: var(--color-accent);
  font-size: 16px;
  text-shadow: 0 0 10px var(--color-accent);
}

#btn-close-ad {
  width: 100%;
  max-width: 280px;
  box-shadow: 0 0 15px rgba(57, 255, 20, 0.3);
}

#btn-close-ad:hover {
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
}

/* AD PAUSE OVERLAY STYLING */
#ad-pause-overlay {
  background: rgba(3, 3, 16, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 9999; /* Higher than any other screen */
}

.ad-pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  max-width: 320px;
  background: rgba(10, 10, 32, 0.6);
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.35), inset 0 0 15px rgba(0, 240, 255, 0.1);
  border-radius: 16px;
  box-sizing: border-box;
}

.ad-pause-icon {
  font-size: 54px;
  margin-bottom: 16px;
  text-shadow: 0 0 15px var(--color-primary);
  animation: pulse 1.5s infinite ease-in-out;
}

.ad-pause-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.ad-pause-subtitle {
  font-size: 14px;
  color: var(--color-primary);
  letter-spacing: 1px;
  margin-bottom: 24px;
}

.ad-pause-tip {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: 24px;
}

/* Sci-fi Ripple Loader animation */
.loader-ripple {
  display: inline-block;
  position: relative;
  width: 60px;
  height: 60px;
}
.loader-ripple div {
  position: absolute;
  border: 4px solid var(--color-primary);
  opacity: 1;
  border-radius: 50%;
  animation: loader-ripple 1.2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.loader-ripple div:nth-child(2) {
  animation-delay: -0.6s;
}
@keyframes loader-ripple {
  0% {
    top: 26px;
    left: 26px;
    width: 8px;
    height: 8px;
    opacity: 0;
  }
  4.9% {
    top: 26px;
    left: 26px;
    width: 8px;
    height: 8px;
    opacity: 0;
  }
  5% {
    top: 26px;
    left: 26px;
    width: 8px;
    height: 8px;
    opacity: 1;
  }
  100% {
    top: 0;
    left: 0;
    width: 60px;
    height: 60px;
    opacity: 0;
  }
}

/* CUSTOM SYSTEM MODAL DIALOGS */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 3, 16, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.25s ease-out;
}

.custom-modal-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  width: 90%;
  max-width: 340px;
  background: rgba(10, 10, 32, 0.9);
  border: 2px solid var(--color-primary, #00f0ff);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.35), inset 0 0 15px rgba(0, 240, 255, 0.1);
  border-radius: 16px;
  box-sizing: border-box;
  text-align: center;
  animation: scaleUp 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-modal-title {
  font-family: var(--font-title, sans-serif);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 15px;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.custom-modal-text {
  font-size: 14px;
  color: #cdd;
  line-height: 1.5;
  margin-bottom: 24px;
}

.custom-modal-buttons {
  display: flex;
  gap: 15px;
  width: 100%;
  justify-content: center;
}

.custom-modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-title, sans-serif);
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  border: none;
  text-transform: uppercase;
  transition: all 0.2s ease;
  letter-spacing: 1px;
}

.custom-modal-btn-primary {
  background: var(--color-primary, #00f0ff);
  color: #030310;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.custom-modal-btn-primary:hover {
  background: #fff;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.6);
}

.custom-modal-btn-secondary {
  background: transparent;
  border: 1px solid var(--color-surface-border, #444);
  color: #aaa;
}

.custom-modal-btn-secondary:hover {
  border-color: #fff;
  color: #fff;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Shop controls container (mobile styling, gets overridden in media query) */
.shop-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Widescreen / Desktop Layout Rules */
@media (min-width: 769px) {
  #game-container {
    width: calc(min(100vw, 100vh * 16 / 9));
    height: calc(min(100vw, 100vh * 16 / 9) * 9 / 16);
    max-width: 100vw;
    max-height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* Hide Keyboard during gameplay on Desktop */
  #keyboard-container {
    display: none !important;
  }

  /* General screen padding adjustments */
  .screen {
    padding: 24px 40px;
  }
  .screen-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
  }
  .screen-header h2 {
    font-size: 26px;
  }

  /* Scale Buttons */
  .btn {
    padding: 14px 28px;
    font-size: 18px;
  }

  /* Main Menu Screen (Grid Layout) */
  #screen-main-menu {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "logo actions"
      "footer footer";
    align-items: center;
    justify-items: center;
    padding: 24px 48px;
    gap: 24px;
  }
  #screen-main-menu .menu-header {
    grid-area: logo;
    margin: 0;
  }
  #screen-main-menu .menu-logo {
    max-height: 280px;
    width: auto;
  }
  #screen-main-menu .menu-actions {
    grid-area: actions;
    margin: 0;
    width: 100%;
    max-width: 340px;
    gap: 16px;
  }
  #screen-main-menu .menu-actions .btn {
    padding: 14px 24px;
    font-size: 17px;
  }
  #screen-main-menu .menu-footer {
    grid-area: footer;
    font-size: 15px;
    margin-top: 12px;
  }

  /* Level Select Screen */
  .levels-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
  }
  .level-card {
    border-radius: 10px;
  }
  .level-card .level-num {
    font-size: 24px;
  }
  .level-card .level-status {
    font-size: 11px;
  }

  /* Hangar Shop Screen */
  .shop-container {
    flex-direction: row;
    align-items: stretch;
    gap: 32px;
    height: calc(100% - 64px);
  }
  .jet-preview-box {
    flex: 1.2;
    height: 100%;
    min-height: auto;
    padding: 20px;
    justify-content: center;
  }
  .jet-preview-box img {
    height: 110px;
    margin-bottom: 20px;
  }
  .jet-title {
    font-size: 24px;
    margin-bottom: 8px;
  }
  .jet-unlock-info {
    font-size: 15px;
  }
  .shop-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
  }
  .shop-thumbnails {
    margin: 0;
    gap: 12px;
  }
  .shop-thumb {
    padding: 8px;
    border-radius: 8px;
  }
  #btn-equip-jet {
    max-width: 100%;
    margin-bottom: 0;
    padding: 16px 24px;
    font-size: 18px;
  }

  /* Settings Screen */
  .settings-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-content: center;
    margin-top: 10px;
  }
  .setting-item {
    padding: 18px;
  }
  .setting-info h3 {
    font-size: 18px;
    margin-bottom: 6px;
  }
  .setting-info p {
    font-size: 13px;
  }
  .btn-toggle {
    min-width: 90px;
    padding: 10px 16px;
    font-size: 14px;
  }
  .reset-data-item {
    grid-column: span 2;
    margin-top: 0;
  }
  #btn-reset-data {
    padding: 12px 24px;
    font-size: 15px;
  }

  /* Gameplay HUD Sizing Adjustments */
  .hud-label {
    font-size: 13px;
    margin-bottom: 4px;
  }
  .hud-value {
    font-size: 24px;
  }
  .progress-bar-container {
    height: 10px;
  }
  .heart {
    font-size: 22px;
  }
  .score-hud {
    font-size: 16px;
    padding: 8px 20px;
  }
  
  /* Game over & level complete overlay scaling */
  .status-icon {
    font-size: 84px;
  }
  .screen-title {
    font-size: 44px;
  }
  .screen-subtitle {
    font-size: 18px;
    margin-bottom: 24px;
  }
  .stats-box {
    max-width: 360px;
    padding: 24px;
    gap: 16px;
  }
  .stat-line {
    font-size: 17px;
  }
  .stat-val {
    font-size: 19px;
  }
}

