:root {
  --ink: #0a0a0b;
  --ink-2: #131317;
  --text: #f4efe6;
  --muted: rgba(244, 239, 230, 0.6);
  --faint: rgba(244, 239, 230, 0.34);
  --gold: #c8a96a;
  --gold-bright: #e8d2a0;
  --rose: #d76c82;
  --green: #7fd39b;
  --maybe: #e8d2a0;
  --line: rgba(244, 239, 230, 0.12);
  --glass: rgba(18, 18, 22, 0.46);
  --radius: 0px;
  --top-safe: env(safe-area-inset-top, 0px);
  --bot-safe: env(safe-area-inset-bottom, 0px);
  --tg-content-top: 0px;
  --chrome-top: calc(var(--top-safe) + 18px);
  --controls-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  overflow: hidden;
  position: fixed;
  inset: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- ambient ---------- */
.glow {
  position: fixed; inset: -12%;
  background-size: cover; background-position: center;
  filter: blur(54px) saturate(1.15) brightness(0.5);
  transform: scale(1.18);
  opacity: 0; transition: opacity 0.9s ease, background-image 0.9s ease;
  z-index: 0;
}
.glow.on { opacity: 1; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -5%, transparent 38%, rgba(10,10,11,0.5) 100%),
    linear-gradient(180deg, rgba(6,6,8,0.68) 0%, transparent 24%, transparent 54%, rgba(6,6,8,0.94) 100%);
}

/* ---------- card stack ---------- */
.stack {
  position: fixed; z-index: 10;
  inset: 0;
  margin: 0;
  touch-action: none;
  background: var(--ink);
}
.card {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink-2);
  box-shadow: none;
  will-change: transform;
  transform-origin: center bottom;
}
.card-img {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
}
.card-img.placeholder {
  background:
    radial-gradient(130% 90% at 50% 10%, #26252b, #0e0e12 75%);
}
.card-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(
    180deg,
    rgba(5,5,7,0.72) 0%, rgba(5,5,7,0.22) 18%,
    transparent 42%, rgba(7,7,9,0.42) 58%, rgba(6,6,8,0.9) 88%, rgba(6,6,8,0.98) 100%);
}
.decision-tint {
  position: absolute; inset: 0; z-index: 2;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.desc-backdrop {
  position: absolute; inset: 0; z-index: 2;
  opacity: 0;
  background:
    radial-gradient(105% 78% at 50% 30%, rgba(0,0,0,0.26), rgba(0,0,0,0.58) 78%),
    rgba(0,0,0,0.34);
  transition: opacity 0.38s ease;
  pointer-events: none;
}
.card.desc-open .desc-backdrop { opacity: 1; }

/* editorial metadata */
.info-stack {
  position: absolute;
  top: calc(var(--chrome-top) - 12px);
  right: 16px;
  z-index: 3;
  display: grid;
  gap: 8px;
  transition: opacity 0.34s ease, transform 0.42s cubic-bezier(0.22,1,0.36,1);
}
.tg-fullscreen .info-stack,
.tg-fullscreen-requested .info-stack {
  top: clamp(138px, calc(var(--tg-content-top) + 22px), 182px);
}
.info-tile {
  position: relative;
  width: 74px;
  height: 74px;
  display: grid;
  grid-template-rows: 20px 11px 1fr;
  align-items: center;
  justify-items: center;
  padding: 8px 7px 7px;
  border-radius: 16px;
  border: 1px solid rgba(232,210,160,0.2);
  color: var(--gold-bright);
  background:
    radial-gradient(110% 92% at 34% 0%, rgba(255,255,255,0.18), transparent 58%),
    linear-gradient(160deg, rgba(22,22,25,0.42), rgba(10,10,12,0.18)),
    rgba(11,11,13,0.2);
  box-shadow:
    0 18px 42px rgba(0,0,0,0.26),
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -1px 0 rgba(0,0,0,0.18);
  backdrop-filter: blur(24px) saturate(1.28);
  -webkit-backdrop-filter: blur(24px) saturate(1.28);
  text-shadow: 0 2px 18px rgba(0,0,0,0.84);
}
.info-tile svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.95px;
  filter: drop-shadow(0 5px 14px rgba(0,0,0,0.58));
}
.info-kicker {
  font-size: 7px;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
  color: rgba(244,239,230,0.68);
}
.info-tile strong {
  align-self: end;
  font-family: "Fraunces", serif;
  font-size: 24px;
  line-height: 0.92;
  font-weight: 560;
  letter-spacing: 0;
  color: rgba(255,248,230,0.98);
}
.format-tile strong {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.rating-tile {
  display: grid;
  grid-template-rows: 1fr;
  border-color: rgba(232,210,160,0.22);
  background:
    radial-gradient(120% 90% at 38% 0%, rgba(232,210,160,0.15), transparent 60%),
    linear-gradient(160deg, rgba(28,25,18,0.42), rgba(10,10,12,0.18)),
    rgba(11,11,13,0.2);
}
.score-value {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}
.rating-tile strong {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 23px;
  line-height: 0.95;
  font-weight: 760;
  letter-spacing: -0.03em;
}
.rating-tile .score-value svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke-width: 1.7px;
  transform: translateY(-1px);
}
.rating-tile.missing strong {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.trailer-tile {
  appearance: none;
  border-color: rgba(232,210,160,0.26);
  cursor: pointer;
  grid-template-rows: 1fr 21px;
  background:
    radial-gradient(120% 90% at 38% 0%, rgba(232,210,160,0.14), transparent 60%),
    linear-gradient(160deg, rgba(20,18,14,0.42), rgba(10,10,12,0.18)),
    rgba(11,11,13,0.2);
}
.trailer-tile svg {
  align-self: end;
  width: 24px;
  height: 24px;
  stroke-width: 2.2px;
}
.trailer-tile span {
  align-self: end;
  max-width: 58px;
  font-size: 7.3px;
  line-height: 1.05;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  color: rgba(244,239,230,0.72);
  text-align: center;
}
.trailer-tile:active { transform: scale(0.96); }
/* card content */
.card-body {
  position: absolute; left: 0; right: 0; bottom: calc(var(--controls-h) + 2px); z-index: 3;
  padding: 0 22px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: calc(100vh - var(--chrome-top) - var(--controls-h) - 36px);
}
.card-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
  transition:
    opacity 0.3s ease,
    transform 0.44s cubic-bezier(0.22,1,0.36,1),
    max-height 0.48s cubic-bezier(0.22,1,0.36,1);
}
.card-title {
  font-family: "Fraunces", serif; font-weight: 500;
  font-size: 46px; line-height: 0.96;
  letter-spacing: 0;
  text-shadow: 0 2px 18px rgba(0,0,0,0.6);
  overflow-wrap: anywhere;
  hyphens: auto;
}
.folded-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.card-genres {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.chip {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); padding: 4px 9px; border-radius: 999px;
  border: 1px solid rgba(244,239,230,0.09); background: rgba(255,255,255,0.018);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.provider-row {
  display: flex; flex-wrap: wrap; gap: 7px;
  max-width: 100%;
}
.provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--provider-fg);
  padding: 6px 10px 6px 7px;
  border-radius: 999px;
  background: var(--provider-bg);
  background: color-mix(in srgb, var(--provider-bg) 74%, transparent);
  border: 1px solid var(--provider-border);
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  backdrop-filter: blur(14px);
  min-height: 30px;
}
.provider-chip img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: cover;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  flex: 0 0 auto;
}
.provider-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.provider-chip.rent,
.provider-chip.buy,
.provider-chip.free { color: var(--provider-fg); border-color: var(--provider-border); }
.desc-panel {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition:
    flex 0.48s cubic-bezier(0.22,1,0.36,1),
    min-height 0.48s cubic-bezier(0.22,1,0.36,1);
}
.desc-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.28s ease,
    transform 0.34s cubic-bezier(0.22,1,0.36,1),
    max-height 0.42s cubic-bezier(0.22,1,0.36,1);
}
.desc-toggle {
  position: absolute;
  right: 0;
  bottom: 22px;
  z-index: 5;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(232,210,160,0.24);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.025)),
    rgba(10,10,12,0.28);
  color: var(--gold-bright);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 16px 34px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}
.desc-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.1px;
  transition: transform 0.34s cubic-bezier(0.22,1,0.36,1);
}
.desc-toggle:active { transform: scale(0.94); }
.card-desc {
  max-height: min(25vh, 158px); overflow-y: auto; touch-action: pan-y;
  font-size: 15.5px; line-height: 1.48; font-weight: 400; color: rgba(244,239,230,0.84);
  padding: 0 48px 38px 0;
  scroll-padding-bottom: 38px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 52px), rgba(0,0,0,0.54) calc(100% - 22px), transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 52px), rgba(0,0,0,0.54) calc(100% - 22px), transparent 100%);
  transition:
    max-height 0.48s cubic-bezier(0.22,1,0.36,1),
    padding-bottom 0.48s cubic-bezier(0.22,1,0.36,1),
    font-size 0.28s ease;
}
.card-desc::-webkit-scrollbar { width: 3px; }
.card-desc::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 99px; }
.card-desc p {
  margin: 0 0 0.9em;
}
.card-desc p:last-child {
  margin-bottom: 0;
}
.actor-name {
  color: var(--gold-bright);
  font-weight: 750;
  text-shadow: 0 2px 18px rgba(0,0,0,0.62);
}
.card.desc-open .info-stack {
  opacity: 0;
  transform: translateY(-10px);
}
.card.desc-open .card-body {
  bottom: calc(var(--controls-h) + 2px);
}
.card.desc-open .card-summary {
  max-height: 0;
  opacity: 0;
  transform: translateY(-18px);
  pointer-events: none;
}
.card.desc-open .desc-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--tg-content-top) - var(--controls-h) - 92px);
}
.card.desc-open .desc-meta {
  max-height: 156px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  margin: 0 44px 12px 0;
}
.card.desc-open .card-desc {
  flex: 1 1 auto;
  max-height: calc(100vh - var(--tg-content-top) - var(--controls-h) - 94px);
  font-size: 18px;
  line-height: 1.5;
  font-weight: 400;
  padding-top: 6px;
  padding-bottom: 40px;
  scroll-padding-bottom: 40px;
}
.card.desc-open .desc-toggle {
  bottom: 20px;
  border-color: rgba(232,210,160,0.36);
}
.card.desc-open .desc-toggle svg { transform: rotate(180deg); }

/* drag stamps */
.stamp {
  position: absolute; left: 50%; top: 42%; z-index: 4;
  font-family: "Fraunces", serif; font-weight: 600;
  font-size: clamp(30px, 10vw, 54px); line-height: 1; letter-spacing: 0.06em;
  padding: 12px 24px 14px;
  border-radius: 999px; border: 1px solid currentColor;
  background: rgba(8,8,10,0.44);
  backdrop-filter: blur(18px);
  box-shadow: 0 28px 70px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.12);
  opacity: 0; transition: opacity 0.05s linear;
  text-transform: uppercase;
  text-shadow: 0 2px 18px rgba(0,0,0,0.58);
  transform: translate(-50%, -50%);
}
.stamp.watch { color: var(--green); }
.stamp.pass  { color: var(--rose); }
.stamp.maybe { color: var(--gold-bright); }

/* ---------- controls ---------- */
.controls {
  position: fixed; left: 0; right: 0; z-index: 30;
  bottom: 0;
  height: var(--controls-h);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.018)),
    rgba(8,8,10,0.18);
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
  border-top: 1px solid rgba(244,239,230,0.16);
  box-shadow: 0 -18px 44px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.12);
  pointer-events: none;
}
.ctrl {
  width: 100%;
  height: var(--controls-h);
  display: grid; place-items: center; cursor: pointer;
  border-radius: 0;
  border: 0;
  border-right: 1px solid rgba(244,239,230,0.075);
  background:
    radial-gradient(80% 120% at 50% 0%, color-mix(in srgb, currentColor 11%, transparent), transparent 66%),
    linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012));
  color: var(--text);
  transition: transform 0.14s ease, filter 0.2s ease;
  pointer-events: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -1px 0 rgba(0,0,0,0.2);
}
.ctrl:last-child { border-right: 0; }
.ctrl:active { transform: scale(0.94); filter: saturate(1.2) brightness(1.12); }
.ctrl svg { width: 30px; height: 30px; stroke-width: 2.25px; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.42)); }
.ctrl.pass {
  color: #f07c94;
  background:
    radial-gradient(92% 128% at 50% 0%, rgba(215,108,130,0.13), transparent 69%),
    linear-gradient(180deg, rgba(215,108,130,0.055), rgba(255,255,255,0.012));
}
.ctrl.like {
  color: #8ce8ac;
  background:
    radial-gradient(92% 128% at 50% 0%, rgba(127,211,155,0.14), transparent 69%),
    linear-gradient(180deg, rgba(127,211,155,0.055), rgba(255,255,255,0.012));
}
.ctrl.maybe {
  color: var(--maybe);
  background:
    radial-gradient(92% 128% at 50% 0%, rgba(232,210,160,0.14), transparent 69%),
    linear-gradient(180deg, rgba(232,210,160,0.055), rgba(255,255,255,0.012));
}

/* ---------- empty state ---------- */
.empty {
  position: fixed; inset: 0; z-index: 12;
  display: grid; place-items: center; padding: 0 36px; text-align: center;
  background: radial-gradient(120% 80% at 50% 10%, #232126, #0a0a0b 68%);
}
.empty-title { font-family: "Fraunces", serif; font-size: 24px; font-weight: 500; margin: 0 0 8px; }
.empty-text { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 22px; }
.empty-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }

.ghost-btn {
  padding: 12px 22px; border-radius: 999px; cursor: pointer;
  background: var(--glass); backdrop-filter: blur(12px);
  border: 1px solid rgba(200,169,106,0.4); color: var(--gold-bright);
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.02em;
  transition: transform 0.14s ease;
}
.ghost-btn:active { transform: scale(0.95); }
.ghost-btn.subtle { border-color: var(--line); color: var(--muted); }

/* ---------- match overlay ---------- */
.match-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(6,6,8,0.78); backdrop-filter: blur(8px);
  animation: fade 0.3s ease;
}
.match-card {
  width: min(86vw, 360px); text-align: center;
  padding: 40px 30px; border-radius: 26px;
  background: linear-gradient(180deg, #16140f, #0c0b09);
  border: 1px solid rgba(200,169,106,0.35);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.8);
}
.match-kicker {
  font-size: 11px; letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 14px;
}
.match-title {
  font-family: "Fraunces", serif; font-weight: 600; font-size: 32px;
  line-height: 1.08; margin: 0 0 12px;
  background: linear-gradient(100deg, var(--gold-bright), #fff7e6, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.match-text { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.match-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- matches sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(6,6,8,0.6); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end;
  animation: fade 0.25s ease;
}
.sheet-panel {
  width: 100%; max-height: 82vh;
  background: var(--ink-2); border-top-left-radius: 26px; border-top-right-radius: 26px;
  border-top: 1px solid var(--line);
  padding: 18px 20px calc(var(--bot-safe) + 24px);
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden; display: flex; flex-direction: column;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { font-family: "Fraunces", serif; font-weight: 500; font-size: 22px; margin: 0; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 50%; font-size: 20px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
  color: var(--text); cursor: pointer;
}
.sheet-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sheet-row {
  display: flex; gap: 13px; align-items: center;
  padding: 9px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}
.sheet-thumb {
  width: 50px; height: 74px; border-radius: 9px; flex: 0 0 auto;
  background-size: cover; background-position: center; background-color: #222;
}
.sheet-info { min-width: 0; flex: 1; }
.sheet-info h3 { font-family: "Fraunces", serif; font-weight: 500; font-size: 16px; margin: 0 0 3px; }
.sheet-info p { margin: 0; font-size: 11px; color: var(--faint); letter-spacing: 0.16em; text-transform: uppercase; }
.sheet-play {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(200,169,106,0.12); border: 1px solid rgba(200,169,106,0.4);
  color: var(--gold-bright);
}
.sheet-play svg { width: 16px; height: 16px; stroke-width: 2.4px; }
.sheet-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 10px; line-height: 1.5; }

.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.05ms !important; }
}

@media (max-height: 720px) {
  .info-stack { top: calc(var(--chrome-top) - 10px); right: 12px; gap: 6px; }
  .tg-fullscreen .info-stack,
  .tg-fullscreen-requested .info-stack { top: clamp(126px, calc(var(--tg-content-top) + 18px), 168px); }
  .info-tile { width: 68px; height: 68px; border-radius: 15px; padding: 7px 6px 6px; }
  .info-tile svg { width: 18px; height: 18px; }
  .info-kicker { font-size: 7px; }
  .info-tile strong,
  .format-tile strong { font-size: 21px; }
  .rating-tile strong { font-size: 20px; }
  .trailer-tile svg { width: 22px; height: 22px; }
  .trailer-tile span { font-size: 6.8px; max-width: 54px; }
  .card-body { bottom: calc(var(--controls-h) + 10px); }
  .card-title { font-size: 38px; }
  .card-desc { max-height: 20vh; font-size: 15px; }
  .card.desc-open .card-desc { font-size: 16.5px; }
  .provider-chip { max-width: 48%; font-size: 10px; padding: 5px 9px 5px 6px; }
  .provider-chip img { width: 16px; height: 16px; border-radius: 4px; }
}
