:root {
  color-scheme: dark;
  --bg: #0e1015;
  --panel: #171b22;
  --panel-strong: #202631;
  --ink: #f7f3e8;
  --muted: #aab2bd;
  --line: rgba(255, 255, 255, 0.15);
  --teal: #39d6c7;
  --coral: #ff6f61;
  --gold: #ffd166;
  --mint: #75e39a;
  --violet: #b98cff;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 18% 8%, rgba(57, 214, 199, 0.14), transparent 24rem),
    radial-gradient(circle at 82% 10%, rgba(255, 209, 102, 0.12), transparent 24rem),
    linear-gradient(145deg, #101219 0%, #16151f 52%, #11161b 100%);
  color: var(--ink);
  overflow-x: hidden;
}

button {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.game-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(12px, 2.4vw, 28px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.8vw, 18px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(132px, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  color: var(--ink);
  font-size: clamp(1.35rem, 4vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 3px 0 rgba(255, 111, 97, 0.55);
}

.hud {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.hud-item {
  min-width: 82px;
  padding: 9px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.78);
  box-shadow: 0 12px 26px var(--shadow);
  text-align: center;
}

.hud-item span {
  display: block;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.hud-item strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.overlay-action,
.touch-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(42, 48, 60, 0.95), rgba(24, 28, 36, 0.95));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    0 12px 28px var(--shadow);
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.icon-button {
  width: 42px;
  height: 42px;
}

.icon-button:hover,
.overlay-action:hover,
.touch-button:hover,
.icon-button:focus-visible,
.overlay-action:focus-visible,
.touch-button:focus-visible {
  border-color: rgba(57, 214, 199, 0.7);
  outline: 0;
  transform: translateY(-1px);
}

.icon-button:active,
.overlay-action:active,
.touch-button:active,
.touch-button.is-held {
  transform: translateY(1px);
  background: linear-gradient(180deg, rgba(50, 58, 72, 1), rgba(30, 35, 44, 1));
}

.stage {
  position: relative;
  align-self: center;
  justify-self: center;
  width: min(100%, calc((100svh - 156px) * 1.5));
  max-height: calc(100svh - 156px);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #12161d;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 22px;
  background: rgba(14, 16, 21, 0.54);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 9vw, 5.7rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.9;
  text-align: center;
  text-shadow:
    0 5px 0 rgba(255, 111, 97, 0.6),
    0 10px 24px rgba(0, 0, 0, 0.4);
}

.overlay p {
  min-height: 1.6em;
  margin: 0;
  color: var(--gold);
  font-size: clamp(0.95rem, 2.6vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.overlay-action {
  width: 54px;
  height: 54px;
  color: var(--teal);
}

.icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}

.icon-play {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid currentColor;
}

.icon-pause::before,
.icon-pause::after {
  position: absolute;
  top: 2px;
  width: 6px;
  height: 16px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.icon-pause::before {
  left: 4px;
}

.icon-pause::after {
  right: 4px;
}

.icon-restart::before {
  position: absolute;
  inset: 3px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
}

.icon-restart::after {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  content: "";
  transform: rotate(-22deg);
}

.touch-pad {
  display: none;
  grid-template-columns: 1fr 72px 1fr;
  gap: 10px;
  width: min(560px, 100%);
  margin: 0 auto;
}

.touch-button {
  height: 54px;
  color: var(--ink);
  user-select: none;
  touch-action: none;
}

.touch-launch {
  color: var(--teal);
}

.touch-arrow {
  display: block;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
}

.touch-arrow-left {
  border-right: 17px solid currentColor;
}

.touch-arrow-right {
  border-left: 17px solid currentColor;
}

@media (max-width: 760px) {
  .game-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand toolbar"
      "hud hud";
    gap: 10px;
  }

  .brand {
    grid-area: brand;
  }

  .hud {
    grid-area: hud;
    justify-content: stretch;
  }

  .hud-item {
    min-width: 0;
    flex: 1;
    padding: 8px 9px;
  }

  .toolbar {
    grid-area: toolbar;
  }

  .stage {
    align-self: start;
    width: 100%;
    max-height: none;
  }

  .touch-pad {
    display: grid;
  }
}

@media (max-width: 440px) {
  .brand {
    font-size: 1.28rem;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .hud-item span {
    font-size: 0.63rem;
  }

  .hud-item strong {
    font-size: 0.94rem;
  }

  .touch-pad {
    grid-template-columns: 1fr 62px 1fr;
  }

  .touch-button {
    height: 50px;
  }
}

@media (pointer: coarse) {
  .touch-pad {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }
}
