:root {
  color-scheme: dark;
  --bg: #020202;
  --ink: #f7f7f2;
  --muted: rgba(247, 247, 242, 0.62);
  --panel: rgba(8, 8, 8, 0.72);
  --panel-strong: rgba(20, 20, 20, 0.9);
  --line: rgba(247, 247, 242, 0.18);
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
  min-height: 460px;
  overflow: hidden;
  background: #000;
}

.game-shell.is-intro #game-canvas,
.game-shell.is-intro .hud {
  opacity: 0;
  pointer-events: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 520ms ease;
}

.intro-message {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 520ms ease;
}

.game-shell.is-intro .intro-message {
  opacity: 1;
}

.intro-message p {
  width: min(680px, 88vw);
  margin: 0;
  display: grid;
  gap: 0.95em;
  color: var(--ink);
  font-size: clamp(28px, 5.6vw, 62px);
  font-weight: 760;
  line-height: 1.03;
  letter-spacing: 0;
  text-align: center;
  text-wrap: balance;
}

.intro-message p span {
  display: block;
}

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

.controls {
  pointer-events: auto;
}

.title-block {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 176px));
  min-width: 0;
  text-align: center;
  transition: opacity 360ms ease;
}

h1 {
  margin: 0;
  color: rgba(247, 247, 242, 0.94);
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.05;
  font-weight: 780;
  letter-spacing: 0;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
}

.controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px var(--shadow);
  backdrop-filter: blur(14px);
  transition: opacity 360ms ease;
}

.controls button {
  min-width: 72px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(247, 247, 242, 0.22);
  border-radius: 7px;
  background: rgba(247, 247, 242, 0.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
}

.controls button[hidden] {
  display: none;
}

.controls .replay-button {
  min-width: 118px;
}

.controls button:disabled {
  cursor: default;
  opacity: 0.58;
}

.controls button:hover,
.controls button:focus-visible {
  background: rgba(247, 247, 242, 0.15);
  border-color: rgba(247, 247, 242, 0.38);
  outline: none;
}

@media (max-width: 680px) {
  .title-block {
    top: 13px;
    width: min(260px, calc(100vw - 104px));
  }

  h1 {
    font-size: 17px;
    line-height: 1.08;
  }

  .intro-message {
    padding: 22px;
  }

  .intro-message p {
    width: min(340px, 90vw);
    gap: 1em;
    font-size: clamp(26px, 9vw, 42px);
    line-height: 1.05;
  }

  .controls {
    right: 12px;
    bottom: 12px;
    gap: 6px;
    padding: 5px;
  }

  .controls button {
    min-width: 52px;
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  .controls .replay-button {
    min-width: 98px;
  }
}

@media (max-width: 430px) {
  .title-block {
    top: 12px;
    width: min(210px, calc(100vw - 96px));
  }

  h1 {
    font-size: 15px;
  }

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

  .controls button {
    width: 54px;
    height: 29px;
    padding: 0 6px;
  }

  .controls .replay-button {
    width: 98px;
  }
}

@supports not (height: 100dvh) {
  @media (max-width: 430px) {
    .controls {
      bottom: max(96px, calc(env(safe-area-inset-bottom) + 72px));
    }
  }
}
