:root {
  --indigo: #201761;
  --deep: #120c3d;
  --snow: #f6f4ff;
  --muted: rgba(246, 244, 255, .72);
  --warm: #ffd36b;
  --line: rgba(255, 255, 255, .14);
  --card: rgba(30, 20, 92, .62);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0c0a24;
  color: var(--snow);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  overflow: hidden;
  background: var(--indigo);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 600px) {
  body { background: radial-gradient(circle at 50% 15%, #2b2174, #0c0a24 70%); }
  #app {
    width: 420px;
    height: min(880px, calc(100% - 40px));
    border-radius: 32px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .08);
  }
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- экраны ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.screen.dim { background: linear-gradient(180deg, rgba(18, 12, 61, .55), rgba(18, 12, 61, .3) 45%, rgba(18, 12, 61, .72)); }
.screen.dim-strong { background: linear-gradient(180deg, rgba(18, 12, 61, .35), rgba(18, 12, 61, .55) 40%, rgba(18, 12, 61, .85)); }

.wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
}

.logo {
  width: 140px;
  filter: invert(1) drop-shadow(0 4px 18px rgba(169, 166, 255, .45));
  margin: 4px 0 2px;
}
.logo.small { width: 110px; margin-bottom: 10px; }

h1 {
  margin: 6px 0 8px;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.5px;
  text-align: center;
  text-shadow: 0 0 28px rgba(255, 211, 107, .35);
}
h1 span { color: var(--warm); }
h2 { margin: 10px 0 4px; font-size: 26px; font-weight: 900; text-align: center; }

.lead { margin: 0 0 14px; text-align: center; font-size: 14px; line-height: 1.4; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; line-height: 1.4; margin: 4px 0; }
.small { font-size: 12px; }

.card {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card.center { text-align: center; }

/* ---------- форма ---------- */
input[type=text], input[type=email] {
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  color: var(--snow);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color .2s, background .2s;
}
input::placeholder { color: rgba(246, 244, 255, .5); }
input:focus { border-color: var(--warm); background: rgba(255, 255, 255, .12); }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, .4);
  border-radius: 6px;
  cursor: pointer;
}
.check input:checked { background: var(--warm); border-color: var(--warm); }
.check input:checked::after {
  content: "";
  width: 10px;
  height: 5px;
  border: solid #2a1d4f;
  border-width: 0 0 2.5px 2.5px;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check a { color: var(--warm); }

.error { min-height: 18px; margin: 2px 2px 0; font-size: 13px; color: #ffb4a8; }

.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  color: #2a1d4f;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(180deg, #ffe08a, #ffb444);
  box-shadow: 0 5px 0 #c97f22, 0 12px 28px rgba(255, 180, 70, .35);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c97f22, 0 6px 16px rgba(255, 180, 70, .3); }

.link {
  margin-top: 14px;
  padding: 4px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: rgba(246, 244, 255, .5);
  text-decoration: underline;
  cursor: pointer;
}

.rules {
  list-style: none;
  margin: 14px 0 4px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.rules li {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-size: 12px;
  color: var(--muted);
}
.rules b { color: var(--warm); }

.pill {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- перед попыткой ---------- */
#screen-ready { justify-content: space-between; cursor: pointer; }
.ready-top, .ready-hint {
  text-align: center;
  padding: 16px 20px;
  border-radius: 22px;
  background: rgba(18, 12, 61, .5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
}
.ready-top { margin-top: 9vh; max-width: 330px; }
.ready-top h2 { font-size: 30px; text-shadow: 0 0 24px rgba(255, 211, 107, .35); }
.ready-hint { margin-bottom: 24vh; }
.tap-text { margin-top: 10px; font-size: 18px; font-weight: 800; }
.tap-ring {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border: 3px solid rgba(255, 211, 107, .9);
  border-radius: 50%;
  animation: ring 1.4s ease-out infinite;
}
@keyframes ring {
  0% { transform: scale(.7); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- итоги ---------- */
.center-v { margin: auto 0; }
.big {
  font-size: 64px;
  line-height: 1;
  font-weight: 900;
  color: var(--warm);
  text-shadow: 0 0 30px rgba(255, 211, 107, .4);
  margin-top: 8px;
}
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 6px;
}
.stats div {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .07);
}
.stats span { display: block; font-size: 11px; color: var(--muted); }
.stats b { font-size: 22px; }

.next-hint { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.next-hint b { color: var(--warm); }

.bonus {
  margin: 16px 0 10px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 211, 107, .18), rgba(255, 140, 80, .08));
  border: 1px solid rgba(255, 211, 107, .35);
}
.bonus-title { margin-top: 4px; font-size: 26px; font-weight: 900; }
.bonus-desc { font-size: 13px; color: var(--muted); }
.promo {
  margin-top: 12px;
  padding: 10px 18px;
  border: 2px dashed rgba(255, 211, 107, .8);
  border-radius: 12px;
  background: rgba(18, 12, 61, .5);
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--warm);
  cursor: pointer;
}
.promo-hint { margin-top: 6px; font-size: 11px; color: var(--muted); }

.ladder { list-style: none; margin: 12px 0 0; padding: 0; text-align: left; }
.ladder li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: rgba(246, 244, 255, .5);
}
.ladder li.reached { color: var(--snow); }
.ladder li.current { color: var(--warm); font-weight: 800; }
.ladder li span:first-child::before { content: "○ "; }
.ladder li.reached span:first-child::before { content: "● "; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
#hud.hidden { display: none; }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-score {
  min-width: 64px;
  padding: 3px 14px;
  border-radius: 16px;
  background: rgba(18, 12, 61, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 26px;
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  transition: transform .12s;
}
.hud-score.bump { transform: scale(1.14); color: var(--warm); }
.hud-attempt {
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(18, 12, 61, .35);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.hud-right { display: flex; gap: 8px; }
.hud-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 13px;
  background: rgba(18, 12, 61, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--snow);
  cursor: pointer;
  pointer-events: auto;
}

#rotate {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--deep);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  z-index: 10;
}
@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
}
