:root {
  color-scheme: dark;
  --panel: rgba(14, 20, 24, 0.82);
  --panel-border: rgba(222, 231, 230, 0.22);
  --text: #f4f7f6;
  --muted: #aebcbd;
  --accent: #77f0cf;
  --warn: #ffc86b;
}

* {
  box-sizing: border-box;
}

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

button {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 0.8rem 1.1rem;
  background: #dceae7;
  color: #111719;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: rgba(119, 240, 207, 0.12);
  color: var(--text);
}

button:focus-visible,
#game-canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

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

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

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

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

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  min-width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 1.35rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.hud-row + .hud-row {
  margin-top: 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

#progress-track {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

#progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warn));
  transition: width 140ms ease;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.86;
}

#crosshair span {
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(244, 247, 246, 0.92);
  box-shadow: 0 0 8px rgba(119, 240, 207, 0.78);
  transform: translate(-50%, -50%);
}

#crosshair span:first-child {
  width: 2px;
  height: 24px;
}

#crosshair span:last-child {
  width: 24px;
  height: 2px;
}

.modal-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  max-height: calc(100dvh - 32px);
  transform: translate(-50%, -50%);
  padding: 26px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(13, 18, 21, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-panel h1 {
  margin: 0 0 8px;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
  white-space: nowrap;
}

.modal-panel p {
  margin: 0 0 20px;
  max-width: 34rem;
  color: #d8e1e0;
  line-height: 1.45;
}

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

.modal-panel dl div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.modal-panel dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-panel dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(320px, 100%);
  margin: 0 auto;
}

.button-row button {
  width: 100%;
}

.button-row button.secondary {
  background: #dceae7;
  color: #111719;
}

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

.modal-panel .gameblocks-credit {
  width: 100%;
  margin: 18px 0 0;
  color: rgba(216, 225, 224, 0.68);
  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: 560px) {
  #hud {
    top: 10px;
    left: 10px;
    min-width: calc(100vw - 20px);
  }

  .modal-panel {
    padding: 20px;
  }

  .modal-panel dl {
    grid-template-columns: 1fr;
  }
}
