* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1216;
  color: #f5f7f8;
}

button {
  font: inherit;
}

#game-root {
  position: fixed;
  inset: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #0d1216;
  color: #eaf4f8;
  font-size: 18px;
  font-weight: 800;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

body.is-loading #hud,
body.is-loading #start-panel {
  visibility: hidden;
  pointer-events: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 8px;
  align-items: stretch;
}

.metric,
.mission-panel,
.controls,
.message {
  background: rgba(10, 17, 21, 0.72);
  border: 1px solid rgba(234, 244, 248, 0.16);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

.metric {
  min-width: 0;
  border-radius: 8px;
  padding: 8px 10px;
}

.metric span {
  display: block;
  color: #a9b7bd;
  font-size: 11px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.1;
  white-space: nowrap;
}

.mission-panel {
  position: absolute;
  left: 16px;
  top: 82px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 10px 12px;
}

.mission-panel strong {
  display: block;
  font-size: 15px;
}

.mission-panel span {
  display: block;
  margin-top: 4px;
  color: #c9d6d9;
  font-size: 13px;
}

#minimap {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 172px;
  height: 172px;
  border-radius: 8px;
  border: 1px solid rgba(234, 244, 248, 0.18);
  background: rgba(10, 17, 21, 0.74);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.waypoint {
  position: absolute;
  left: 50%;
  top: 74px;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  display: grid;
  place-items: center;
  color: #ffd65a;
  font-size: 34px;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
  transform-origin: 50% 50%;
}

.controls {
  display: none;
}

.message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 18px 20px;
  text-align: center;
  font-size: 18px;
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  background: rgba(5, 9, 12, 0.42);
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
}

.start-dialog {
  width: min(420px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100svh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  box-sizing: border-box;
  border: 1px solid rgba(234, 244, 248, 0.18);
  border-radius: 8px;
  background: rgba(12, 20, 24, 0.86);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.38);
  padding: 22px;
  -webkit-overflow-scrolling: touch;
}

.start-kicker {
  color: #8ed9ee;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.start-dialog h1 {
  margin: 0 0 12px;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(30px, 7vw, 52px);
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
}

.start-dialog p {
  margin: 0 0 16px;
  color: #dceef2;
  line-height: 1.45;
}

.start-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}

.start-controls div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(234, 244, 248, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.start-controls dt {
  color: #8ed9ee;
  font-size: 12px;
  font-weight: 800;
}

.start-controls dd {
  margin: 3px 0 0;
  color: #edf7f8;
  font-size: 12px;
}

.mode-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-actions button {
  min-height: 48px;
  border: 1px solid rgba(234, 244, 248, 0.2);
  border-radius: 8px;
  background: #edf7f8;
  color: #11191d;
  cursor: pointer;
  font-weight: 700;
}

.mode-actions button:last-child {
  background: #edf7f8;
  color: #11191d;
}

.mode-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.start-dialog .gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(220, 238, 242, 0.72);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.gameblocks-credit a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hidden {
  display: none;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric strong {
    font-size: 17px;
  }

  .mission-panel {
    top: 206px;
  }

  .waypoint {
    top: 276px;
  }

  #minimap {
    width: 132px;
    height: 132px;
  }

  .start-dialog {
    padding: 18px;
  }

  .start-dialog h1 {
    font-size: 23px;
  }

  .mode-actions {
    grid-template-columns: 1fr;
  }
}
