/* Soldier Surfer — UI styling. Brand palette matches sourcestrongai.com. */

:root {
  --orange: #ff5e00;
  --paper: #0e0d0b;
  --cream: #f4f0ec;
  --ink: #1a1a1a;
  --green: #2ecc71;
  --red: #ff3b30;
  --gold: #ffc432;
  --hud-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--cream);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- overlays ---------- */

#fx-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.45s ease-out;
}
#fx-flash.on {
  opacity: 0.55;
  transition: none;
}

#touch-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%; /* bottom half+ so the thumb never covers the crowd */
  z-index: 10;
  touch-action: none;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + var(--safe-top)) 14px 0;
}

#hud-army {
  text-align: left;
}

#hud-count {
  font-size: clamp(2.1rem, 8vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: var(--hud-shadow);
  line-height: 1;
  transition:
    transform 0.12s ease-out,
    color 0.12s ease-out;
}
#hud-count.bump-up {
  transform: scale(1.22);
  color: var(--green);
}
#hud-count.bump-down {
  transform: scale(0.88);
  color: var(--red);
}

#hud-tier {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(244, 240, 236, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
  text-shadow: none;
}
#hud-tier-icon {
  font-size: 0.9em;
}

#hud-combo {
  margin-top: 5px;
  font-size: clamp(0.95rem, 3.6vw, 1.25rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
#hud-combo.combo-hot {
  color: var(--orange);
  text-shadow:
    0 0 16px rgba(255, 94, 0, 0.75),
    0 2px 10px rgba(0, 0, 0, 0.5);
}
#hud-combo.bump {
  animation: comboBump 0.18s ease-out;
}
@keyframes comboBump {
  0% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.go-motivate {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  max-width: 320px;
}

.stat-bank {
  color: var(--gold);
  opacity: 0.95;
}

.missions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  opacity: 0.85;
}
.mission-row {
  color: var(--cream);
}
.mission-done {
  color: var(--green);
  font-weight: 800;
  animation: missionPop 0.4s ease-out;
}
@keyframes missionPop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#hud-distance {
  font-size: clamp(1.15rem, 4.5vw, 1.6rem);
  font-weight: 800;
  text-shadow: var(--hud-shadow);
  font-variant-numeric: tabular-nums;
}

#hud-coins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: var(--hud-shadow);
  font-variant-numeric: tabular-nums;
}
.coin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--gold) 60%, #b8860b);
  display: inline-block;
}

/* active power-up chips */
#hud-effects {
  display: flex;
  gap: 6px;
  padding: 6px 14px 0;
  flex-wrap: wrap;
}
.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(244, 240, 236, 0.3);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: none;
}

/* rare-event banner */
#event-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -30px) scale(0.8);
  z-index: 25;
  font-size: clamp(1.5rem, 7vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  transition:
    opacity 0.3s,
    transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}
#event-banner.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
#event-banner.banner-gold {
  color: var(--gold);
  text-shadow:
    0 0 24px rgba(255, 196, 50, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.6);
}
#event-banner.banner-danger {
  color: var(--red);
  text-shadow:
    0 0 24px rgba(255, 59, 48, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.6);
}
#event-banner.banner-meteor {
  color: #ff9a3d;
  text-shadow:
    0 0 24px rgba(255, 122, 51, 0.85),
    0 2px 8px rgba(0, 0, 0, 0.6);
}

/* subtle vignette adds depth without costing a single draw call */
#app::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 58%, rgba(10, 8, 6, 0.28) 100%);
}

#btn-pause {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.45);
  color: var(--cream);
  border: 1px solid rgba(244, 240, 236, 0.25);
  border-radius: 10px;
  font-size: 0.9rem;
  padding: 8px 12px;
  cursor: pointer;
}

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(14, 13, 11, 0.78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  text-align: center;
  padding: calc(16px + var(--safe-top)) 18px calc(70px + var(--safe-bottom));
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  margin: auto;
}

.mini-header {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.85rem;
}
.mini-header a,
.mini-footer a {
  color: var(--cream);
  text-decoration: none;
  opacity: 0.85;
}
.mini-header a:hover,
.mini-footer a:hover {
  opacity: 1;
  text-decoration: underline;
}
.brand-link {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.mini-footer {
  position: absolute;
  bottom: calc(58px + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 0.8rem;
  opacity: 0.85;
}

.accent {
  color: var(--orange);
}

.game-title {
  font-size: clamp(2.6rem, 13vw, 4.6rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-shadow: 0 6px 30px rgba(255, 94, 0, 0.35);
}

.brand-line {
  font-size: 0.9rem;
  opacity: 0.8;
}

.screen-title {
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.screen-title.small {
  font-size: clamp(1.5rem, 7vw, 2.2rem);
}

.stat-line {
  font-size: 0.95rem;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 16px 52px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 94, 0, 0.4);
  transition: transform 0.1s ease-out;
  touch-action: manipulation;
}
.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary,
.btn-link {
  background: rgba(244, 240, 236, 0.08);
  color: var(--cream);
  border: 1px solid rgba(244, 240, 236, 0.3);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  touch-action: manipulation;
}
.btn-secondary:active {
  transform: scale(0.97);
}

.start-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.hint-line {
  font-size: 0.82rem;
  opacity: 0.6;
  max-width: 300px;
}

/* game over */
.go-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  width: 100%;
  max-width: 340px;
  background: rgba(244, 240, 236, 0.06);
  border: 1px solid rgba(244, 240, 236, 0.15);
  border-radius: 14px;
  padding: 14px 18px;
}
.go-stats > div {
  display: flex;
  justify-content: space-between;
  grid-column: span 2;
}
.go-stats dt {
  opacity: 0.65;
  font-size: 0.9rem;
}
.go-stats dd {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.new-best {
  color: var(--gold);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  animation: bestPulse 0.9s ease-in-out infinite alternate;
}
@keyframes bestPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.12);
  }
}

.btn-revive {
  background: linear-gradient(135deg, #ffc432, #ff8a00);
  color: #2b1600;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 900;
  padding: 13px 30px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(255, 196, 50, 0.35);
  touch-action: manipulation;
}
.revive-sub {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* power-ups modal */
.modal-card {
  background: rgba(20, 18, 15, 0.95);
  border: 1px solid rgba(244, 240, 236, 0.15);
  border-radius: 18px;
  padding: 22px 18px;
}
.modal-sub {
  font-size: 0.85rem;
  opacity: 0.75;
}

.powerup {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(244, 240, 236, 0.05);
  border: 1px solid rgba(244, 240, 236, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
}
.powerup-icon {
  font-size: 1.6rem;
}
.powerup-info {
  flex: 1;
}
.powerup-name {
  font-weight: 800;
  font-size: 0.95rem;
}
.powerup-desc {
  font-size: 0.78rem;
  opacity: 0.7;
}
.powerup-buy {
  background: rgba(255, 94, 0, 0.25);
  color: var(--cream);
  border: 1px solid rgba(255, 94, 0, 0.5);
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 10px;
  white-space: nowrap;
}
.powerup-buy:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- ad banner ---------- */

#ad-banner {
  position: absolute;
  bottom: var(--safe-bottom);
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 50px;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 240, 236, 0.06);
  border: 1px dashed rgba(244, 240, 236, 0.25);
  border-radius: 6px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
}

/* rewarded-ad simulation overlay (built by ads.js) */
#ad-sim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--cream);
  font-weight: 800;
  letter-spacing: 0.06em;
}
#ad-sim .ad-sim-box {
  width: min(80vw, 300px);
  height: 160px;
  border: 2px dashed rgba(244, 240, 236, 0.35);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* ---------- noscript ---------- */

.noscript-card {
  max-width: 560px;
  margin: 12vh auto;
  padding: 28px;
  background: #171512;
  border: 1px solid #2a2620;
  border-radius: 16px;
}
.noscript-card h1 {
  color: var(--orange);
  margin-bottom: 12px;
}
.noscript-card p {
  line-height: 1.5;
  margin-bottom: 10px;
}
.noscript-card a {
  color: var(--orange);
}

/* ---------- responsive ---------- */

/* landscape phones: tighten vertical rhythm */
@media (max-height: 480px) {
  .screen-inner {
    gap: 8px;
  }
  .game-title {
    font-size: clamp(1.8rem, 9vh, 2.6rem);
  }
  .btn-primary {
    padding: 10px 36px;
    font-size: 1.1rem;
  }
  .mini-footer {
    display: none;
  }
  .go-stats {
    padding: 8px 14px;
    gap: 3px 12px;
  }
}

/* desktop */
@media (min-width: 900px) {
  #hud-top {
    padding: 18px 26px 0;
  }
  .hint-line {
    max-width: 380px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .new-best {
    animation: none;
  }
  #fx-flash {
    transition: none;
  }
}
