:root {
  --bg: #090a0a;
  --panel: rgba(12, 14, 14, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4f2e8;
  --muted: #a9a79e;
  --lime: #d8f35e;
  --teal: #19b4a5;
  --ember: #f0573f;
  --gold: #ffb23a;
  --cobalt: #4f74ff;
  --purple: #7d4dff;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.back-pill {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 6;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel);
  backdrop-filter: blur(18px);
  font-size: 0.78rem;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease;
}

.back-pill:hover,
.back-pill:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(216, 243, 94, 0.55);
}

@media (max-width: 760px) {
  .back-pill {
    top: 12px;
    left: 12px;
    padding: 7px 11px;
    font-size: 0.72rem;
  }
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  background: #080908;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(150px, auto) 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 42px);
  pointer-events: none;
}

.brand,
.stats,
.controls,
.energy-wrap,
.help-bar {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
  font-weight: 900;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border: 3px solid var(--lime);
  border-left-color: var(--ember);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(216, 243, 94, 0.55);
}

.stats {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.stats div {
  min-width: 94px;
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.stats span,
.energy-wrap span,
.screen-actions span,
.help-bar span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  color: var(--lime);
  font-size: 1.28rem;
  line-height: 1.05;
}

.controls {
  display: flex;
  gap: 8px;
}

.controls button,
.screen button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  backdrop-filter: blur(18px);
  font-weight: 900;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.controls button {
  padding: 9px 12px;
}

.controls button:hover,
.controls button:focus-visible,
.screen button:hover,
.screen button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(216, 243, 94, 0.55);
}

.energy-wrap {
  position: absolute;
  left: clamp(16px, 4vw, 42px);
  bottom: 72px;
  z-index: 3;
  width: min(330px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.energy-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.energy-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--lime));
  box-shadow: 0 0 18px rgba(25, 180, 165, 0.54);
  transform-origin: left center;
}

.screen {
  position: absolute;
  left: clamp(16px, 7vw, 92px);
  top: clamp(84px, 13vh, 120px);
  bottom: clamp(78px, 11vh, 100px);
  z-index: 4;
  width: min(560px, calc(100vw - 32px));
  overflow-y: auto;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(9, 10, 10, 0.76);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(22px);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition:
    opacity 260ms ease,
    transform 260ms ease;
}

.screen.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--lime);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 16px;
  line-height: 0.92;
  letter-spacing: 0;
}

h1 {
  font-size: 4.8rem;
}

h2 {
  font-size: 3.4rem;
}

.screen p:not(.eyebrow) {
  max-width: 44ch;
  color: rgba(244, 242, 232, 0.78);
  font-size: 1.03rem;
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.screen .primary {
  min-width: 154px;
  padding: 12px 18px;
  color: #11120f;
  border-color: transparent;
  background: var(--lime);
}

.help-bar {
  position: absolute;
  right: clamp(16px, 4vw, 42px);
  bottom: 18px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(620px, calc(100vw - 32px));
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

kbd {
  min-width: 32px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 760px) {
  .game-shell {
    min-height: 620px;
  }

  .hud {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .brand {
    min-width: 0;
  }

  .stats {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: stretch;
  }

  .stats div {
    flex: 1;
    min-width: 0;
  }

  .screen {
    top: 132px;
    bottom: 96px;
  }

  h1 {
    font-size: 3.4rem;
  }

  h2 {
    font-size: 2.5rem;
  }

  .energy-wrap {
    bottom: 72px;
  }

  .help-bar {
    left: 16px;
    justify-content: flex-start;
  }
}

@media (max-width: 460px) {
  .controls button {
    min-height: 38px;
    padding: 8px 9px;
    font-size: 0.86rem;
  }

  .screen-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .screen .primary {
    width: 100%;
  }

  .help-bar kbd:nth-of-type(2),
  .help-bar span:nth-of-type(2),
  .help-bar span:nth-of-type(3) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------------- combo cell (reuses .stats div base styles) ---------------- */

.combo-cell strong {
  color: var(--gold);
}

/* ---------------- mode toggles ---------------- */

.mode-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.screen .mode-btn {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.88rem;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.mode-btn:hover,
.mode-btn:focus-visible {
  transform: translateY(-2px);
}

.mode-btn.is-active {
  border-color: var(--ember);
  background: rgba(240, 87, 63, 0.18);
}

#stormToggle.is-active {
  border-color: var(--cobalt);
  background: rgba(79, 116, 255, 0.18);
}

/* ---------------- skin strip ---------------- */

.skin-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.screen .skin-swatch {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease;
}

.skin-swatch:hover,
.skin-swatch:focus-visible {
  transform: translateY(-2px);
}

.skin-swatch.is-selected {
  border-color: var(--lime);
}

.skin-swatch.is-locked {
  opacity: 0.55;
}

.swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* ---------------- menu links ---------------- */

.menu-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.menu-links button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.82rem;
  transition: transform 160ms ease, border-color 160ms ease;
}

.menu-links button:hover,
.menu-links button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(216, 243, 94, 0.55);
}

.stars-pill {
  margin-left: 4px;
  color: var(--gold);
}

/* ---------------- challenge banner ---------------- */

.challenge-banner {
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  background: rgba(255, 178, 58, 0.1);
  font-weight: 800;
  font-size: 0.92rem !important;
  color: var(--text) !important;
}

/* ---------------- event banner ---------------- */

.event-banner {
  position: absolute;
  top: 96px;
  left: 50%;
  z-index: 7;
  transform: translate(-50%, -14px);
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(9, 10, 10, 0.8);
  backdrop-filter: blur(18px);
  font-weight: 900;
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease;
}

.event-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- end screen extras ---------------- */

.end-rank {
  padding: 9px 12px;
  margin-top: -6px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: rgba(216, 243, 94, 0.12);
  color: var(--lime) !important;
  font-weight: 800 !important;
  font-size: 0.9rem !important;
}

.end-missions {
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  color: rgba(244, 242, 232, 0.7);
}

.end-missions li.is-done {
  color: var(--lime);
}

.end-hint {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.screen .ghost {
  color: var(--text);
  background: transparent;
  border-color: var(--line);
}

.screen .ghost:hover,
.screen .ghost:focus-visible {
  border-color: var(--lime);
}

/* ---------------- panels (classifica / obiettivi / missioni) ---------------- */

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 3, 3, 0.6);
  backdrop-filter: blur(4px);
}

.panel-backdrop[hidden] {
  display: none;
}

.panel {
  width: min(480px, 100%);
  max-height: min(600px, 86vh);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: #0d0e0d;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.5rem;
}

.panel-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.panel-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-tab {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.8rem;
}

.panel-tab.is-active {
  border-color: var(--lime);
  color: var(--lime);
}

.panel-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.board-list,
.achv-list,
.mission-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-list li {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.board-rank {
  color: var(--gold);
  font-weight: 900;
}

.board-score {
  color: var(--lime);
  font-weight: 900;
}

.board-empty {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  padding: 18px 0;
}

.achv-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

.achv-list li.is-unlocked {
  border-color: rgba(216, 243, 94, 0.4);
  color: var(--text);
}

.achv-icon {
  font-size: 1.3rem;
}

.mission-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
}

.mission-list li.is-done {
  border-color: rgba(216, 243, 94, 0.4);
}

.mission-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 700;
}

.mission-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.mission-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--lime));
}

/* ---------------- toasts ---------------- */

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: rgba(9, 10, 10, 0.92);
  backdrop-filter: blur(18px);
  font-weight: 700;
  font-size: 0.85rem;
  max-width: 320px;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* ---------------- Neon Storm fx ---------------- */

#game.fx-invert {
  filter: invert(0.86) hue-rotate(180deg);
}

@media (max-width: 620px) {
  .toast-stack {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .toast {
    max-width: none;
  }

  .event-banner {
    top: 128px;
    width: min(320px, calc(100vw - 40px));
    text-align: center;
    font-size: 0.82rem;
  }
}

/* ---------------- ad slot ----------------
   Inline dentro le schermate Start/Game Over: mai sopra al gioco,
   mai sopra ai comandi. */

.ad-inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.ad-label {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  .ad-inline ins {
    width: 260px !important;
  }
}

/* ---------------- premium skin panel ---------------- */

.premium-copy {
  margin: 0 0 16px;
  color: rgba(244, 242, 232, 0.78);
  font-size: 0.94rem;
}

.premium-buy {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffe9b0, #ffcf4d);
  color: #241a04;
  text-align: center;
  font-weight: 900;
  text-decoration: none;
  margin-bottom: 16px;
}

.premium-redeem {
  display: flex;
  gap: 8px;
}

.premium-redeem input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.9rem;
}

.premium-redeem button {
  padding: 10px 16px;
  border: 1px solid var(--lime);
  border-radius: var(--radius);
  background: rgba(216, 243, 94, 0.14);
  color: var(--lime);
  font-weight: 800;
  cursor: pointer;
}

.premium-redeem button:hover,
.premium-redeem button:focus-visible {
  background: rgba(216, 243, 94, 0.24);
}
