:root {
  color-scheme: dark;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background: #0a0d13;
  color: #e2eaf0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --muted: #8c9aa8;
  --lime: #a6f6ff;
  --panel: rgba(14, 19, 28, 0.96);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(72, 105, 130, 0.14), transparent 58%),
    #0a0d13;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 24px;
}

.topbar,
.brand,
.hud,
.hud-group,
.hud-value,
.footer {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  gap: 10px;
  color: #e2eaf0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(166, 246, 255, 0.4);
  border-radius: 9px;
  color: var(--lime);
  font-size: 16px;
  box-shadow: inset 0 0 14px rgba(166, 246, 255, 0.1);
}

.brand-light {
  color: var(--lime);
}

.topbar-note,
.eyebrow,
.hud-label,
.overlay-hint,
.desktop-controls {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.12em;
}

.topbar-note {
  color: #7e8c9a;
  font-size: 10px;
}

.pause-button {
  padding: 8px 13px;
  border: 1px solid rgba(173, 197, 214, 0.19);
  border-radius: 8px;
  background: rgba(24, 31, 43, 0.8);
  color: #c7d1dc;
  font-size: 12px;
  cursor: pointer;
}

.pause-button span {
  color: #8290a0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
}

.pause-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.game-card {
  overflow: hidden;
  border: 1px solid rgba(166, 198, 220, 0.18);
  border-radius: 16px;
  background: #111721;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42), 0 0 60px rgba(91, 153, 184, 0.07);
}

.hud {
  min-height: 76px;
  justify-content: space-between;
  padding: 13px 22px;
  border-bottom: 1px solid rgba(166, 198, 220, 0.13);
  background: var(--panel);
}

.hud-group {
  gap: clamp(12px, 2vw, 24px);
}

.distance-item {
  min-width: 70px;
}

.best-value {
  color: #758493;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 7px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.moonlight-meter {
  width: clamp(120px, 21%, 210px);
  gap: 6px;
}

.darkness-meter {
  width: clamp(110px, 19%, 190px);
  gap: 6px;
}

.moonlight-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.moonlight-percent {
  color: #d6f8ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.moonlight-track {
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(166, 198, 220, 0.2);
  border-radius: 5px;
  background: rgba(4, 10, 25, 0.5);
}

.moonlight-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #718bb8, #a6f6ff);
  box-shadow: 0 0 12px rgba(166, 246, 255, 0.62);
  transition: width 350ms ease-out;
}

.darkness-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #542646, #f04458);
  box-shadow: 0 0 12px rgba(240, 68, 88, 0.55);
  transition: width 180ms linear;
}

.hud-item {
  display: grid;
  gap: 3px;
}

.hud-label {
  color: #8493a3;
  font-size: 9px;
}

.hud-value {
  gap: 6px;
  color: #e2eaf0;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.coin-icon {
  color: var(--lime);
  font-size: 15px;
  text-shadow: 0 0 12px rgba(214, 242, 138, 0.75);
}

.hud-unit {
  color: #9ca9b7;
  font-size: 11px;
  font-weight: 500;
}

.hearts .hud-value {
  color: #ff9b91;
  letter-spacing: 0.1em;
  text-shadow: 0 0 14px rgba(255, 124, 106, 0.22);
}

.ward-status {
  color: #697887;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 7px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ward-status.active {
  color: #d5b4ff;
  text-shadow: 0 0 9px rgba(190, 143, 255, 0.75);
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #111721;
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(90deg, rgba(3, 6, 11, 0.72), rgba(3, 6, 11, 0.38));
  backdrop-filter: blur(3px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(460px, 100%);
  padding: 30px 34px 24px;
  border: 1px solid rgba(166, 246, 255, 0.22);
  border-radius: 14px;
  background: rgba(10, 14, 21, 0.94);
  text-align: center;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.25);
}

.eyebrow {
  color: var(--lime);
  font-size: 9px;
}

h1 {
  margin: 11px 0 9px;
  color: #e7eef4;
  font-size: clamp(30px, 5vw, 45px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
}

.overlay-card p {
  max-width: 350px;
  margin: 0 auto 22px;
  color: #aab8c6;
  font-size: 13px;
  line-height: 1.65;
}

.primary-button {
  min-width: 190px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--lime);
  color: #203124;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(181, 222, 112, 0.21);
  transition: transform 150ms ease, background 150ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: #e2f7a8;
}

.primary-button span {
  padding-left: 6px;
}

.overlay-hint {
  margin-top: 19px;
  color: #8493a3;
  font-size: 8px;
}

kbd {
  display: inline-block;
  min-width: 19px;
  margin: 0 2px;
  padding: 3px 5px;
  border: 1px solid rgba(166, 198, 220, 0.22);
  border-radius: 4px;
  color: #d2e3ed;
  font: inherit;
  letter-spacing: 0;
}

.hint-separator {
  margin: 0 5px;
  color: #4e5b6b;
}

.toast {
  position: absolute;
  top: 18%;
  left: 50%;
  color: #d6f8ff;
  font-size: clamp(14px, 2vw, 20px);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.footer {
  justify-content: space-between;
  gap: 20px;
  padding: 16px 3px 0;
  color: #8493a3;
  font-size: 11px;
}

.footer p {
  margin: 0;
}

.desktop-controls {
  color: #788898;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.desktop-controls span {
  margin: 0 5px;
  color: #4e5b6b;
}

.touch-controls {
  display: none;
  gap: 9px;
}

.touch-button {
  min-width: 48px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(166, 246, 255, 0.24);
  border-radius: 9px;
  background: rgba(23, 32, 43, 0.92);
  color: #d6f8ff;
  font-size: 20px;
  font-weight: 700;
  touch-action: none;
  user-select: none;
}

.jump-button {
  min-width: 66px;
  color: var(--lime);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
}

.pulse-button {
  min-width: 58px;
  color: #a6f6ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9px;
}

.touch-button:active {
  background: #293b4a;
  transform: scale(0.96);
}

@media (max-width: 700px) {
  .game-shell {
    width: min(100% - 24px, 1120px);
    padding-top: 16px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .topbar-note,
  .desktop-controls,
  .footer > p:first-child {
    display: none;
  }

  .game-card {
    border-radius: 12px;
  }

  .hud {
    min-height: 62px;
    padding: 10px 13px;
  }

  .hud-group {
    gap: 10px;
  }

  .distance-item {
    min-width: 48px;
  }

  .best-value {
    font-size: 6px;
  }

  .moonlight-meter {
    width: clamp(68px, 19%, 125px);
  }

  .darkness-meter {
    width: clamp(68px, 19%, 115px);
  }

  .hud-label {
    font-size: 8px;
  }

  .hud-value {
    font-size: 15px;
  }

  .overlay-card {
    padding: 21px 17px 18px;
  }

  .overlay-card p {
    margin-bottom: 14px;
    font-size: 11px;
  }

  .overlay-hint {
    display: none;
  }

  .footer {
    justify-content: center;
    padding-top: 13px;
  }

  .touch-controls {
    display: flex;
  }
}

@media (max-width: 420px) {
  .game-shell {
    width: calc(100% - 16px);
  }

  .brand {
    font-size: 11px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
  }

  .pause-button {
    padding: 7px 10px;
  }

  .hud-group {
    gap: 7px;
  }

  .moonlight-meter {
    width: 62px;
  }

  .darkness-meter {
    width: 62px;
  }

  .ward-status {
    font-size: 6px;
  }

  .hearts .hud-value {
    font-size: 13px;
  }
}
