:root {
  --bg: #070c09;
  --panel: rgba(9, 15, 11, 0.9);
  --panel-solid: #0b120e;
  --line: rgba(183, 255, 60, 0.18);
  --lime: #b7ff3c;
  --lime-dim: #7fbb1f;
  --banana: #ffd63d;
  --text: #e8f2e4;
  --muted: #93a68f;
  --danger: #ff5d78;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(183, 255, 60, 0.12);
  border: 1px solid rgba(183, 255, 60, 0.3);
  color: #dcffa0;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ HUD */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.2s ease;
}

#hud.hidden,
#hud.menu-open {
  opacity: 0;
}

.hud-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  gap: 12px;
}

.hud-top {
  top: 0;
}

.hud-bottom {
  bottom: 0;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(12, 20, 14, 0.92), rgba(8, 13, 10, 0.86));
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
}

.chip-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}

.chip-value {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--banana);
  line-height: 1;
  display: inline-block;
}

.chip-value.pop {
  animation: pop 0.32s cubic-bezier(0.2, 1.6, 0.35, 1);
}

.chip-ghost .chip-value {
  color: var(--lime);
}

@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(236, 255, 220, 0.9);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

#crosshair::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

#crosshair::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
}

.hud-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.hud-hints b {
  color: #d8ffa3;
  font-weight: 700;
}

.hud-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(214, 236, 210, 0.7);
  background: rgba(8, 13, 10, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 7px 11px;
  border-radius: 10px;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
}

/* --------------------------------------------------------------- toasts */

#toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
  width: min(92vw, 620px);
}

.toast {
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  background: rgba(10, 17, 12, 0.94);
  border: 1px solid var(--line);
  color: #e6f6df;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 1.3, 0.4, 1);
  backdrop-filter: blur(8px);
}

.toast.in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.good {
  border-color: rgba(183, 255, 60, 0.45);
  color: #dcffa8;
}

.toast.bad {
  border-color: rgba(255, 93, 120, 0.45);
  color: #ffc3cd;
}

/* ---------------------------------------------------------------- start */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% 0%, rgba(183, 255, 60, 0.1), transparent 60%),
    radial-gradient(900px 500px at 80% 100%, rgba(255, 214, 61, 0.07), transparent 60%),
    rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(9px);
}

.start-card {
  width: min(620px, 100%);
  padding: 40px 44px 34px;
  border-radius: 24px;
  background: linear-gradient(170deg, rgba(14, 22, 16, 0.97), rgba(7, 12, 9, 0.98));
  border: 1px solid rgba(183, 255, 60, 0.2);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.start-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.012) 3px 4px);
  pointer-events: none;
}

.start-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--lime-dim);
  margin-bottom: 14px;
}

.start-card h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 66px);
  line-height: 0.9;
  letter-spacing: 0.04em;
  font-weight: 900;
  color: #f2ffe8;
  text-shadow: 0 0 40px rgba(183, 255, 60, 0.22);
}

.start-card h1 span {
  display: block;
  color: var(--lime);
  font-size: 0.78em;
  letter-spacing: 0.12em;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.25);
}

.start-tagline {
  margin: 18px auto 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 26px 0 26px;
}

.control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.control span {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  font-family: var(--mono);
}

.control kbd {
  font-size: 11px;
}

.play-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 100%;
  padding: 16px 24px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ccff62, #8fdd16);
  color: #10210a;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--sans);
  box-shadow: 0 14px 34px rgba(150, 230, 30, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.14s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.play-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 20px 44px rgba(150, 230, 30, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.play-btn:active {
  transform: translateY(1px) scale(0.995);
}

.play-btn:focus-visible {
  outline: 2px solid var(--banana);
  outline-offset: 3px;
}

.start-fine {
  margin: 16px 0 0;
  font-size: 11px;
  color: rgba(147, 166, 143, 0.85);
  font-family: var(--mono);
  line-height: 1.7;
}

.fatal-title {
  color: var(--danger) !important;
  font-size: 34px !important;
}

/* ----------------------------------------------------------------- menu */

#menu {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(900px 500px at 55% 40%, rgba(0, 0, 0, 0.35), rgba(2, 5, 3, 0.72));
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

.menu-panel {
  width: min(440px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(13, 21, 15, 0.98), rgba(6, 10, 8, 0.98));
  border: 1px solid rgba(183, 255, 60, 0.22);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: menuIn 0.18s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(183, 255, 60, 0.07), transparent);
}

.menu-brand {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #efffe0;
  display: flex;
  align-items: center;
  gap: 9px;
}

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

.logo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.menu-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: right;
  line-height: 1.35;
}

.menu-meta span {
  display: block;
  color: rgba(147, 166, 143, 0.65);
}

.menu-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cfe0c8;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s;
}

.menu-close:hover {
  background: rgba(255, 93, 120, 0.18);
  border-color: rgba(255, 93, 120, 0.45);
  color: #ffd7de;
}

.menu-body {
  overflow-y: auto;
  padding: 6px 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(183, 255, 60, 0.35) transparent;
}

.menu-body::-webkit-scrollbar {
  width: 8px;
}

.menu-body::-webkit-scrollbar-thumb {
  background: rgba(183, 255, 60, 0.28);
  border-radius: 8px;
}

.menu-section h2 {
  margin: 14px 12px 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--lime-dim);
  font-weight: 700;
}

.mod-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.14s ease;
  border: 1px solid transparent;
}

.mod-row:hover {
  background: rgba(183, 255, 60, 0.06);
  border-color: rgba(183, 255, 60, 0.1);
}

.mod-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.mod-label {
  font-size: 13px;
  font-weight: 600;
  color: #e9f5e3;
  letter-spacing: 0.01em;
}

.mod-hint {
  font-size: 10px;
  color: rgba(147, 166, 143, 0.8);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.mod-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #93a68f;
  transition: transform 0.18s cubic-bezier(0.2, 1.4, 0.4, 1), background 0.18s ease;
}

.mod-toggle input:checked ~ .switch {
  background: rgba(183, 255, 60, 0.22);
  border-color: rgba(183, 255, 60, 0.55);
  box-shadow: 0 0 16px rgba(183, 255, 60, 0.22);
}

.mod-toggle input:checked ~ .switch::after {
  transform: translateX(18px);
  background: var(--lime);
  box-shadow: 0 0 10px rgba(183, 255, 60, 0.8);
}

.mod-toggle input:focus-visible ~ .switch {
  outline: 2px solid var(--banana);
  outline-offset: 2px;
}

.mod-range {
  flex-wrap: wrap;
}

.mod-range .mod-text {
  flex: 1 1 auto;
}

.mod-range .mod-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--banana);
  min-width: 48px;
  text-align: right;
}

.mod-range input[type="range"] {
  flex: 1 1 100%;
  appearance: none;
  height: 20px;
  background: transparent;
  cursor: pointer;
  margin: 2px 0 0;
}

.mod-range input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(183, 255, 60, 0.75), rgba(255, 214, 61, 0.55));
}

.mod-range input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #f3ffe1;
  border: 2px solid #6f9b21;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.mod-range input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(183, 255, 60, 0.75), rgba(255, 214, 61, 0.55));
}

.mod-range input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f3ffe1;
  border: 2px solid #6f9b21;
}

.mod-range input[type="range"]:focus-visible {
  outline: none;
}

.mod-range input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(255, 214, 61, 0.35);
}

.mod-action {
  cursor: default;
}

.ghost-btn {
  appearance: none;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d9efcd;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.15s ease, border-color 0.15s, color 0.15s;
  flex: 0 0 auto;
}

.ghost-btn:hover {
  background: rgba(183, 255, 60, 0.14);
  border-color: rgba(183, 255, 60, 0.4);
  color: #eaffc9;
}

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(147, 166, 143, 0.85);
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 620px) {
  .start-card {
    padding: 28px 22px 24px;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-hints {
    display: none;
  }

  .hud-bottom {
    justify-content: flex-end;
  }
}
