:root {
  color-scheme: dark;
  --ink: #f7f2df;
  --muted: rgba(247, 242, 223, 0.7);
  --panel: rgba(2, 2, 5, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  --accent: #ffd447;
  --accent-strong: #ff3b38;
  --blue: #3fd5ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Arial,
    sans-serif;
}

button {
  font: inherit;
}

.game-menu-link {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.game-menu-link:hover,
.game-menu-link:focus-visible {
  background: rgba(255, 212, 71, 0.24);
  outline: none;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 460px;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 120%, rgba(255, 212, 71, 0.13), transparent 36%),
    linear-gradient(#020204, #000 48%, #030303);
}

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

.hud {
  position: absolute;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud div {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.42));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hud span,
.hud strong {
  display: block;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud span {
  color: var(--muted);
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
}

.hud strong {
  margin-top: 3px;
  color: #fff;
  font-size: clamp(1.12rem, 3vw, 1.55rem);
}

.title-panel {
  position: absolute;
  z-index: 4;
  inset: auto 50% 16%;
  width: min(92vw, 500px);
  transform: translateX(50%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 26px 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.52);
  text-align: center;
  backdrop-filter: blur(12px);
}

.title-panel[hidden] {
  display: none;
}

.eyebrow,
.title-panel p,
.title-panel h1 {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(0.82rem, 2.1vw, 1rem);
}

.title-panel h1 {
  color: #fff;
  font-size: clamp(2.25rem, 8vw, 4.7rem);
  line-height: 0.9;
  text-shadow:
    0 0 18px rgba(255, 212, 71, 0.45),
    0 4px 0 rgba(255, 59, 56, 0.62);
}

.title-panel p:not(.eyebrow) {
  max-width: 36ch;
  color: var(--muted);
  font-size: clamp(0.98rem, 2.6vw, 1.14rem);
  line-height: 1.45;
}

.primary-action,
.touch-controls button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #090909;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
  box-shadow:
    0 9px 0 #ad871a,
    0 20px 38px rgba(0, 0, 0, 0.36);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
}

.primary-action {
  min-width: 160px;
  padding: 0 24px;
  font-size: 1.08rem;
}

.primary-action:hover,
.touch-controls button:hover {
  filter: brightness(1.08);
}

.primary-action:active,
.touch-controls button:active {
  transform: translateY(4px);
  box-shadow:
    0 5px 0 #ad871a,
    0 12px 22px rgba(0, 0, 0, 0.42);
}

.touch-controls {
  position: absolute;
  z-index: 3;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  gap: 12px;
  pointer-events: none;
}

.touch-controls button {
  height: 54px;
  pointer-events: auto;
  font-size: 2rem;
  line-height: 1;
}

#pauseButton {
  background: var(--blue);
  box-shadow:
    0 9px 0 #157d9e,
    0 20px 38px rgba(0, 0, 0, 0.36);
  font-size: 1.32rem;
}

@media (min-width: 720px) {
  .hud {
    left: auto;
    width: min(40vw, 390px);
  }

  .title-panel {
    bottom: 12%;
  }

  .touch-controls {
    right: auto;
    left: 22px;
    width: 280px;
  }
}

@media (max-width: 719px) {
  .game-menu-link {
    top: 82px;
  }
}

@media (max-height: 580px) {
  .title-panel {
    bottom: 11%;
    padding: 18px;
    gap: 8px;
  }

  .touch-controls button {
    height: 46px;
  }
}
