/* ============================================================
   34 · Маленькое путешествие для Маши
   ============================================================ */

:root {
  --pink: #ff5c93;
  --pink-soft: #ff9dba;
  --lilac: #8a5cff;
  --teal: #2ec4b6;
  --gold: #ffc93c;
  --cream: #fff3e0;
  --ink: #2a1b3d;
  --ink-soft: #6b5a80;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.75);
  --shadow: 0 24px 70px rgba(56, 24, 74, 0.28);
  --radius: 28px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0c0a18;
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 8%, transparent 55%, rgba(42, 27, 61, 0.12) 100%),
    radial-gradient(90% 70% at 50% 120%, transparent 62%, rgba(42, 27, 61, 0.18) 100%);
  z-index: 2;
}

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

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: none;
}

#hud.show {
  opacity: 1;
  transform: translateY(0);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--lilac));
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(138, 92, 255, 0.35);
  white-space: nowrap;
}

.hud-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(56, 24, 74, 0.12);
}

.hud-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(90, 50, 130, 0.22);
  box-shadow: inset 0 0 0 1px rgba(90, 50, 130, 0.16);
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.hud-dot.done {
  background: linear-gradient(135deg, var(--pink), var(--gold));
  transform: scale(1.25);
  box-shadow: 0 0 12px rgba(255, 92, 147, 0.7);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-counter {
  font-weight: 900;
  font-size: 14px;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s ease, background 0.2s ease;
  display: grid;
  place-items: center;
}

.icon-btn:hover { transform: scale(1.08); }
.icon-btn.off { opacity: 0.45; text-decoration: line-through; }

/* ---------------- Hint ---------------- */

.hint {
  position: absolute;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 5;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(42, 27, 61, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
  white-space: nowrap;
}

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

.hint-touch { display: none; }

@media (pointer: coarse) {
  .hint-desktop { display: none; }
  .hint-touch { display: inline; }
}

/* ---------------- Touch controls ---------------- */

#touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

@media (pointer: coarse) {
  #touch-controls { display: flex; }
}

.touch-left {
  display: flex;
  gap: 12px;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(56, 24, 74, 0.2);
  pointer-events: auto;
  touch-action: none;
  transition: transform 0.12s ease, background 0.12s ease;
}

.touch-btn.active {
  transform: scale(0.92);
  background: rgba(255, 92, 147, 0.75);
  color: #fff;
}

.touch-jump {
  width: 82px;
  height: 82px;
  background: rgba(138, 92, 255, 0.5);
  color: #fff;
}

/* ---------------- Screens ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 190, 222, 0.55), transparent 60%),
    radial-gradient(100% 80% at 50% 110%, rgba(160, 120, 255, 0.3), transparent 62%),
    rgba(48, 26, 64, 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.55s ease, visibility 0.55s ease;
  pointer-events: none;
}

.screen.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen-inner {
  width: min(760px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
  padding: 42px 34px 34px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 250, 245, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  transform: translateY(18px) scale(0.97);
  transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.screen.show .screen-inner {
  transform: translateY(0) scale(1);
}

.screen-inner.narrow {
  width: min(560px, 100%);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(255, 92, 147, 0.12);
  color: #d63a72;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.display {
  margin: 0 0 18px;
  font-size: clamp(38px, 6.4vw, 68px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #ff4f8b 0%, #8a5cff 48%, #2ec4b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 22px rgba(138, 92, 255, 0.22));
}

.display.small {
  font-size: clamp(30px, 4.6vw, 46px);
}

.lead {
  margin: 0 auto 28px;
  max-width: 540px;
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.6;
  font-weight: 600;
  color: var(--ink-soft);
}

.screen-foot {
  margin-top: 20px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(107, 90, 128, 0.7);
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.01em;
  padding: 16px 30px;
  border-radius: 999px;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1), box-shadow 0.2s ease, filter 0.2s ease;
  min-height: 54px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #ff5c93 0%, #8a5cff 100%);
  box-shadow: 0 16px 34px rgba(255, 92, 147, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 22px 44px rgba(255, 92, 147, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:active {
  transform: translateY(0) scale(0.985);
}

.btn-ghost {
  margin-left: 10px;
  color: var(--ink-soft);
  background: rgba(42, 27, 61, 0.06);
  border: 1px solid rgba(42, 27, 61, 0.08);
}

.btn-ghost:hover { background: rgba(42, 27, 61, 0.1); }

/* ---------------- Item card ---------------- */

.card-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(20, 12, 32, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  pointer-events: none;
}

.card-layer.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: 26px 30px 30px;
  border-radius: 34px;
  background: linear-gradient(180deg, #fffdfb 0%, #fff5ee 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 30px 80px rgba(30, 12, 44, 0.45);
  transform: translateY(24px) scale(0.94);
  transition: transform 0.55s cubic-bezier(0.18, 1.05, 0.3, 1);
}

.card-layer.show .card {
  transform: translateY(0) scale(1);
}

.card-art {
  position: relative;
  width: 200px;
  height: 200px;
  margin: -6px auto 6px;
  display: grid;
  place-items: center;
}

.card-art::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255, 92, 147, 0.16), rgba(138, 92, 255, 0.06) 55%, transparent 72%);
  filter: blur(2px);
}

#card-art {
  position: relative;
  width: 200px;
  height: 200px;
  display: block;
  animation: floaty 4s ease-in-out infinite;
}

#card-photo {
  position: relative;
  width: 200px;
  height: 200px;
  object-fit: cover;
  object-position: center 38%;
  border-radius: 26px;
  box-shadow: 0 14px 34px rgba(42, 27, 61, 0.22);
  animation: floaty 4s ease-in-out infinite;
}

.card-art.has-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  max-height: 40vh;
  margin: 0 0 18px;
  overflow: hidden;
  border-radius: 22px;
  background: #f3e7dc;
  box-shadow: 0 16px 38px rgba(42, 27, 61, 0.2);
}

.card-art.has-photo::before { display: none; }

.card-art.has-photo #card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

.card-date {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 92, 147, 0.14), rgba(138, 92, 255, 0.14));
  color: #c6386e;
  font-weight: 900;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-title {
  margin: 4px 0 10px;
  font-size: 27px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.card-text {
  margin: 0 auto 24px;
  font-size: 15.5px;
  line-height: 1.6;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------------- Rotate hint ---------------- */

#rotate {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 205, 228, 0.6), transparent 60%),
    linear-gradient(160deg, #fff2e4 0%, #ffd9e8 48%, #e2d4ff 100%);
}

.rotate-card {
  width: min(340px, 100%);
  text-align: center;
  padding: 38px 28px 34px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 26px 60px rgba(56, 24, 74, 0.22);
}

.rotate-phone {
  width: 66px;
  height: 108px;
  margin: 0 auto 24px;
  border-radius: 16px;
  border: 4px solid var(--lilac);
  position: relative;
  transform: rotate(90deg);
  animation: rotateWiggle 2.4s ease-in-out infinite;
  box-shadow: 0 12px 26px rgba(138, 92, 255, 0.28);
}

.rotate-phone::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 4px;
  border-radius: 4px;
  background: rgba(138, 92, 255, 0.35);
  transform: translate(-50%, -50%);
}

.rotate-phone span {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--pink);
}

@keyframes rotateWiggle {
  0%, 100% { transform: rotate(90deg) translateX(0); }
  50% { transform: rotate(90deg) translateX(-6px); }
}

.rotate-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.rotate-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 600;
  color: var(--ink-soft);
}

@media (pointer: coarse) and (orientation: portrait) {
  #rotate { display: flex; }
}

/* ---------------- Small screens ---------------- */

@media (max-width: 720px) {
  #hud { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .hud-title { display: none; }
  .hud-progress { gap: 6px; padding: 9px 12px; }
  .hud-dot { width: 7px; height: 7px; }
  .hud-counter { font-size: 12px; padding: 7px 11px; }
  .screen-inner { padding: 34px 22px 26px; }
  .btn { width: 100%; }
  .btn-ghost { margin: 10px 0 0; }
  .card { padding: 22px 22px 26px; border-radius: 28px; }
  .card-art, #card-art, #card-photo { width: 160px; height: 160px; }
}

@media (max-height: 560px) {
  #hud {
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .hud-chip { height: 24px; padding: 0 10px; font-size: 10px; }
  .hud-title { font-size: 12px; }
  .hud-progress { gap: 5px; padding: 6px 10px; }
  .hud-dot { width: 6px; height: 6px; }
  .hud-counter { font-size: 11px; padding: 5px 9px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .touch-btn { width: 56px; height: 56px; font-size: 20px; }
  .touch-jump { width: 66px; height: 66px; }
  #touch-controls { padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .hint { bottom: 8px; font-size: 11.5px; padding: 8px 14px; }
  .screen { padding: 12px; }
  .screen-inner { max-height: 96vh; padding: 18px 20px 16px; border-radius: 22px; }
  .eyebrow { margin-bottom: 10px; padding: 5px 12px; font-size: 10px; }
  .display { font-size: 34px; margin-bottom: 10px; }
  .display.small { font-size: 26px; }
  .lead { font-size: 13px; line-height: 1.45; margin-bottom: 14px; }
  .btn { min-height: 44px; padding: 12px 22px; font-size: 14px; }
  .screen-foot { margin-top: 10px; font-size: 10.5px; }
  .card { padding: 16px 20px 18px; max-height: 96vh; border-radius: 22px; }
  .card-art, #card-art, #card-photo { width: 110px; height: 110px; }
  .card-art.has-photo { width: 100%; height: 120px; aspect-ratio: auto; max-height: none; margin-bottom: 10px; }
  .card-title { font-size: 20px; margin: 2px 0 6px; }
  .card-text { font-size: 13px; line-height: 1.45; margin-bottom: 14px; }
  .rotate-card { padding: 24px 20px 22px; }
  .rotate-phone { height: 80px; width: 50px; margin-bottom: 14px; }
  .rotate-card h2 { font-size: 20px; }
  .rotate-card p { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
