:root {
  color-scheme: dark;
  --ink: #f4f1df;
  --night: #071827;
  --blue: #6598aa;
  --blue-deep: #355d70;
  --red: #ac685b;
  --red-deep: #704037;
  --amber: #c6a25e;
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  color: inherit;
  font: inherit;
}

#game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
  background: #77b9c9;
  isolation: isolate;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  z-index: 4;
  top: max(7px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(130px, 230px) 1fr minmax(130px, 230px);
  align-items: start;
  gap: 12px;
  pointer-events: none;
}

.hud-card {
  min-width: 0;
  padding: 7px 9px 8px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 9px;
  background: rgba(5, 18, 29, 0.69);
  box-shadow: 0 4px 18px rgba(3, 11, 18, 0.18);
  backdrop-filter: blur(5px);
}

.hud-card--blue {
  border-left: 3px solid var(--blue);
}

.hud-card--red {
  border-right: 3px solid var(--red);
}

.hud-name {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.hud-card--red .hud-name {
  text-align: right;
}

.meter-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.73);
  font-size: 8px;
  font-weight: 800;
}

.hud-card--red .meter-row {
  grid-template-columns: 1fr 38px;
}

.hud-card--red .meter-row span {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}

.hud-card--red .meter {
  grid-column: 1;
  grid-row: 1;
}

.meter {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 150ms linear;
}

.hud-card--red .meter i {
  margin-left: auto;
  background: var(--red);
}

.hud-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding-top: 1px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.icon-button {
  width: 29px;
  height: 29px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 7px;
  background: rgba(5, 18, 29, 0.62);
  pointer-events: auto;
}

.controls {
  position: absolute;
  z-index: 5;
  bottom: max(13px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, var(--button-size));
  gap: 8px;
  pointer-events: none;
  --button-size: clamp(58px, 8.8vw, 72px);
}

.controls--left {
  left: max(12px, env(safe-area-inset-left));
}

.controls--right {
  right: max(12px, env(safe-area-inset-right));
}

.control {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--button-size);
  height: var(--button-size);
  padding: 0;
  border: 2px solid currentColor;
  border-radius: 11px;
  background: rgba(18, 29, 34, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 10px rgba(1, 10, 17, 0.2);
  color: var(--blue);
  pointer-events: auto;
  touch-action: none;
  transition: transform 60ms ease, background 60ms ease, filter 60ms ease;
}

.control--red {
  color: var(--red);
}

.control--roll {
  border-style: dashed;
}

.control--fire {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(52, 28, 8, 0.72);
}

.control.is-active {
  transform: translateY(2px) scale(0.94);
  background: currentColor;
  color: #071827;
  filter: brightness(1.12);
}

.control.is-cooling {
  filter: saturate(0.25) brightness(0.7);
}

.control-icon {
  font-family: system-ui, sans-serif;
  font-size: clamp(23px, 3.5vw, 29px);
  font-weight: 900;
  line-height: 0.9;
}

.control-label {
  margin-top: 4px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(14, 56, 73, 0.48), rgba(2, 12, 20, 0.86));
  backdrop-filter: blur(5px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

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

.briefing-card {
  width: min(480px, 88vw);
  padding: 25px 28px 22px;
  border: 1px solid rgba(255, 255, 255, 0.29);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(9, 31, 47, 0.96), rgba(4, 17, 28, 0.96));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.briefing-card--compact {
  width: min(380px, 84vw);
}

.eyebrow {
  color: var(--amber);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.briefing-card h1,
.briefing-card h2 {
  margin: 5px 0 8px;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(38px, 8vw, 62px);
  font-style: italic;
  letter-spacing: 0.045em;
  line-height: 0.95;
  text-shadow: 4px 4px 0 rgba(55, 169, 255, 0.4), -3px -2px 0 rgba(255, 90, 82, 0.27);
}

.briefing-card h2 {
  font-size: clamp(32px, 7vw, 52px);
}

.briefing-card p {
  margin: 0 auto 13px;
  max-width: 390px;
  color: rgba(255, 255, 255, 0.72);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

.pilot-key {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 12px 0 15px;
  font-size: 9px;
  font-weight: 800;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
}

.dot--blue {
  background: var(--blue);
  box-shadow: 0 0 10px var(--blue);
}

.dot--red {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
}

.primary-button {
  min-width: 210px;
  min-height: 46px;
  padding: 11px 20px;
  border: 1px solid #ffe1a4;
  border-radius: 11px;
  background: var(--amber);
  box-shadow: 0 5px 0 #a8650d, 0 10px 25px rgba(0, 0, 0, 0.32);
  color: #1b1c16;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.1em;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #a8650d;
}

.mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-buttons .primary-button {
  min-width: 0;
  min-height: 54px;
  padding-inline: 12px;
}

.mode-buttons .primary-button span {
  display: block;
  margin-top: 3px;
  font-size: 8px;
  letter-spacing: 0.08em;
  opacity: 0.68;
}

.primary-button--secondary {
  border-color: rgba(255, 255, 255, 0.45);
  background: #263f4b;
  box-shadow: 0 5px 0 #13252e, 0 10px 25px rgba(0, 0, 0, 0.32);
  color: #e8e5d5;
}

#game-shell.is-single-player .controls--right {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.briefing-card small {
  display: block;
  margin-top: 13px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 8px;
}

.rotate-prompt {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--night);
  text-align: center;
}

.rotate-prompt strong {
  font-size: 15px;
  letter-spacing: 0.1em;
}

.rotate-prompt span {
  color: rgba(255, 255, 255, 0.55);
  font-size: 10px;
}

.phone-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 86px;
  margin-bottom: 14px;
  border: 3px solid var(--amber);
  border-radius: 10px;
  color: var(--amber);
  font-family: system-ui, sans-serif;
  font-size: 31px;
  animation: tilt 1.8s ease-in-out infinite;
}

@keyframes tilt {
  0%, 28% { transform: rotate(0deg); }
  72%, 100% { transform: rotate(90deg); }
}

@media (orientation: portrait) {
  .rotate-prompt {
    display: flex;
  }
}

@media (max-height: 390px) {
  .controls {
    --button-size: clamp(52px, 16vh, 62px);
    gap: 6px;
  }

  .control {
    border-radius: 15px;
  }

  .hud {
    top: max(4px, env(safe-area-inset-top));
  }

  .hud-card {
    padding: 5px 7px 6px;
  }

  .briefing-card {
    padding: 18px 24px 16px;
  }

  .briefing-card h1 {
    font-size: 42px;
  }

  .briefing-card p {
    font-size: 11px;
  }
}

@media (max-width: 680px) and (orientation: landscape) {
  .hud {
    grid-template-columns: 118px 1fr 118px;
  }

  .hud-center > span {
    display: none;
  }
}
