*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: #050607;
  color: #d6dce0;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030405;
}

#viewport-wrap {
  position: relative;
  width: 100vw;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

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

.hidden {
  display: none !important;
}

#kill-banner {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(22px, 3.6vw, 38px);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #f02c2c;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0    2px 10px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 20;
  animation: bannerPop 0.22s ease-out;
}

@keyframes bannerPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#shot-feedback {
  position: absolute;
  top: calc(max(18px, env(safe-area-inset-top)) + 44px);
  left: max(20px, env(safe-area-inset-left));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9be8a4;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 20;
}

#status-pill {
  position: absolute;
  bottom: calc(max(56px, env(safe-area-inset-bottom) + 46px));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(8, 10, 11, 0.84);
  border: 1px solid rgba(110, 231, 120, 0.45);
  color: #8df09a;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

/* Mobile Touch Controls */
#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 22;
}

.touch-left {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(max(66px, env(safe-area-inset-bottom) + 56px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.touch-right {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(66px, env(safe-area-inset-bottom) + 56px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  min-width: 72px;
  padding: 11px 12px;
  background: rgba(8, 11, 12, 0.62);
  border: 1px solid rgba(94, 226, 110, 0.48);
  color: #c7f7cd;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  touch-action: none;
}

.touch-btn.active,
.touch-btn:active {
  background: rgba(94, 226, 110, 0.32);
  border-color: #6df27d;
  color: #ffffff;
}

.touch-fire {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: rgba(220, 42, 42, 0.34);
  border: 2px solid rgba(255, 92, 92, 0.82);
  color: #ffe2e2;
  font-size: 13px;
  letter-spacing: 0.14em;
  box-shadow: 0 0 24px rgba(220, 42, 42, 0.25);
}

.touch-fire:active {
  background: rgba(235, 52, 52, 0.65);
  transform: scale(0.95);
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 8, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 30;
  cursor: default;
  overflow-y: auto;
  touch-action: pan-y;
}

.landing-overlay {
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(5, 7, 8, 0.68) 0%, rgba(5, 7, 8, 0.84) 55%, rgba(4, 6, 7, 0.92) 100%);
}

.landing-shell {
  width: min(860px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 0 18px;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(12, 15, 18, 0.84);
  border: 1px solid #262e34;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #f0f4f7;
}

.nav-logo {
  width: 28px;
  height: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
}

.nav-links a {
  color: #9aa4ac;
  text-decoration: none;
  letter-spacing: 0.08em;
}

.nav-links a:hover {
  color: #5ee26e;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: rgba(94, 226, 110, 0.09);
  border: 1px solid rgba(94, 226, 110, 0.35);
  color: #79eb86;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef3b3b;
  box-shadow: 0 0 8px #ef3b3b;
}

.hero-card {
  background: linear-gradient(180deg, rgba(16, 20, 23, 0.9), rgba(9, 11, 13, 0.94));
  border: 1px solid #2b343b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
  padding: 24px 26px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}

.hero-logo {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  filter: drop-shadow(0 8px 24px rgba(72, 235, 90, 0.18));
}

.hero-copy h1 {
  font-size: clamp(28px, 5.2vw, 40px);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #f5f8fa;
  margin-bottom: 6px;
}

.hero-cta-row {
  margin-bottom: 18px;
}

.hero-play {
  padding: 15px 22px;
  font-size: 14px;
  box-shadow: 0 0 28px rgba(72, 201, 88, 0.25);
}

.setup-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: #7d8890;
  margin-bottom: 8px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.feat {
  padding: 10px 11px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid #22292f;
}

.feat-title {
  font-size: 11px;
  font-weight: 700;
  color: #e6edf2;
  margin-bottom: 4px;
}

.feat-desc {
  font-size: 10px;
  line-height: 1.4;
  color: #849099;
}

.landing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #6d7882;
}

.landing-footer a {
  color: #7d8994;
  text-decoration: none;
}

.landing-footer a:hover {
  color: #5ee26e;
}

@media (max-width: 720px) {
  .hero-top {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .hero-logo {
    width: 76px;
    height: 76px;
  }
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .live-pill {
    display: none;
  }
  .landing-footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

.panel {
  width: min(640px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(20, 23, 26, 0.96), rgba(11, 13, 15, 0.98));
  border: 1px solid #2b3238;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75);
  padding: 22px 24px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #5ee26e;
  margin-bottom: 6px;
}

.panel h1, .panel h2 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f0f4f7;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 12px;
  line-height: 1.5;
  color: #9aa4ac;
  margin-bottom: 14px;
}

.sector-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.sector-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid #283036;
  color: #cfd7dc;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.sector-btn.active {
  border-color: #5ee26e;
  background: rgba(94, 226, 110, 0.08);
}

.sector-num {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #5ee26e;
}

.sector-name {
  font-size: 12px;
  font-weight: 700;
  color: #f0f4f7;
}

.sector-meta {
  font-size: 10px;
  line-height: 1.3;
  color: #7d8890;
}

.mode-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.toggle-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #252c31;
  font-size: 11px;
  color: #b7c1c8;
  cursor: pointer;
}

.toggle-chip input {
  accent-color: #5ee26e;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #20262b;
  font-size: 11px;
  color: #9ba5ad;
}

.mobile-controls {
  display: none;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  background: #1a2024;
  border: 1px solid #353f47;
  color: #e2eaef;
  font-family: inherit;
  font-size: 10px;
}

.primary-btn {
  width: 100%;
  padding: 13px 18px;
  background: #48c958;
  border: none;
  color: #061108;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
}

.primary-btn:hover {
  background: #5ee26e;
}

.secondary-btn {
  padding: 12px 14px;
  background: transparent;
  border: 1px solid #353f47;
  color: #cfd7dc;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.badge-row {
  margin-top: 12px;
  text-align: center;
}

.dotframe-link {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #6e7982;
  text-decoration: none;
}

.dotframe-link:hover {
  color: #5ee26e;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 16px;
}

.stat-card {
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #232a2f;
}

.stat-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #7d8890;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #eef3f6;
}

.debrief-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

/* Mobile & coarse-pointer optimizations */
@media (pointer: coarse), (max-width: 768px) {
  .desktop-controls {
    display: none;
  }
  .mobile-controls {
    display: grid;
  }
  .panel {
    padding: 16px;
  }
  .sector-picker {
    grid-template-columns: 1fr;
  }
  .mode-row {
    flex-direction: column;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .debrief-actions {
    grid-template-columns: 1fr;
  }
}
