:root {
  --panel: #0f172a;
  --panel-border: #1e293b;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #f43f5e;
}

body {
  font-family: "Space Grotesk", "Barlow", system-ui, sans-serif;
  position: relative;
  background: #05070f;
}

/* Utility classes replacing Tailwind */
.bg-slate-950 { background-color: #05070f; }
.text-slate-100 { color: #f1f5f9; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }

.min-h-screen { min-height: 100vh; }
.min-h-\[260px\] { min-height: 260px; }

.max-w-6xl { max-width: 72rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-auto { margin-top: auto;  margin-bottom: auto;}

.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.p-3 { padding: 0.75rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.pl-5 { padding-left: 1.25rem; }
.pr-3 { padding-right: 0.75rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.gap-1 { gap: 0.25rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.w-40 { width: 10rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }

.text-left { text-align: left; }
.text-2xl { font-size: 1.5rem; }
.text-lg { font-size: 1.125rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-\[0\.65rem\] { font-size: 0.65rem; }
.font-semibold { font-weight: 600; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-widest { letter-spacing: 0.1em; }
.uppercase { text-transform: uppercase; }
.list-disc { list-style-type: disc; }

.divide-y > * + * { border-top: 1px solid var(--divide-color, #1e293b); }
.divide-slate-800 { --divide-color: #1e293b; }

.hidden { display: none; }

@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-\[1fr_auto_1fr\] { grid-template-columns: 1fr auto 1fr; }
}

.starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
}

.panel {
  background: radial-gradient(circle at top, #0f172a, #0b1120 70%);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.05), 0 8px 24px rgba(15, 23, 42, 0.6);
}

.panel--alert::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  border: 1px solid rgba(244, 63, 94, 0.65);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4), 0 0 30px rgba(244, 63, 94, 0.2);
  animation: alert-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes alert-pulse {
  0% {
    opacity: 0.35;
    box-shadow: 0 0 6px rgba(244, 63, 94, 0.25), 0 0 16px rgba(244, 63, 94, 0.15);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.6), 0 0 36px rgba(244, 63, 94, 0.35);
  }
  100% {
    opacity: 0.35;
    box-shadow: 0 0 6px rgba(244, 63, 94, 0.25), 0 0 16px rgba(244, 63, 94, 0.15);
  }
}

.panel-title {
  padding: 12px 16px 0;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #94a3b8;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  position: relative;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.btn-icon {
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
}

.btn-icon svg {
  display: block;
}

#btn-mute[aria-pressed="true"] {
  color: #94a3b8;
}

#btn-mute[aria-pressed="true"] .mute-x {
  opacity: 1;
}

#btn-mute[aria-pressed="false"] .mute-x {
  opacity: 0;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #22d3ee);
  color: #0b1120;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
  background: #0b1222;
  color: #e2e8f0;
  border: 1px solid #1e293b;
}

.btn-danger {
  background: #f43f5e;
  color: #0b1120;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover {
  transform: translateY(-1px);
}

.btn-malfunction::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  border: 1px solid rgba(244, 63, 94, 0.85);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.45), 0 0 24px rgba(244, 63, 94, 0.25);
  animation: alert-pulse 1.25s ease-in-out infinite;
  pointer-events: none;
}

.stat {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 8px;
}

.input {
  background: #0b1222;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  color: #e2e8f0;
}

.input--compact {
  width: 5.2rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.warp-slider {
  width: 11rem;
}

.log {
  height: 220px;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #e2e8f0;
}

.log-entry {
  margin-bottom: 0.5rem;
}

.grid-cell {
  position: relative;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 6px;
  min-height: 36px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

.galaxy-grid .grid-cell {
  font-size: 0.65rem;
  min-height: 32px;
}

.grid-cell.active {
  outline: 2px solid var(--accent);
}

.grid-cell.scanned {
  background: rgba(56, 189, 248, 0.08);
  color: #e2e8f0;
}

.sector-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 12px;
  background: #0b1222;
}

.grid-cell.shot {
  position: relative;
}

.grid-cell.shot::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 999px;
  opacity: 0.9;
  animation: shot-pulse 220ms ease-out;
}

.grid-cell.shot-player::after {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.9), transparent 70%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.grid-cell.shot-enemy::after {
  background: radial-gradient(circle, rgba(248, 113, 113, 0.9), transparent 70%);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.6);
}

.grid-cell.shot-torpedo::after {
  background: radial-gradient(circle, rgba(250, 204, 21, 0.9), transparent 70%);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
}

@keyframes shot-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.2;
  }
  60% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
}

.grid-cell.explosion {
  animation: boom 700ms ease-out;
}

.grid-cell.explosion .sprite {
  animation: boom-scale 700ms ease-out;
}

body.ship-shake {
  animation: ship-shake 320ms ease-in-out 0s 4;
}

@keyframes ship-shake {
  0% {
    transform: translate3d(0, 0, 0);
  }
  20% {
    transform: translate3d(-6px, 3px, 0);
  }
  40% {
    transform: translate3d(5px, -4px, 0);
  }
  60% {
    transform: translate3d(-4px, -2px, 0);
  }
  80% {
    transform: translate3d(3px, 4px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes boom {
  0% {
    box-shadow: 0 0 0 rgba(248, 113, 113, 0);
  }
  40% {
    box-shadow: 0 0 14px rgba(248, 113, 113, 0.45);
  }
  100% {
    box-shadow: 0 0 0 rgba(248, 113, 113, 0);
  }
}

@keyframes boom-scale {
  0% {
    transform: scale(0.7);
    opacity: 0.2;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.6;
  }
}
.sprite {
  width: 22px;
  height: 22px;
}

.sprite svg {
  width: 100%;
  height: 100%;
}

.enterprise-sprite {
  transform: rotate(var(--ship-rotation, 0deg));
  transition: transform 180ms ease;
  transform-origin: 50% 50%;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 6px;
}

.direction-pad--radial {
  background: radial-gradient(circle at center, rgba(56, 189, 248, 0.12), transparent 60%);
  border-radius: 999px;
  padding: 8px;
}

.command-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.command-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.direction-btn {
  background: #0b1222;
  border: 1px solid #1e293b;
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  transition: background 120ms ease, transform 120ms ease;
}

.direction-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.6);
}

.direction-btn:hover {
  transform: translateY(-1px);
}

.course-dial {
  width: min(70vw, 210px);
  aspect-ratio: 1;
  padding: 16px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(15, 23, 42, 0.85), rgba(2, 6, 23, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.15);
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.6);
  touch-action: none;
  user-select: none;
}

.course-dial.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.course-svg {
  width: 100%;
  height: 100%;
}

.course-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.3);
  stroke-width: 10;
}

.course-track--inner {
  stroke-width: 2;
  stroke-dasharray: 6 8;
  opacity: 0.6;
}

.course-glow {
  fill: none;
  stroke: url(#courseGlow);
  stroke-width: 14;
  opacity: 0.65;
}

.course-handle {
  fill: #38bdf8;
  stroke: #0b1222;
  stroke-width: 4;
  cursor: grab;
  transition: transform 120ms ease;
}

.course-handle:active {
  cursor: grabbing;
}

.course-center {
  fill: #0b1120;
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 2;
}

.course-tick {
  stroke: rgba(226, 232, 240, 0.6);
  stroke-width: 2;
}

.course-tick-half {
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 1.5;
}

.course-label {
  fill: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 2rem 2rem 3rem;
  padding-top: 3.5rem;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-card {
  max-width: 560px;
  background: #0b1222;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-body {
  display: grid;
  gap: 0.75rem;
}

.damage-panel {
  display: grid;
  gap: 0.75rem;
}

.ship-schematic {
  position: relative;
  height: 220px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.enterprise-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ship-node {
  position: absolute;
  padding: 0.35rem 0.65rem;
  width: 150px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.65rem;
  color: #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-align: center;
}

.ship-node[data-system=\"computer\"] { top: 16px; left: 24px; }
.ship-node[data-system=\"shields\"] { top: 60px; left: 24px; }
.ship-node[data-system=\"phasers\"] { top: 104px; left: 24px; }
.ship-node[data-system=\"torpedoes\"] { top: 148px; left: 24px; }
.ship-node[data-system=\"srscan\"] { top: 16px; right: 24px; }
.ship-node[data-system=\"lrscan\"] { top: 60px; right: 24px; }
.ship-node[data-system=\"warp\"] { top: 104px; right: 24px; }

.ship-node.ok {
  border-color: rgba(34, 197, 94, 0.7);
  color: #86efac;
}

.ship-node.damaged {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fecaca;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.35);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.course-actions {
  display: flex;
  justify-content: center;
  padding-top: 0.35rem;
  padding-bottom: 1.75rem;
}
