:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050810;
  color: #f5f7fb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-width: 320px;
}

button {
  font: inherit;
}

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

#game-root,
#game-canvas {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  touch-action: none;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(71, 120, 255, 0.14), transparent 38%),
    linear-gradient(180deg, #050816, #01030a);
}

#game-canvas {
  display: block;
}

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

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

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

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(2, 6, 16, 0.42), rgba(3, 5, 15, 0.84)),
    radial-gradient(circle at 50% 30%, rgba(101, 228, 255, 0.18), transparent 42%),
    radial-gradient(circle at 24% 72%, rgba(255, 99, 183, 0.12), transparent 38%);
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#start-screen[hidden] {
  display: none;
}

#hud[hidden] {
  display: none;
}

.panel {
  width: min(540px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100svh - 48px);
  max-height: calc(100dvh - 48px);
  border: 1px solid rgba(172, 188, 220, 0.3);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 44px);
  background: rgba(6, 12, 27, 0.84);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.kicker {
  margin: 0 0 10px;
  color: #78e0ff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

h1 {
  font-size: clamp(2rem, 7vw, 4rem);
}

h2 {
  font-size: clamp(1.9rem, 6vw, 3.6rem);
}

.lede {
  margin: 18px 0 24px;
  color: #c7d2e5;
  font-size: 1rem;
  line-height: 1.6;
}

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

.primary-button,
.secondary-button {
  min-height: 48px;
  width: 100%;
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 0;
  color: #03111b;
  background: #65e4ff;
}

.primary-button:hover,
.secondary-button:hover {
  background: #94efff;
}

.secondary-button {
  border: 0;
  color: #03111b;
  background: #65e4ff;
}

.gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(199, 210, 229, 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;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin-top: 22px;
  color: #94a7c4;
  font-size: 0.92rem;
}

.controls-grid strong {
  color: #eef6ff;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}

.metric {
  min-width: 92px;
  border: 1px solid rgba(114, 244, 255, 0.22);
  border-radius: 6px;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(9, 17, 34, 0.78), rgba(5, 8, 18, 0.68));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.24);
}

.metric span {
  display: block;
  color: #8ea0bb;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 1.15rem;
}

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

  .hud {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .metric {
    min-width: calc(50% - 4px);
  }
}
