:root {
  color-scheme: dark;
  --ink: #fff8df;
  --muted: rgba(255, 248, 223, 0.74);
  --panel: rgba(24, 39, 44, 0.76);
  --panel-strong: rgba(17, 31, 34, 0.93);
  --gold: #f2b72f;
  --red: #f45b43;
  --teal: #19c7be;
  --line: rgba(255, 255, 255, 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 18%, rgba(242, 183, 47, 0.18), transparent 26rem),
    radial-gradient(circle at 80% 72%, rgba(25, 199, 190, 0.16), transparent 25rem),
    #10231f;
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 0.5625));
  height: min(100dvh, calc(100vw / 0.5625));
  margin: auto;
  overflow: hidden;
  background: #132820;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42);
  isolation: isolate;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.top-hud,
.run-hud,
.control-dock,
.modal-overlay,
.shop-overlay {
  position: absolute;
  z-index: 2;
}

.top-hud {
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.brand-lockup {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(22, 41, 42, 0.82), rgba(18, 28, 31, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
}

.brand-lockup span,
.hud-strip span,
.run-hud span,
.shop-header span,
.premium-strip span,
.upgrade-card span,
#overlayKicker {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup h1,
.shop-header h2,
.modal-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  font-size: clamp(1rem, 4vw, 1.35rem);
  line-height: 1.05;
}

.hud-strip,
.run-hud {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
}

.hud-strip div,
.run-hud div {
  min-width: 64px;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(20, 37, 40, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  backdrop-filter: blur(10px);
}

.hud-strip strong,
.run-hud strong {
  display: block;
  color: #ffffff;
  font-size: 1.05rem;
  line-height: 1.1;
}

.run-hud {
  left: 12px;
  right: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 82px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  pointer-events: none;
}

.control-dock {
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 0.74fr);
  gap: 8px;
  pointer-events: auto;
}

.primary-button,
.dock-button {
  min-height: 48px;
  border-radius: 8px;
  color: #16120a;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 8px 0 rgba(87, 51, 12, 0.38), 0 18px 30px rgba(0, 0, 0, 0.24);
  transition: transform 130ms ease, filter 130ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #ffe17b, var(--gold));
}

.dock-button {
  background: linear-gradient(180deg, #ffffff, #d8edf1);
  color: #183133;
  box-shadow: 0 7px 0 rgba(12, 57, 62, 0.32), 0 16px 24px rgba(0, 0, 0, 0.22);
}

.primary-button:active,
.dock-button:active {
  transform: translateY(3px);
  filter: brightness(0.96);
}

.modal-overlay {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(180deg, rgba(5, 15, 17, 0.18), rgba(5, 15, 17, 0.42));
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

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

.modal-panel {
  width: min(100%, 390px);
  padding: 20px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(25, 46, 50, 0.94), rgba(14, 29, 32, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  text-align: center;
  backdrop-filter: blur(16px);
}

.modal-panel h2 {
  margin-top: 4px;
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 0.96;
}

.modal-panel p {
  min-height: 1.5em;
  margin: 12px 0 18px;
  color: var(--muted);
  font-weight: 800;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 10px;
}

.shop-overlay {
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(8, 20, 22, 0.9);
  backdrop-filter: blur(18px);
  transform: translateY(104%);
  transition: transform 220ms ease;
  pointer-events: none;
}

.shop-overlay.is-active {
  transform: translateY(0);
  pointer-events: auto;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shop-header h2 {
  font-size: 2rem;
  line-height: 1;
}

.shop-header .dock-button {
  min-width: 86px;
}

.upgrade-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 3px;
}

.upgrade-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 98px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
}

.upgrade-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.upgrade-card strong {
  display: block;
  color: var(--gold);
}

.upgrade-card .dock-button {
  min-height: 42px;
  box-shadow: none;
}

.sprite-icon {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  background-image: url("assets/art/sprite-sheet.png");
  background-repeat: no-repeat;
  background-size: 400% 300%;
  background-color: rgba(255, 255, 255, 0.08);
}

.sprite-projectile {
  background-position: 33.333% 0%;
}

.sprite-rocket {
  background-position: 33.333% 100%;
}

.sprite-coin {
  background-position: 33.333% 50%;
}

.sprite-shield {
  background-position: 100% 50%;
}

.premium-strip {
  padding: 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(244, 91, 67, 0.26), rgba(25, 199, 190, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.premium-strip strong {
  display: block;
  margin-top: 4px;
  color: #ffffff;
  font-size: 0.92rem;
}

@media (max-width: 390px) {
  .top-hud {
    align-items: flex-start;
  }

  .hud-strip div {
    min-width: 54px;
    padding-inline: 6px;
  }

  .control-dock {
    grid-template-columns: 1fr 0.7fr 0.78fr 0.78fr;
  }

  .primary-button,
  .dock-button {
    min-height: 44px;
    font-size: 0.84rem;
  }
}
