:root {
  --bg: #0e0f11;
  --panel: #16181b;
  --surface: #1c1f23;
  --line: #2e3239;
  --muted: #8b919b;
  --dim: #4f545d;
  --red: #e3000b;
  --red-deep: #7c0a11;
  --white: #f4f1ec;
  --top: max(env(safe-area-inset-top), 12px);
  --bottom: max(env(safe-area-inset-bottom), 12px);
  --ease: cubic-bezier(.22, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: var(--white); }
body { font-family: Montserrat, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }

/* ——— Сцена: на компьютере — телефон по центру, на телефоне — во весь экран ——— */
.stage { height: 100%; display: grid; place-items: center; }
.phone { position: relative; width: 100vw; height: 100dvh; overflow: hidden; overflow: clip; background: var(--bg); isolation: isolate; }
.statusbar, .caption { display: none; }

@media (min-width: 560px) and (min-height: 700px) {
  .stage {
    background:
      radial-gradient(60% 50% at 50% 0%, rgba(227, 0, 11, .16), transparent 70%),
      radial-gradient(40% 40% at 50% 100%, rgba(227, 0, 11, .08), transparent 70%), #050506;
    gap: 18px; align-content: center;
  }
  .phone {
    width: 390px; height: min(844px, calc(100vh - 70px)); border-radius: 54px;
    box-shadow: 0 0 0 10px #151517, 0 0 0 11px #2a2a2e, 0 40px 120px rgba(0, 0, 0, .8);
    --top: 50px; --bottom: 22px;
  }
  .statusbar {
    display: flex; position: absolute; z-index: 50; left: 0; right: 0; top: 0; height: 50px;
    align-items: center; justify-content: space-between; padding: 6px 30px 0 44px; pointer-events: none;
    font-weight: 600; font-size: 16px; letter-spacing: -.2px;
  }
  .sb-island { position: absolute; left: 50%; top: 11px; width: 122px; height: 35px; margin-left: -61px; border-radius: 20px; background: #000; }
  .sb-icons { display: flex; gap: 6px; align-items: center; }
  .sb-icons svg { fill: currentColor; color: #fff; }
  .caption { display: block; margin: 0; font-size: 12px; color: #6c7079; letter-spacing: .2px; }
}

canvas#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; touch-action: none; transition: opacity .5s; }
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 2;
  background: radial-gradient(120% 80% at 50% 35%, transparent 55%, rgba(0, 0, 0, .55) 100%);
}

.view { position: absolute; inset: 0; z-index: 5; }
.view-pov { pointer-events: none; }
.view-pov > * { pointer-events: auto; }

/* ——— Шапка ——— */
.top {
  position: absolute; left: 0; right: 0; top: var(--top); padding: 4px 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between; z-index: 3;
}
.round {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: #e8e6e3; flex: none; text-decoration: none;
  transition: transform .2s var(--ease), background .2s;
}
.round:active { transform: scale(.92); }
.glass { background: rgba(18, 18, 20, .5); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); }
.title { text-align: center; min-width: 0; padding-top: 0; }
.title .logo { height: 12px; display: block; margin: 0 auto 6px; opacity: .95; }
.film { font-weight: 600; font-size: 17px; letter-spacing: -.2px; white-space: nowrap; }
.sub { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; }

/* ——— Сеансы ——— */
.times {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--panel);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03);
}
.time {
  height: 34px; padding: 0 16px; border-radius: 999px; display: flex; align-items: baseline; gap: 5px;
  line-height: 34px; color: #cfd2d6; font-weight: 600; font-size: 14px; transition: background .25s, color .25s;
}
.time small { font-size: 9px; font-weight: 600; letter-spacing: .6px; color: var(--dim); }
.time.on { background: var(--white); color: #111; }
.time.on small { color: #8a8a8a; }

/* ——— Зал ——— */
.hall { position: absolute; left: 0; right: 0; }
.screen-arc { position: absolute; overflow: visible; pointer-events: none; }
.screen-glow {
  display: none; position: absolute; pointer-events: none; border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 0%, rgba(255, 236, 225, .11), rgba(227, 0, 11, .05) 45%, transparent 75%);
}
.screen-label {
  position: absolute; left: 0; right: 0; text-align: center; font-size: 9px; letter-spacing: 5px;
  color: #5b6068; font-weight: 600; pointer-events: none;
}
.seats { position: absolute; inset: 0; }
.row-label {
  position: absolute; width: 20px; margin-left: -10px; text-align: center; font-size: 10px; color: #8b919b;
  font-weight: 600; transform: translateY(-50%); pointer-events: none; text-shadow: 0 1px 4px #000;
}
.seat {
  position: absolute; border-radius: 6px; background: transparent; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: transparent; text-shadow: none;
  transition: background .2s, box-shadow .25s;
}
.seat::after { content: ""; position: absolute; inset: -3px; } /* попасть пальцем легче */
.seat.taken { cursor: default; }
.seat.sel { color: var(--red); }
@media (hover: hover) { .seat:not(.taken):not(.sel):hover { background: rgba(255, 255, 255, .1); } }
.seat.shake { animation: shake .35s, deny .6s; }
@keyframes shake { 25% { translate: -2px 0; } 75% { translate: 2px 0; } }
@keyframes deny { from { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55); } to { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0); } }

.legend {
  position: absolute; left: 0; right: 0; display: flex; justify-content: center; gap: 18px;
  font-size: 11px; color: #b4b8bf; z-index: 3; text-shadow: 0 1px 6px #000;
}
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.free { background: #a3141c; }
.lg.taken { background: #55565c; }
.lg.sel { background: var(--white); }

/* ——— Нижняя панель ——— */
.bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 18px 20px calc(var(--bottom) + 12px); background: var(--panel);
  border-radius: 26px 26px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, .04);
}
.pick-label { font-size: 12px; color: var(--muted); }
.pick-price { font-size: 20px; font-weight: 600; margin-top: 3px; letter-spacing: -.3px; }
.cta {
  height: 52px; padding: 0 30px; border-radius: 999px; background: var(--red); color: #fff;
  font-weight: 600; font-size: 16px; letter-spacing: -.1px; white-space: nowrap;
  box-shadow: 0 8px 26px rgba(227, 0, 11, .35); transition: transform .2s var(--ease), background .25s, color .25s, box-shadow .25s;
}
.cta:active { transform: scale(.96); }
.cta:disabled { background: var(--surface); color: #4f545d; box-shadow: none; cursor: default; }
.ghost {
  height: 52px; padding: 0 22px; border-radius: 999px; background: rgba(255, 255, 255, .06); color: #e8e6e3;
  font-weight: 600; font-size: 15px; white-space: nowrap; transition: transform .2s var(--ease), background .2s;
}
.ghost:active { transform: scale(.96); }

/* ——— Вид с места ——— */
.pov-back { position: absolute; left: 16px; top: calc(var(--top) + 4px); }
.pov-chip {
  position: absolute; left: 50%; top: calc(var(--top) + 6px); transform: translateX(-50%);
  height: 34px; padding: 0 16px 0 12px; border-radius: 999px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pov-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }
.pov-hint {
  position: absolute; left: 50%; bottom: 360px; transform: translateX(-50%); height: 30px; padding: 0 14px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .85);
  background: rgba(18, 18, 20, .5); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  pointer-events: none !important; opacity: 0; transition: opacity .6s;
}
.pov-hint::before { content: "↔"; font-size: 13px; opacity: .8; }
.pov-hint.on { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 20px calc(var(--bottom) + 10px);
  background: linear-gradient(180deg, rgba(22, 23, 26, .9), rgba(14, 15, 17, .97));
  -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2);
  border-radius: 28px 28px 0 0; box-shadow: 0 -1px 0 rgba(255, 255, 255, .06), 0 -20px 60px rgba(0, 0, 0, .35);
  transition: transform .5s var(--ease);
}
.grabber { display: block; width: 100%; height: 22px; display: grid; place-items: center; }
.grabber i { width: 38px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .22); display: block; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { font-size: 10px; letter-spacing: 1.6px; font-weight: 700; color: var(--red); }
.sheet-title { font-size: 26px; font-weight: 600; letter-spacing: -.6px; margin-top: 6px; }
.sheet-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.mini { width: 76px; height: 64px; flex: none; margin-top: 2px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .ghost { flex: 1; }
.sheet-actions .cta { flex: 1.35; padding: 0 16px; }
.sheet.collapsed { transform: translateY(calc(100% - 118px - var(--bottom))); }

/* ——— Всплывающие окна ——— */
.pop {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px;
  background: rgba(5, 5, 6, .6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fadeIn .3s var(--ease);
}
.pop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.pop-card, .ticket {
  width: 100%; max-width: 340px; background: var(--panel); border-radius: 26px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .05);
  animation: rise .45s var(--ease);
}
@keyframes rise { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.pop-card p { font-size: 14px; line-height: 1.5; color: #d9d7d4; margin: 12px 0 0; }
.pop-card .ghost, .ticket .cta { width: 100%; margin-top: 18px; }
.muted { color: var(--muted) !important; font-size: 12px !important; }
.ticket .logo { height: 14px; display: block; }
.t-film { font-size: 22px; font-weight: 600; letter-spacing: -.4px; margin: 16px 0 14px; }
.t-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 7px 0; color: var(--muted); }
.t-row b { color: var(--white); font-weight: 600; }
.t-cut { height: 1px; margin: 12px -22px; background: repeating-linear-gradient(90deg, #2e3239 0 6px, transparent 6px 12px); position: relative; }
.t-cut::before, .t-cut::after { content: ""; position: absolute; top: -11px; width: 22px; height: 22px; border-radius: 50%; background: #0b0b0c; }
.t-cut::before { left: -11px; } .t-cut::after { right: -11px; }
.t-total { font-size: 15px; } .t-total b { font-size: 20px; }
.ticket p { margin: 12px 0 0; }

.loading { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg); transition: opacity .6s; }
.loading img { height: 18px; animation: pulse 1.4s ease-in-out infinite; }
.loading.gone { opacity: 0; pointer-events: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ——— Переходы между схемой и 3D ——— */
.hall { transform-origin: 0 0; }
.top, .times, .legend, .bar { transition: opacity .45s var(--ease), transform .55s var(--ease); }
.phone.in3d .view-map { pointer-events: none; }
.phone.in3d .top { opacity: 0; transform: translateY(-16px); }
.phone.in3d .times { opacity: 0; transform: translateX(-50%) translateY(-16px); }
.phone.in3d .legend { opacity: 0; }
.phone.in3d .bar { transform: translateY(110%); }

.view-pov { --k: 0; }
.phone:not(.pov) .view-pov, .phone:not(.pov) .view-pov * { pointer-events: none; }
.pov-back { opacity: var(--k); translate: 0 calc((1 - var(--k)) * -12px); }
.pov-chip { opacity: var(--k); translate: 0 calc((1 - var(--k)) * -12px); }
.sheet { translate: 0 calc((1 - var(--k)) * 105%); }
