* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100vh;
  height: 100dvh;     /* mobile: tracks the dynamic viewport (no toolbar drift) */
  background: #7ec8ff;
  color: #1a2638;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #bfe3ff 0%, #7ec8ff 70%, #5fb0f0 100%);
}

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

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(env(safe-area-inset-top, 0), 6px) env(safe-area-inset-right, 16px) max(env(safe-area-inset-bottom, 0), 6px) env(safe-area-inset-left, 16px);
  text-align: center;
  pointer-events: none;
  /* On short landscape phones, let the column scroll rather than spill off
     the top of the viewport. justify-content stays centered for tall screens. */
  overflow-y: auto;
}
.screen.visible { display: flex; }
.screen > * { pointer-events: auto; flex-shrink: 0; }

h1 {
  font-size: min(clamp(28px, 8vw, 64px), 14vh);
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
  color: #fff;
  text-shadow:
    -2px -2px 0 #264a73,
    2px -2px 0 #264a73,
    -2px 2px 0 #264a73,
    2px 2px 0 #264a73,
    0 4px 0 #264a73,
    0 8px 14px rgba(38, 74, 115, 0.3);
}
h2 {
  font-size: min(clamp(22px, 7vw, 48px), 12vh);
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  color: #fff;
  text-shadow:
    -2px -2px 0 #264a73,
    2px -2px 0 #264a73,
    -2px 2px 0 #264a73,
    2px 2px 0 #264a73;
}
.tag {
  font-size: clamp(11px, 3vh, 14px);
  color: #264a73;
  opacity: 0.85;
  margin: 0 0 12px;
  letter-spacing: 0.04em;
}
.hint {
  font-size: clamp(10px, 2.6vh, 12px);
  color: #264a73;
  opacity: 0.7;
  margin-top: 10px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.hint kbd {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(38,74,115,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-weight: 700;
}

.cta {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, #ffd34d 0%, #ffaa00 100%);
  color: #1a2638;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(14px, 3.6vh, 18px);
  letter-spacing: 0.1em;
  padding: clamp(10px, 2.2vh, 16px) clamp(24px, 6vw, 36px);
  border-radius: 999px;
  box-shadow:
    0 4px 0 #b87600,
    0 8px 20px rgba(38, 74, 115, 0.25);
  cursor: pointer;
  margin: 4px 0;
  min-width: 180px;
}
.cta:active { transform: translateY(2px); box-shadow: 0 2px 0 #b87600, 0 4px 10px rgba(38, 74, 115, 0.2); }

.cta-ghost {
  background: rgba(255,255,255,0.85);
  color: #264a73;
  box-shadow: 0 4px 0 rgba(38,74,115,0.35), 0 8px 16px rgba(38,74,115,0.15);
}
.cta-ghost:active { box-shadow: 0 2px 0 rgba(38,74,115,0.35), 0 4px 8px rgba(38,74,115,0.12); }

.cta-rewarded {
  background: linear-gradient(180deg, #ff8a4d 0%, #ff5e3a 100%);
  color: #fff;
  box-shadow: 0 4px 0 #b03217, 0 8px 20px rgba(255, 94, 58, 0.3);
}
.cta-rewarded:active { box-shadow: 0 2px 0 #b03217, 0 4px 10px rgba(255, 94, 58, 0.25); }
.cta-rewarded .icon { display: inline-block; transform: rotate(-90deg); margin-right: 8px; }

.score {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  left: 0; right: 0;
  text-align: center;
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.04em;
  text-shadow:
    -2px -2px 0 #264a73,
    2px -2px 0 #264a73,
    -2px 2px 0 #264a73,
    2px 2px 0 #264a73;
  pointer-events: none;
}
.run-coins {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 72px);
  left: 0; right: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: #ffd34d;
  letter-spacing: 0.04em;
  text-shadow:
    -1px -1px 0 #264a73,
    1px -1px 0 #264a73,
    -1px 1px 0 #264a73,
    1px 1px 0 #264a73;
  pointer-events: none;
}
.intro-hint {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0) + 40px);
  left: 0; right: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 6px rgba(38,74,115,0.5);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.intro-hint.visible { opacity: 1; }

.run-stat {
  font-size: clamp(48px, 14vw, 96px);
  font-weight: 900;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  color: #fff;
  text-shadow:
    -2px -2px 0 #264a73,
    2px -2px 0 #264a73,
    -2px 2px 0 #264a73,
    2px 2px 0 #264a73;
}
.run-coins-final {
  font-size: 16px;
  font-weight: 800;
  color: #ffd34d;
  margin: 0 0 20px;
  letter-spacing: 0.04em;
  text-shadow:
    -1px -1px 0 #264a73,
    1px -1px 0 #264a73,
    -1px 1px 0 #264a73,
    1px 1px 0 #264a73;
}

.best-stat {
  margin-top: 18px;
  font-size: 14px;
  font-weight: 700;
  color: #264a73;
  opacity: 0.8;
  letter-spacing: 0.04em;
}
.coins-stat {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 800;
  color: #b87600;
  letter-spacing: 0.04em;
}

.hangar-coins {
  font-size: 18px;
  font-weight: 800;
  color: #b87600;
  margin: 0 0 16px;
  letter-spacing: 0.04em;
}
.plane-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  max-width: min(640px, 90vw);
  width: 100%;
  margin: 0 0 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}
.plane-card {
  background: rgba(255,255,255,0.92);
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 10px 8px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #1a2638;
  transition: transform 0.1s;
}
.plane-card:active { transform: scale(0.97); }
.plane-card.selected { border-color: #ffaa00; box-shadow: 0 0 0 4px rgba(255,170,0,0.25); }
.plane-card.locked { opacity: 0.6; cursor: default; }
.plane-card .plane-thumb {
  width: 100px; height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.plane-card .plane-thumb canvas { width: 100%; height: 100%; }
.plane-card .plane-name { font-size: 14px; font-weight: 800; letter-spacing: 0.04em; }
.plane-card .plane-meta { font-size: 11px; opacity: 0.7; }
.plane-card .plane-unlock { font-size: 11px; font-weight: 700; color: #b03217; }
.plane-card .plane-unlock.affordable { color: #1a2638; }
.plane-card .unlock-btn {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, #ff8a4d, #ff5e3a);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 999px;
  margin-top: 4px;
  cursor: pointer;
}
.plane-card .unlock-btn.coin {
  background: linear-gradient(180deg, #ffd34d, #ffaa00);
  color: #1a2638;
}
.plane-card .unlock-btn:disabled { opacity: 0.5; cursor: default; }

.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  color: #fff;
}
.ad-overlay[hidden] { display: none; }
.ad-overlay-inner {
  background: #1a2638;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  text-align: center;
}
