:root {
  --night: #08111f;
  --ink: #07131d;
  --mist: rgba(134, 218, 216, 0.14);
  --teal: #82f4df;
  --teal-deep: #2ca8a9;
  --sun: #ffc861;
  --ember: #ff7c43;
  --rose: #ff5b6a;
  --paper: #f6f6f1;
  --panel: rgba(8, 18, 31, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  color: var(--paper);
  background:
    radial-gradient(circle at top, rgba(255, 138, 73, 0.22), transparent 38%),
    radial-gradient(circle at 20% 20%, rgba(130, 244, 223, 0.14), transparent 30%),
    linear-gradient(180deg, #10233c 0%, #08111f 50%, #04070c 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.hero-copy {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--sun);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.8rem, 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.deck {
  margin: 0;
  max-width: 720px;
  font-size: 1.1rem;
  color: rgba(246, 246, 241, 0.86);
}

.game-shell {
  position: relative;
}

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

.hud-card,
.control-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hud-card {
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  min-height: 78px;
}

.hud-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(246, 246, 241, 0.65);
}

.hud-card strong {
  font-size: 1.2rem;
  line-height: 1.15;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at top, rgba(255, 200, 97, 0.12), transparent 30%),
    linear-gradient(180deg, #102746, #0b1321);
}

.game-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px;
}

.objective-panel,
.message-panel {
  max-width: 390px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(5, 12, 22, 0.54);
  backdrop-filter: blur(12px);
}

.panel-kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--sun);
  font-size: 0.74rem;
}

.objective-panel p:last-child,
.message-panel {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.35;
}

.message-panel {
  align-self: flex-end;
  max-width: 460px;
  color: var(--teal);
}

.touch-controls-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 12px;
  gap: 14px;
  pointer-events: none;
  z-index: 6;
}

.touch-cluster {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-right {
  align-items: flex-end;
}

.touch-btn {
  min-width: 64px;
  min-height: 64px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    rgba(5, 12, 22, 0.74);
  color: var(--paper);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  touch-action: none;
  user-select: none;
}

.touch-btn.fire {
  min-width: 84px;
  min-height: 84px;
  color: #ffd98f;
}

.touch-btn.action {
  min-width: 78px;
  font-size: 1rem;
}

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

.control-card {
  padding: 18px;
}

.control-card h2 {
  margin: 0 0 14px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.control-card p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.control-card p:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.control-card span {
  color: rgba(246, 246, 241, 0.72);
}

.control-card strong {
  text-align: right;
  color: var(--teal);
}

.touch-controls-card {
  display: none;
}

body.touch-device .keyboard-controls {
  display: none;
}

body.touch-device .touch-controls-card {
  display: block;
}

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

@media (max-width: 880px) {
  .shell {
    width: min(100vw - 20px, 1280px);
    padding-top: 22px;
  }

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

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

  .game-overlay {
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .keyboard-controls {
    display: none;
  }

  .touch-controls-card {
    display: block;
  }

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

@media (max-width: 560px) {
  .hud,
  .controls {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    gap: 10px;
  }

  .objective-panel,
  .message-panel {
    max-width: none;
  }

  .touch-btn {
    min-width: 58px;
    min-height: 58px;
    border-radius: 16px;
  }

  .touch-btn.fire {
    min-width: 76px;
    min-height: 76px;
  }
}
