:root {
  --bg: #0b0c0f;
  --fg: #e9e6de;
  --dim: #8b8d94;
  --red: #e2262b;
  --line: rgba(233, 230, 222, 0.14);
  --glass: rgba(16, 17, 21, 0.72);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Manrope', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* виньетка + зерно */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(5, 6, 8, 0.75) 100%);
}
#grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- пилюли ---------- */
#pills { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.pillwrap {
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  will-change: transform;
}
.floaty {
  font-size: 30px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -9px; } }
.pill {
  pointer-events: auto;
  transform: translateX(0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.22em;
  color: var(--fg);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.25s, box-shadow 0.25s, scale 0.25s;
}
.pillwrap.near .pill {
  border-color: var(--acc, #fff);
  box-shadow: 0 0 22px color-mix(in srgb, var(--acc, #fff) 35%, transparent);
  scale: 1.08;
}
.pillwrap.done .pill::after {
  content: ' ✓';
  color: #57c84d;
  letter-spacing: 0;
}
.pill { --acc: #fff; }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 4; font-family: 'JetBrains Mono', monospace; }
#logo {
  top: 20px; left: 24px;
  display: flex; align-items: center; gap: 12px;
  user-select: none;
}
#logo .mark {
  width: 34px; height: 34px; border: 1.5px solid var(--fg); border-radius: 4px;
  display: grid; place-items: center;
  font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 15px;
  background: linear-gradient(180deg, transparent 49%, var(--red) 49%);
}
#logo .name { font-size: 12px; letter-spacing: 0.28em; font-weight: 700; }
#logo .name em { display: block; font-style: normal; color: var(--dim); font-size: 9px; letter-spacing: 0.34em; margin-top: 3px; }

#progress {
  top: 22px; left: 50%; translate: -50% 0;
  font-size: 11px; letter-spacing: 0.3em; color: var(--dim);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 16px; background: var(--glass);
  backdrop-filter: blur(8px);
}

#menu { top: 20px; right: 24px; text-align: right; }
#menu-btn {
  font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.26em;
  color: var(--fg); background: var(--glass);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 18px; cursor: pointer;
  backdrop-filter: blur(8px);
}
#menu-btn:hover { border-color: var(--fg); }
#menu-list {
  display: none;
  margin-top: 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(14px);
  overflow: hidden;
  min-width: 260px;
}
#menu.open #menu-list { display: block; }
#menu-list button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 600;
  color: var(--fg); background: none; border: none;
  border-bottom: 1px solid rgba(233, 230, 222, 0.07);
  padding: 11px 16px; cursor: pointer;
}
#menu-list button:last-child { border-bottom: none; }
#menu-list button:hover { background: rgba(233, 230, 222, 0.06); }
#menu-list i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
#menu-list em { font-style: normal; color: var(--dim); font-size: 11px; margin-left: auto; }

#hint, #action {
  bottom: 26px; left: 50%; translate: -50% 0;
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--dim);
  background: var(--glass); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 18px; backdrop-filter: blur(8px);
  white-space: nowrap;
  transition: opacity 0.8s;
}
#hint.fade { opacity: 0; }
#action { bottom: 64px; color: var(--fg); opacity: 0; transition: opacity 0.25s; }
#action.show { opacity: 1; }

#toast {
  top: 76px; left: 50%; translate: -50% -20px;
  font-size: 11px; letter-spacing: 0.18em;
  color: var(--fg);
  background: var(--glass); border: 1px solid var(--red); border-radius: 8px;
  padding: 14px 22px; backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s, translate 0.5s;
  text-align: center; line-height: 1.7;
}
#toast.show { opacity: 1; translate: -50% 0; }
#toast b { color: var(--red); letter-spacing: 0.3em; }

/* ---------- интро ---------- */
#intro {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(7, 8, 10, 0.82);
  backdrop-filter: blur(10px);
  transition: opacity 0.7s, visibility 0.7s;
}
#intro.hide { opacity: 0; visibility: hidden; }
.intro-card { max-width: 620px; padding: 40px 32px; text-align: center; }
.intro-chip {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.4em;
  color: var(--dim); margin-bottom: 22px;
}
.intro-card h1 {
  font-family: 'Unbounded', sans-serif; font-weight: 800;
  font-size: clamp(28px, 5.4vw, 52px); line-height: 1.05;
  text-transform: uppercase;
}
.intro-card h1 span { color: var(--red); }
.intro-lead {
  color: var(--dim); font-size: 15px; line-height: 1.65;
  max-width: 460px; margin: 20px auto 28px;
}
.intro-legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-bottom: 34px;
}
.intro-legend span {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.14em;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 12px; color: var(--fg);
}
#start-btn {
  font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 14px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #0b0c0f; background: var(--fg);
  border: none; border-radius: 8px;
  padding: 17px 46px; cursor: pointer;
  transition: background 0.25s, scale 0.2s;
}
#start-btn:hover { background: #fff; scale: 1.04; }
.intro-keys {
  margin-top: 18px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.2em;
  color: var(--dim);
}

/* ---------- модалка ---------- */
#modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(6, 7, 9, 0.55);
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s, visibility 0.35s;
}
#modal.open { opacity: 1; visibility: visible; }
.panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  background: rgba(13, 14, 18, 0.92);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 30px 30px 40px;
  overflow-y: auto;
  transform: translateX(40px);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#modal.open .panel { transform: translateX(0); }
#modal-close {
  position: absolute; top: 18px; right: 20px;
  width: 34px; height: 34px;
  font-size: 16px; color: var(--dim);
  background: none; border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer;
}
#modal-close:hover { color: var(--fg); border-color: var(--fg); }

.m-chip {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.4em;
  color: var(--dim); margin-bottom: 18px;
}
.m-emoji {
  width: 74px; height: 74px; border-radius: 14px;
  display: grid; place-items: center; font-size: 38px;
  background: color-mix(in srgb, var(--acc, #fff) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--acc, #fff) 40%, transparent);
  margin-bottom: 18px;
}
.panel h2 {
  font-family: 'Unbounded', sans-serif; font-weight: 800;
  font-size: 24px; line-height: 1.15; text-transform: uppercase;
  margin-bottom: 6px;
}
.m-sub { color: var(--dim); font-size: 13px; margin-bottom: 16px; }
.m-desc { font-size: 14px; line-height: 1.65; color: #c9c6bd; margin-bottom: 24px; }
.m-label {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--dim);
  border-top: 1px solid var(--line);
  padding-top: 16px; margin-bottom: 12px;
}
.m-services { list-style: none; margin-bottom: 22px; }
.m-services li {
  padding: 9px 0; border-bottom: 1px dashed rgba(233, 230, 222, 0.09);
  font-size: 13.5px;
}
.m-services b { display: block; font-weight: 700; }
.m-services span { color: var(--dim); font-size: 12px; }
.m-stats { margin-bottom: 26px; }
.stat { margin-bottom: 10px; }
.stat-row {
  display: flex; justify-content: space-between;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--fg); margin-bottom: 5px;
}
.bar { height: 4px; background: rgba(233, 230, 222, 0.1); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 2px; }
.m-cta {
  display: block; width: 100%;
  font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 13px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: #0b0c0f; background: var(--fg);
  border: none; border-radius: 8px;
  padding: 16px; cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.m-cta:hover {
  background: #fff;
  box-shadow: 0 0 24px color-mix(in srgb, var(--acc, #fff) 40%, transparent);
}
.m-note {
  margin-top: 12px; text-align: center;
  font-size: 11.5px; color: var(--dim);
}
.m-form-title { margin-top: 6px; }
.m-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.m-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--dim);
}
.m-form input, .m-form select, .m-form textarea {
  font-family: 'Manrope', sans-serif; font-size: 14px;
  color: var(--fg); background: rgba(233, 230, 222, 0.05);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 12px 14px; outline: none; resize: none;
}
.m-form input:focus, .m-form select:focus, .m-form textarea:focus { border-color: var(--fg); }
.m-form select option { background: #16171b; }
.m-success {
  width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 30px; color: #57c84d;
  border: 1.5px solid #57c84d;
  margin-bottom: 20px;
}
.m-handover {
  margin: 6px auto 22px; width: 220px; height: 220px;
  display: grid; place-items: center;
  border-radius: 14px; overflow: hidden;
  background: radial-gradient(ellipse at center bottom, rgba(87, 200, 77, 0.18), transparent 65%);
  border: 1px solid rgba(87, 200, 77, 0.35);
}
.m-handover img { width: 100%; height: 100%; object-fit: contain; object-position: center; }

@media (max-width: 640px) {
  #logo .name { display: none; }
  #progress { display: none; }
  .panel { padding: 24px 20px 34px; }
}
