:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --panel: rgba(12, 15, 28, 0.86);
  --panel-solid: #111425;
  --line: rgba(248, 251, 255, 0.17);
  --cyan: #21d4fd;
  --pink: #ff4fd8;
  --gold: #ffd166;
  --green: #64f58d;
  --red: #ff5a6e;
  --purple: #7b61ff;
  --shadow: 0 28px 86px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 14%, rgba(33, 212, 253, 0.25), transparent 30%),
    radial-gradient(circle at 83% 20%, rgba(255, 79, 216, 0.2), transparent 28%),
    linear-gradient(145deg, #12172b 0%, #222042 43%, #113c45 100%);
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  width: min(100vw, 1200px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 22px);
  display: grid;
  place-items: center;
}

.game-card {
  width: min(100%, 600px, max(350px, calc((100vh - 250px) * 9 / 14)));
  padding: clamp(11px, 2.3vw, 16px);
  border: 2px solid rgba(248, 251, 255, 0.24);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

@supports (height: 100svh) {
  .game-card {
    width: min(100%, 600px, max(350px, calc((100svh - 250px) * 9 / 14)));
  }
}

.topbar,
.button-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.brand img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 15px rgba(33, 212, 253, 0.48));
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.96;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.18rem, 4.5vw, 1.88rem);
  text-shadow: 0 0 18px rgba(255, 79, 216, 0.38);
}

h2 {
  font-size: clamp(2.15rem, 9.2vw, 3.9rem);
}

.icon-button,
.primary-button,
.secondary-button,
.upgrade-card {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 950;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.25);
}

.icon-button {
  flex: 0 0 auto;
  padding: 0 13px;
  background: var(--gold);
  color: #111425;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.hud div {
  min-height: 54px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 251, 255, 0.075);
  text-align: center;
}

.hud span {
  display: block;
  color: #bdd4e6;
  font-size: 0.68rem;
  font-weight: 850;
}

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.98rem, 4vw, 1.36rem);
  line-height: 1;
}

.xp-shell {
  overflow: hidden;
  height: 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(248, 251, 255, 0.18);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.xp-shell span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink), var(--gold));
  transition: width 0.16s ease;
}

.weapon-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 7px;
}

.weapon-strip div {
  min-height: 42px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 251, 255, 0.075);
  font-size: 0.74rem;
  font-weight: 900;
  text-align: center;
}

.weapon-strip strong {
  color: var(--gold);
}

.weapon-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
}

.weapon-dot.blaster {
  background: var(--gold);
}

.weapon-dot.orbit {
  background: var(--cyan);
}

.weapon-dot.pulse {
  background: var(--pink);
}

.status-line {
  min-height: 24px;
  margin-bottom: 7px;
  color: #d9e7f6;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.canvas-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 9 / 14;
  border: 3px solid rgba(248, 251, 255, 0.82);
  border-radius: 8px;
  background: #07101f;
  box-shadow:
    inset 0 0 0 5px rgba(33, 212, 253, 0.13),
    0 0 28px rgba(33, 212, 253, 0.2);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 10, 18, 0.48);
}

.overlay.is-visible {
  display: flex;
}

.overlay-panel,
.upgrade-panel,
.ad-panel {
  width: min(100%, 390px);
  padding: 24px;
  border: 2px solid rgba(248, 251, 255, 0.86);
  border-radius: 8px;
  background: rgba(17, 20, 37, 0.97);
  text-align: center;
  box-shadow:
    10px 10px 0 rgba(0, 0, 0, 0.28),
    0 0 34px rgba(255, 79, 216, 0.2);
}

.upgrade-panel {
  width: min(100%, 430px);
}

.flavor {
  max-width: 31ch;
  margin: 14px auto 22px;
  color: #d9e7f6;
  font-size: 0.98rem;
  font-weight: 760;
  line-height: 1.36;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 0 16px;
  white-space: nowrap;
}

.primary-button {
  background: var(--cyan);
  color: #07101f;
}

.secondary-button {
  background: var(--pink);
  color: #fff;
}

.button-row {
  gap: 10px;
}

.button-row .primary-button,
.button-row .secondary-button {
  flex: 1 1 0;
}

.upgrade-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.upgrade-card {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(248, 251, 255, 0.2);
  background: rgba(248, 251, 255, 0.08);
  color: var(--ink);
  text-align: left;
}

.upgrade-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 1rem;
}

.upgrade-card span {
  display: block;
  color: #d9e7f6;
  font-size: 0.86rem;
  line-height: 1.3;
}

.ad-panel {
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 10px, transparent 10px 22px),
    #161a32;
}

.ad-logo {
  width: 196px;
  min-height: 104px;
  margin: 18px auto;
  display: grid;
  place-items: center;
  border: 3px solid var(--cyan);
  border-radius: 8px;
  background: var(--pink);
  color: #fff;
  font-size: 1.95rem;
  font-weight: 1000;
  line-height: 0.92;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 24px rgba(255, 79, 216, 0.45);
}

#adCountdown {
  display: inline-grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #111425;
  font-size: 2.4rem;
}

@media (min-width: 900px) {
  .game-card {
    width: min(96vw, 1080px);
    display: grid;
    grid-template-columns: 336px minmax(300px, min(560px, calc((100vh - 92px) * 9 / 14)));
    grid-template-rows: auto auto auto auto auto 1fr;
    align-items: start;
    justify-content: center;
    gap: 9px 14px;
  }

  @supports (height: 100svh) {
    .game-card {
      grid-template-columns: 336px minmax(300px, min(560px, calc((100svh - 92px) * 9 / 14)));
    }
  }

  .topbar,
  .hud,
  .xp-shell,
  .weapon-strip,
  .status-line {
    grid-column: 1;
  }

  .canvas-frame {
    grid-column: 2;
    grid-row: 1 / span 6;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .weapon-strip {
    grid-template-columns: 1fr;
  }

  .weapon-strip div,
  .status-line {
    text-align: left;
  }
}

@media (max-width: 440px) {
  .app-shell {
    padding: 7px;
    align-items: start;
  }

  .game-card {
    padding: 9px;
  }

  .brand img {
    width: 42px;
    height: 42px;
  }

  .hud {
    gap: 5px;
  }

  .hud div {
    min-height: 48px;
    padding: 6px 3px;
  }

  .hud span {
    font-size: 0.62rem;
  }

  .weapon-strip {
    gap: 5px;
  }

  .weapon-strip div {
    padding: 6px 4px;
    font-size: 0.66rem;
  }

  .button-row {
    flex-direction: column;
  }
}
