:root {
  --bg-1: #05050b;
  --bg-2: #10061d;
  --bg-3: #081121;
  --glass: rgba(12, 14, 28, 0.54);
  --glass-strong: rgba(10, 12, 24, 0.82);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: rgba(245, 248, 255, 0.96);
  --muted: rgba(200, 206, 230, 0.72);
  --cyan: #55f6ff;
  --magenta: #ff4fd8;
  --blue: #6d7dff;
  --red: #ff5978;
  --amber: #ffc65c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 20% 15%, rgba(109, 125, 255, 0.18), transparent 26%),
    radial-gradient(circle at 80% 18%, rgba(255, 79, 216, 0.14), transparent 22%),
    radial-gradient(circle at 50% 80%, rgba(85, 246, 255, 0.1), transparent 30%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.03), transparent 20%, rgba(255, 255, 255, 0.02) 50%, transparent 80%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  mix-blend-mode: screen;
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

body.hints-hidden .device-hint {
  opacity: 0 !important;
}

a {
  color: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

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

.hud {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 10;
}

.hud-card,
.stats-box,
.hero-card,
.progress-card {
  min-width: 120px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hud-card,
.stats-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-value,
.hero-stat-value,
.progress-value {
  color: white;
  text-shadow: 0 0 10px rgba(85, 246, 255, 0.35), 0 0 20px rgba(255, 79, 216, 0.18);
}

.hud-value {
  font-size: 24px;
  font-weight: 700;
}

.hero-stat-value,
.progress-value {
  font-size: 26px;
  font-weight: 700;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 24;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.glass-panel {
  width: min(580px, calc(100vw - 32px));
  padding: 30px 28px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%),
    var(--glass-strong);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  text-align: center;
}

.hero-panel h1,
.hero-panel h2,
.modal-panel h3 {
  margin: 10px 0 8px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero-panel h1 {
  font-size: clamp(44px, 6vw, 76px);
  text-shadow: 0 0 18px rgba(85, 246, 255, 0.22), 0 0 34px rgba(255, 79, 216, 0.16);
}

.hero-panel h2,
.modal-panel h3 {
  font-size: clamp(30px, 4vw, 48px);
}

.hero-panel--launch {
  width: min(860px, calc(100vw - 32px));
}

.eyebrow,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.eyebrow.danger {
  color: #ffd4df;
  border-color: rgba(255, 89, 120, 0.28);
  background: rgba(255, 89, 120, 0.12);
}

.status-pill {
  color: #d7feff;
  border-color: rgba(85, 246, 255, 0.22);
  background: rgba(85, 246, 255, 0.12);
  letter-spacing: 0.12em;
}

.subtitle {
  margin: 0 0 10px;
  font-size: clamp(18px, 2.4vw, 22px);
  color: var(--muted);
}

.zeptai-powered {
  margin: 8px 0 16px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(200, 206, 230, 0.64);
  text-transform: uppercase;
}

.zeptai-link {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.zeptai-link:hover {
  color: #7ffbff;
  text-shadow: 0 0 12px rgba(85, 246, 255, 0.4);
}

.hero-note,
.card-copy,
.modal-copy,
.hint {
  color: rgba(210, 216, 240, 0.76);
}

.hero-note,
.modal-copy {
  margin: 0 auto 16px;
  max-width: 58ch;
  line-height: 1.6;
}

.card-copy {
  margin: 12px 0 0;
  line-height: 1.55;
}

.hint {
  margin: 16px 0 0;
  font-size: 14px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.footer-link {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 52px;
  min-width: 148px;
  padding: 14px 22px;
  border-radius: 16px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.primary-btn {
  color: white;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, rgba(109, 125, 255, 0.96), rgba(255, 79, 216, 0.88));
  box-shadow:
    0 18px 40px rgba(109, 125, 255, 0.22),
    0 16px 40px rgba(255, 79, 216, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.secondary-btn,
.ghost-btn {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
}

.ghost-btn {
  min-width: 128px;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.footer-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active,
.footer-link:active {
  transform: translateY(0) scale(0.99);
}

.zeptai-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.zeptai-tagline {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--cyan);
  letter-spacing: 0.06em;
  font-weight: 500;
}

.zeptai-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.zeptai-btn {
  padding: 8px 16px;
  border: 1px solid rgba(85, 246, 255, 0.3);
  border-radius: 8px;
  background: rgba(85, 246, 255, 0.06);
  color: var(--cyan);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  display: inline-block;
}

.zeptai-btn:hover {
  background: rgba(85, 246, 255, 0.12);
  border-color: rgba(85, 246, 255, 0.5);
  color: #7ffbff;
}

.zeptai-btn:active {
  transform: scale(0.98);
}

.zeptai-btn--secondary {
  border-color: rgba(200, 206, 230, 0.2);
  background: rgba(200, 206, 230, 0.05);
  color: var(--muted);
}

.zeptai-btn--secondary:hover {
  background: rgba(200, 206, 230, 0.12);
  border-color: rgba(200, 206, 230, 0.4);
  color: rgba(245, 248, 255, 0.96);
}

.high-score-message {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(85, 246, 255, 0.08);
  border: 1px solid rgba(85, 246, 255, 0.2);
  color: rgba(127, 251, 255, 0.92);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.high-score-message a {
  color: var(--cyan);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.high-score-message a:hover {
  color: #7ffbff;
  text-shadow: 0 0 12px rgba(85, 246, 255, 0.4);
}

.is-hidden,
[hidden] {
  display: none !important;
}

.cta-row,
.secondary-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.cta-row {
  margin-top: 18px;
}

.cta-row--hero {
  margin-top: 24px;
}

.secondary-row {
  margin-top: 14px;
}

.hero-grid,
.progress-grid {
  display: grid;
  gap: 14px;
}

.hero-grid {
  margin-top: 22px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.progress-grid {
  margin-top: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hero-card,
.progress-card {
  min-width: 0;
  text-align: left;
}

.hero-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
}

.challenge-banner {
  position: absolute;
  top: calc(84px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 198, 92, 0.14);
  border: 1px solid rgba(255, 198, 92, 0.24);
  color: #ffe7b3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  z-index: 18;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.modal-panel {
  width: min(620px, calc(100vw - 32px));
}

.modal-panel--wide {
  width: min(860px, calc(100vw - 32px));
}

.share-url {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  color: rgba(228, 234, 255, 0.86);
  margin-top: 16px;
}

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

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.setting-row span {
  color: rgba(241, 245, 255, 0.9);
}

.setting-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--cyan);
}

.setting-row select {
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 10, 20, 0.8);
  color: var(--text);
}

.achievements-panel {
  margin-top: 22px;
  text-align: left;
}

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

.panel-heading__meta {
  color: rgba(228, 234, 255, 0.82);
  font-size: 13px;
}

.achievement-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.achievement-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.achievement-item.is-unlocked {
  border-color: rgba(85, 246, 255, 0.28);
  background: rgba(85, 246, 255, 0.08);
}

.achievement-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.achievement-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.achievement-state {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.96);
  transform: scale(1.1);
}

.modal-close-btn:active {
  transform: scale(0.95);
}

.pause-badge,
.device-hint,
.app-footer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(12, 14, 28, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.pause-badge,
.device-hint {
  pointer-events: none;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 15;
}

.pause-badge {
  top: calc(18px + env(safe-area-inset-top));
}

.device-hint {
  bottom: calc(70px + env(safe-area-inset-bottom));
  opacity: 0.82;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.pause-badge.visible {
  opacity: 1;
}

.touch-device .device-hint {
  opacity: 0.96;
  bottom: calc(118px + env(safe-area-inset-bottom));
}

.app-footer {
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 18;
  padding: 8px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 10px 14px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(236, 240, 255, 0.84);
  text-decoration: none;
}

.footer-link:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.touch-controls {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  z-index: 18;
}

.touch-device .touch-controls {
  display: flex;
}

.touch-controls__group {
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.touch-controls__group--right {
  max-width: 52vw;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-btn {
  appearance: none;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 14, 28, 0.46);
  color: rgba(245, 248, 255, 0.98);
  min-width: 74px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}

.control-btn:active,
.control-btn.active {
  transform: translateY(1px) scale(0.98);
  background: rgba(109, 125, 255, 0.42);
  border-color: rgba(160, 190, 255, 0.88);
}

.control-btn--action {
  min-width: 94px;
  background: rgba(255, 89, 120, 0.34);
}

@media (max-width: 980px) {
  .hero-grid,
  .progress-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .hud {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
  }

  .hud-card {
    min-width: 96px;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .hud-value {
    font-size: 20px;
  }

  .glass-panel {
    width: min(720px, calc(100vw - 24px));
    padding: 24px 18px;
    border-radius: 24px;
  }

  .hero-grid,
  .progress-grid,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .app-footer {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    transform: none;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 20px;
  }

  .touch-device .device-hint {
    bottom: calc(148px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 680px) {
  .touch-controls {
    left: calc(10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .touch-controls__group {
    gap: 8px;
  }

  .touch-controls__group--right {
    max-width: 56vw;
  }

  .control-btn {
    min-width: 64px;
    min-height: 46px;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 12px;
  }
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    min-height: 56px;
  }
}

@media (pointer: fine) {
  .touch-controls {
    display: none !important;
  }
}
