:root {
  --sky: #5c94fc;
  --gold: #f8d030;
  --cream: #fff8e7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  font-family: "Press Start 2P", monospace;
  color: var(--cream);
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px 22px 0;
  pointer-events: none;
  text-shadow:
    3px 3px 0 #000,
    -1px 0 #000,
    0 -1px #000,
    1px 0 #000;
}

.mute-btn {
  pointer-events: auto;
  align-self: start;
  margin-top: 2px;
  width: 42px;
  height: 42px;
  border: 3px solid #111;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffe566, #f0b400);
  box-shadow: 0 3px 0 #8a6500;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  text-shadow: none;
}

.mute-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #8a6500;
}

.mute-btn.muted {
  background: linear-gradient(180deg, #bbb, #888);
  box-shadow: 0 3px 0 #555;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: clamp(11px, 1.6vw, 16px);
}

.hud-item:nth-child(3),
.hud-item:nth-child(4) {
  align-items: flex-end;
}

.hud .brand {
  font-size: clamp(14px, 2vw, 20px);
  color: var(--gold);
  letter-spacing: 1px;
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.mode-badge {
  font-size: clamp(7px, 0.9vw, 9px);
  color: #0d1b2a;
  background: var(--gold);
  padding: 5px 8px;
  border: 2px solid #111;
  letter-spacing: 0.5px;
  text-shadow: none;
}

.label {
  font-size: clamp(8px, 1vw, 10px);
  opacity: 0.85;
  letter-spacing: 1px;
}

.stage-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #000a, #000c);
  backdrop-filter: blur(3px);
  transition: opacity 0.25s ease;
  z-index: 10;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.panel {
  width: min(560px, 92vw);
  padding: 32px 28px;
  text-align: center;
  background: linear-gradient(180deg, #3d7ed6, #2457a8);
  border: 4px solid #111;
  box-shadow:
    0 0 0 4px var(--gold),
    10px 10px 0 #0007;
}

.panel-wide {
  width: min(920px, 94vw);
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 22px;
  text-align: left;
}

.mode-picker.hidden {
  display: none;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  font: inherit;
  color: #e8f1ff;
  text-align: left;
  background: #0f2448cc;
  border: 3px solid #1a3a6e;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.mode-card:hover {
  border-color: #7ab0fc;
  transform: translateY(-2px);
}

.mode-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px #f8d03066;
  background: #163566;
}

.mode-icon {
  font-size: 18px;
  line-height: 1;
}

.mode-name {
  font-size: clamp(8px, 1.1vw, 11px);
  color: var(--gold);
  line-height: 1.4;
}

.mode-desc {
  font-size: clamp(7px, 0.95vw, 9px);
  line-height: 1.55;
  color: #c5d8f5;
  opacity: 0.95;
}

.agent-chip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 6;
  font-size: clamp(8px, 1vw, 10px);
  padding: 8px 12px;
  color: #0d1b2a;
  background: linear-gradient(180deg, #9ef0a0, #3ecf4a);
  border: 3px solid #111;
  box-shadow: 0 3px 0 #1a6b22;
  pointer-events: none;
  letter-spacing: 0.5px;
}

.agent-chip.override {
  background: linear-gradient(180deg, #ffe566, #f0b400);
  box-shadow: 0 3px 0 #8a6500;
}

.agent-chip.hidden {
  display: none;
}

.panel h1 {
  font-size: clamp(20px, 4vw, 32px);
  color: var(--gold);
  margin-bottom: 18px;
  text-shadow: 3px 3px 0 #000;
  line-height: 1.35;
}

.panel p {
  font-size: clamp(8px, 1.2vw, 11px);
  line-height: 1.85;
  margin-bottom: 20px;
  color: #e8f1ff;
}

.controls {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  font-size: clamp(8px, 1.1vw, 10px);
  line-height: 1.6;
  color: #dce9ff;
}

.controls.hidden {
  display: none;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 5px 7px;
  margin: 0 2px;
  background: #111;
  border: 2px solid #eee;
  border-bottom-width: 4px;
  border-radius: 4px;
  font: inherit;
  font-size: inherit;
  color: var(--gold);
}

#start-btn {
  font: inherit;
  font-size: clamp(11px, 1.5vw, 14px);
  padding: 16px 26px;
  color: #1a1a2e;
  background: linear-gradient(180deg, #ffe566, #f0b400);
  border: 3px solid #111;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 6px 0 #8a6500;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

#start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #8a6500;
}

#start-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8a6500;
}

@media (max-width: 900px) {
  .mode-picker {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .hud {
    grid-template-columns: 1fr 1fr auto;
    padding: 10px 12px 0;
  }

  .hud .brand {
    grid-column: 1 / -1;
    order: -1;
  }

  .hud-item:nth-child(3),
  .hud-item:nth-child(4) {
    align-items: flex-start;
  }

  .mute-btn {
    grid-column: 3;
    grid-row: 2;
  }
}
