/* ==========================================================================
   Ночь в Замке — стили
   ========================================================================== */

:root,
.style-crimson {
  --paper: #ecd3b2; --paper2: #d9b38a; --frame: #5e1414; --gold: #c08a3e;
  --ink: #3a0e0e; --accent: #8e1b1b; --sky1: #f0a487; --sky2: #b8442f; --glow: #f6c3a8;
  --env: #b98d63; --env2: #d9b48a; --env3: #caa076;
  --bg1: #2c0b10; --bg2: #0f0406;
}
.style-azure {
  --paper: #eedfbd; --paper2: #d6bd8a; --frame: #2e4a78; --gold: #c9a24a;
  --ink: #1f2638; --accent: #2e4a78; --sky1: #f3e2b5; --sky2: #d6b46e; --glow: #f5c94a;
  --env: #b49f74; --env2: #d8c599; --env3: #c7b286;
  --bg1: #10203d; --bg2: #060b17;
}
.style-violet {
  --paper: #e6d5c2; --paper2: #c9ae94; --frame: #3f2a5c; --gold: #c9a46a;
  --ink: #24163a; --accent: #5a2f80; --sky1: #8a6aa8; --sky2: #2f1d48; --glow: #efe2fb;
  --env: #ad937f; --env2: #d2bca5; --env3: #c1a891;
  --bg1: #1f1033; --bg2: #0a0613;
}
:root {
  --f-title: 'Ruslan Display', 'Cormorant Garamond', Georgia, serif;
  --f-body: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --f-hand: 'Kurale', 'Cormorant Garamond', Georgia, serif;
  --cream: #f3e3c3;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .18 0 0 0 0 .06 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-body);
  font-size: 19px;
  line-height: 1.5;
  color: var(--cream);
  background:
    radial-gradient(ellipse at 50% -10%, var(--bg1) 0%, transparent 65%),
    radial-gradient(ellipse at 50% 120%, var(--bg1) 0%, transparent 55%),
    var(--bg2);
  background-attachment: fixed;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }

.night-sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #ffe9c4, transparent),
    radial-gradient(1.5px 1.5px at 200px 160px, #fff, transparent),
    radial-gradient(1px 1px at 280px 40px, #fff, transparent),
    radial-gradient(1px 1px at 60px 220px, #ffd9b0, transparent),
    radial-gradient(1.5px 1.5px at 330px 250px, #fff, transparent);
  background-size: 360px 300px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .35; } to { opacity: .7; } }

a { color: var(--gold); }
.muted { opacity: .72; }
.small { font-size: .82em; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: 400 1rem/1.2 var(--f-hand);
  padding: .75em 1.5em;
  color: #fbecd0;
  background: var(--frame);
  border: 2px solid var(--gold);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--frame), inset 0 0 0 3px rgba(255, 220, 160, .35), 0 4px 14px rgba(0, 0, 0, .35);
  cursor: pointer;
  text-decoration: none;
  letter-spacing: .02em;
  transition: transform .15s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: grayscale(.5); }
.btn:focus-visible, .link-btn:focus-visible, .pick:focus-visible, .envelope:focus-visible, .card-zoom:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
.btn-accept { background: var(--accent); }
.btn-decline { background: transparent; color: var(--ink); border-color: var(--ink); box-shadow: none; }
.btn-ghost { background: transparent; color: inherit; box-shadow: none; }
.btn-danger { background: #6e1010; border-color: #d4705a; }
.btn-small { font-size: .82rem; padding: .45em .85em; }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: .9em; color: inherit; opacity: .75;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { opacity: 1; }
.inline-form { display: inline; margin: 0; }

/* ---------- Разделитель ---------- */
.divider { color: var(--gold); display: flex; justify-content: center; margin: .6rem 0 1rem; }
.divider svg { max-width: 70%; height: auto; }

/* ---------- Flash ---------- */
.flash {
  padding: .7em 1em; margin: 1em 0; border-radius: 3px;
  font-family: var(--f-hand); font-size: .95rem;
  border: 1px solid; word-break: break-word;
}
.flash-ok    { background: rgba(60, 110, 60, .18); border-color: #5f9a5f; }
.flash-error { background: rgba(150, 30, 30, .18); border-color: #c2504a; }
.flash-info  { background: rgba(60, 80, 140, .16); border-color: #6a80c0; }

/* ==========================================================================
   Главная
   ========================================================================== */
.hero { position: relative; text-align: center; padding: 70px 16px 30px; overflow: hidden; }
.hero-moon {
  position: absolute; left: 50%; top: -120px; width: 360px; height: 360px; transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 120, 90, .45) 0%, rgba(160, 30, 30, .18) 45%, transparent 70%);
  pointer-events: none;
}
.hero-title {
  position: relative; margin: 0;
  font: 400 clamp(2.3rem, 7vw, 4.4rem)/1.1 var(--f-title);
  color: #f1cf8e;
  text-shadow: 0 0 22px rgba(220, 80, 50, .55), 0 3px 0 #3a0a0a;
  letter-spacing: .03em;
}
.hero-sub { position: relative; margin: .6rem 0 0; font: italic 1.25rem var(--f-body); opacity: .85; }
.hero-counter { font-family: var(--f-hand); margin: 0; opacity: .9; }
.hero-counter b { color: #f1cf8e; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }

.guest-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 34px 26px; }
.guest-card { width: 220px; margin: 0; text-align: center; animation: rise .7s both; }
.guest-card:nth-child(2n) { animation-delay: .08s; }
.guest-card:nth-child(3n) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.card-zoom {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in;
  border-radius: 9px;
  transition: transform .25s, filter .25s;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, .6));
}
.card-zoom:hover { transform: translateY(-6px) rotate(-.8deg); filter: drop-shadow(0 18px 30px rgba(180, 40, 30, .45)); }
.card-zoom img { display: block; width: 100%; height: auto; border-radius: 8px; }
.guest-card figcaption { margin-top: .8rem; display: flex; flex-direction: column; gap: .1rem; }
.guest-name { font: 1.35rem/1.2 var(--f-hand); color: #f1cf8e; word-break: break-word; }
.guest-card-name { font-style: italic; font-size: .95rem; opacity: .7; }

.empty-state { text-align: center; padding: 60px 16px; font: 1.4rem var(--f-hand); }

.site-foot { text-align: center; padding: 30px 16px 40px; opacity: .5; font-family: var(--f-hand); font-size: .9rem; }

.lightbox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 2, 3, .88); opacity: 0; transition: opacity .25s;
}
.lightbox.show { opacity: 1; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: min(460px, 92vw); max-height: 80vh; width: auto; height: auto; border-radius: 10px; box-shadow: 0 20px 60px #000; }
.lightbox-close {
  position: absolute; top: 12px; right: 16px; font-size: 2.4rem; line-height: 1;
  background: none; border: 0; color: var(--cream); cursor: pointer;
}

/* ==========================================================================
   Конверт
   ========================================================================== */
.invite-stage {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 16px; gap: 26px; text-align: center;
}
.invite-hint { margin: 0; font: 1.6rem var(--f-title); color: #f1cf8e; text-shadow: 0 2px 0 rgba(0, 0, 0, .6); }
.invite-hint.small { font: italic 1.05rem var(--f-body); color: var(--cream); opacity: .7; }

.envelope {
  position: relative; display: block;
  width: min(440px, 90vw); aspect-ratio: 3 / 2;
  padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 1400px;
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
.envelope.open { animation: none; cursor: default; }

.env-back, .env-pocket, .env-flap, .env-letter { position: absolute; display: block; }
.env-back {
  inset: 0; border-radius: 6px;
  background: var(--grain), var(--env);
  box-shadow: 0 25px 60px rgba(0, 0, 0, .7), inset 0 0 40px rgba(60, 30, 10, .35);
}
.env-letter {
  left: 7%; right: 7%; top: 7%; height: 82%; z-index: 1;
  padding: 18% 10% 0; display: flex; flex-direction: column; gap: 10px;
  background: var(--grain), var(--paper);
  border: 3px double var(--frame);
  transition: transform .8s cubic-bezier(.3, .8, .3, 1) .45s;
}
.env-letter span { display: block; height: 4px; background: var(--ink); opacity: .22; border-radius: 2px; }
.env-letter span:nth-child(2) { width: 80%; }
.env-letter span:nth-child(3) { width: 60%; }
.env-pocket {
  inset: 0; z-index: 2; border-radius: 6px;
  background: var(--grain), linear-gradient(160deg, var(--env2), var(--env3));
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  left: 0; right: 0; top: 0; height: 60%; z-index: 3;
  background: var(--grain), linear-gradient(180deg, var(--env3), var(--env));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform .7s ease-in-out, z-index 0s linear .35s;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3));
}
.env-seal {
  position: absolute; left: 50%; top: 58%; z-index: 4;
  width: 76px; height: 76px; transform: translate(-50%, -50%);
  display: grid; place-items: center;
  font: 2rem/1 var(--f-title); color: #f5c9a0;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .5);
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #e0473f 0, #a3121b 45%, #5c070d 100%);
  box-shadow: 0 0 0 5px rgba(150, 15, 22, .55), 0 6px 14px rgba(0, 0, 0, .55), inset 0 0 0 7px rgba(0, 0, 0, .18);
  transition: transform .45s, opacity .45s;
  animation: pulse 2.4s ease-in-out infinite;
}
.style-azure .env-seal  { background: radial-gradient(circle at 35% 30%, #5d86c9 0, #2e4a78 45%, #142440 100%); box-shadow: 0 0 0 5px rgba(46, 74, 120, .55), 0 6px 14px rgba(0, 0, 0, .55), inset 0 0 0 7px rgba(0, 0, 0, .18); color: #f3dc9a; }
.style-violet .env-seal { background: radial-gradient(circle at 35% 30%, #9a6bc9 0, #5a2f80 45%, #2a1340 100%); box-shadow: 0 0 0 5px rgba(90, 47, 128, .55), 0 6px 14px rgba(0, 0, 0, .55), inset 0 0 0 7px rgba(0, 0, 0, .18); color: #f0dcb0; }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.06); } }

.env-address {
  position: absolute; left: 0; right: 0; bottom: 9%; z-index: 3;
  font: 1.35rem/1.2 var(--f-hand); color: var(--ink);
  padding: 0 16px; word-break: break-word;
}
.env-address small { display: block; font-size: .75rem; letter-spacing: .25em; text-transform: uppercase; opacity: .6; }

.envelope:hover:not(.open) .env-flap { transform: rotateX(18deg); }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-seal { opacity: 0; transform: translate(-50%, -50%) scale(1.5) rotate(25deg); animation: none; }
.envelope.open .env-letter { transform: translateY(-58%); }
.envelope.instant * { transition: none !important; }

/* ==========================================================================
   Письмо
   ========================================================================== */
.letter-overlay, .picker-overlay {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto;
  padding: 34px 16px;
  background: rgba(6, 2, 4, .82);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .35s;
}
.letter-overlay.show, .picker-overlay.show { opacity: 1; }

.letter {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, .25), transparent 50%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(110, 60, 20, .35) 100%),
    var(--grain), var(--paper);
  border: 12px solid var(--frame);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 70px rgba(90, 45, 10, .35), 0 30px 90px rgba(0, 0, 0, .75);
  transform: translateY(40px) scale(.92) rotateX(12deg);
  transform-origin: top center;
  transition: transform .55s cubic-bezier(.2, .9, .3, 1.1);
}
.letter-overlay.show .letter { transform: none; }
.letter::before {
  content: ''; position: absolute; inset: -8px; pointer-events: none;
  border: 2px dotted var(--gold); border-radius: 3px;
}
.letter::after {
  content: ''; position: absolute; inset: -20px; pointer-events: none;
  --c: radial-gradient(circle, var(--gold) 0 4px, var(--frame) 5px 12px, var(--gold) 13px 14.5px, transparent 15.5px);
  background: var(--c) top left / 32px 32px no-repeat, var(--c) top right / 32px 32px no-repeat,
              var(--c) bottom left / 32px 32px no-repeat, var(--c) bottom right / 32px 32px no-repeat;
}
.letter-close {
  position: absolute; top: 6px; right: 10px; z-index: 2;
  font-size: 2rem; line-height: 1; background: none; border: 0; color: var(--frame); cursor: pointer;
}
.letter-inner { padding: 26px clamp(18px, 6vw, 56px) 40px; text-align: center; }

.letter-sky {
  display: block; width: 100%; height: 150px; margin-bottom: 18px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky2), var(--sky1));
  border: 2px solid var(--frame);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--gold);
}
.letter-title {
  margin: 8px 0 0;
  font: 400 clamp(1.7rem, 5.5vw, 2.6rem)/1.15 var(--f-title);
  color: var(--frame);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  word-break: break-word;
}
.letter-greeting { font: 1.55rem var(--f-hand); margin: .2rem 0 .8rem; color: var(--accent); word-break: break-word; }
.letter-body p {
  margin: 0 0 .55em;
  font-size: 1.22rem; line-height: 1.55;
  word-break: break-word;
}
.letter-body { text-align: center; }
.letter-details {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 30px;
  margin: 1.4rem 0 .4rem; padding: .9rem 0;
  border-top: 1px solid rgba(0, 0, 0, .18); border-bottom: 1px solid rgba(0, 0, 0, .18);
}
.letter-details div { min-width: 160px; }
.letter-details dt { font: .78rem var(--f-hand); letter-spacing: .25em; text-transform: uppercase; opacity: .65; }
.letter-details dd { margin: 0; font-size: 1.2rem; font-weight: 700; word-break: break-word; }
.letter-sign { font: italic 1.35rem var(--f-hand); text-align: right; margin: 1.2rem 0 .5rem; }

.letter .flash { color: var(--ink); }
.letter-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 1.6rem; }
.letter-actions .btn { min-width: 170px; font-size: 1.1rem; }
.letter-result { margin-top: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.result-title { margin: 0; font: 1.5rem var(--f-title); color: var(--frame); }
.result-card { width: min(240px, 70%); height: auto; border-radius: 8px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.result-card-name { margin: 0; font: 1.15rem var(--f-hand); }

.letter-seal {
  width: 70px; height: 70px; margin: 26px auto 0;
  display: grid; place-items: center;
  font: 1.8rem/1 var(--f-title); color: #f5c9a0;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #e0473f 0, #a3121b 45%, #5c070d 100%);
  box-shadow: 0 0 0 5px rgba(150, 15, 22, .5), 0 5px 12px rgba(0, 0, 0, .4), inset 0 0 0 7px rgba(0, 0, 0, .18);
  transform: rotate(-8deg);
}
.style-azure .letter-seal  { background: radial-gradient(circle at 35% 30%, #5d86c9 0, #2e4a78 45%, #142440 100%); box-shadow: 0 0 0 5px rgba(46, 74, 120, .5), 0 5px 12px rgba(0, 0, 0, .4), inset 0 0 0 7px rgba(0, 0, 0, .18); color: #f3dc9a; }
.style-violet .letter-seal { background: radial-gradient(circle at 35% 30%, #9a6bc9 0, #5a2f80 45%, #2a1340 100%); box-shadow: 0 0 0 5px rgba(90, 47, 128, .5), 0 5px 12px rgba(0, 0, 0, .4), inset 0 0 0 7px rgba(0, 0, 0, .18); color: #f0dcb0; }

.lost-letter {
  max-width: 520px; padding: 40px 30px; color: var(--ink);
  background: var(--grain), var(--paper); border: 10px solid var(--frame);
  box-shadow: inset 0 0 0 2px var(--gold), 0 20px 60px #000;
}
.lost-letter h1 { margin: 0; font: 2rem var(--f-title); color: var(--frame); }

/* ==========================================================================
   Выбор карты
   ========================================================================== */
.picker-overlay { z-index: 40; }
.picker {
  max-width: 1100px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 30px) 0;
  color: var(--ink);
  background: var(--grain), var(--paper);
  border: 10px solid var(--frame);
  box-shadow: inset 0 0 0 2px var(--gold), 0 30px 90px #000;
  border-radius: 4px;
}
.picker h2 { margin: 0; text-align: center; font: 400 clamp(1.5rem, 4vw, 2.2rem) var(--f-title); color: var(--frame); }
.picker > .muted { text-align: center; margin: .3rem 0 1.2rem; }
.picker-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.pick {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px; border: 3px solid transparent; border-radius: 10px;
  background: rgba(255, 255, 255, .15); cursor: pointer;
  font: .95rem/1.2 var(--f-hand); color: var(--ink);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.pick img { display: block; width: 100%; height: auto; border-radius: 6px; }
.pick:not(.is-taken):hover { transform: translateY(-4px); }
.pick.selected {
  border-color: var(--gold); background: rgba(255, 230, 170, .45);
  box-shadow: 0 0 0 2px var(--frame), 0 0 24px rgba(220, 150, 40, .7);
  transform: translateY(-4px) scale(1.03);
}
.pick.is-taken { cursor: not-allowed; }
.pick.is-taken img { filter: grayscale(1) brightness(.7); opacity: .45; }
.pick.is-taken .pick-name { opacity: .5; }
.pick-taken {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  padding: .2em .7em; font: 1.15rem var(--f-title); letter-spacing: .08em;
  color: #9b1414; border: 3px double #9b1414; border-radius: 4px; background: rgba(255, 240, 220, .75);
}
.picker-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end;
  margin: 18px calc(-1 * clamp(14px, 3vw, 30px)) 0; padding: 14px clamp(14px, 3vw, 30px);
  background: var(--grain), var(--paper2);
  border-top: 2px solid var(--frame);
}
.picker-choice { margin-right: auto; font-family: var(--f-hand); }

/* ==========================================================================
   Админка
   ========================================================================== */
.page-admin { font-size: 17px; --frame: #5e1414; }
.admin-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(20, 8, 10, .92); border-bottom: 2px solid var(--gold);
  backdrop-filter: blur(4px);
}
.admin-brand { font: 1.2rem var(--f-title); color: #f1cf8e; text-decoration: none; }
.admin-brand small { font: .8rem var(--f-hand); opacity: .6; }
.admin-bar nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-family: var(--f-hand); }
.admin-bar nav a { color: var(--cream); text-decoration: none; opacity: .75; padding: 4px 0; border-bottom: 2px solid transparent; }
.admin-bar nav a:hover, .admin-bar nav a.active { opacity: 1; border-color: var(--gold); }
.admin-wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 20px; }
.stat {
  display: flex; flex-direction: column; padding: 14px 16px; text-decoration: none; color: var(--cream);
  background: rgba(40, 18, 22, .8); border: 1px solid rgba(192, 138, 62, .35); border-radius: 6px;
}
.stat b { font: 1.9rem var(--f-title); color: #f1cf8e; }
.stat span { font-family: var(--f-hand); font-size: .9rem; opacity: .75; }
.stat.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.stat-ok b { color: #9fd68f; }
.stat-no b { color: #e98a7a; }

.panel {
  margin-bottom: 22px;
  background: rgba(30, 13, 17, .85); border: 1px solid rgba(192, 138, 62, .4); border-radius: 6px;
}
.panel > summary, .panel-title {
  margin: 0; padding: 14px 18px;
  font: 1.25rem var(--f-title); color: #f1cf8e; cursor: default;
  border-bottom: 1px solid rgba(192, 138, 62, .25);
}
.panel > summary { cursor: pointer; list-style: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: ' ▾'; font-size: .9rem; opacity: .6; }
.panel[open] > summary::after { content: ' ▴'; }
.panel-body { padding: 16px 18px; margin: 0; }

.form-grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.page-admin label { display: flex; flex-direction: column; gap: 5px; font-family: var(--f-hand); font-size: .95rem; }
.page-admin label small { opacity: .6; }
.page-admin input[type=text], .page-admin input[type=password], .page-admin textarea, .page-admin select {
  width: 100%; padding: .6em .75em;
  font: 1.05rem var(--f-body); color: #2a120e;
  background: #f1e2c4; border: 1px solid #8a6a3a; border-radius: 3px;
}
.page-admin textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
.page-admin input:focus, .page-admin textarea:focus, .page-admin select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.page-admin input[type=file] { font-size: .85rem; color: var(--cream); max-width: 100%; }
.panel-body > .btn { margin-right: 8px; margin-top: 4px; }

.table-scroll { overflow-x: auto; }
.inv-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.inv-table th, .inv-table td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(192, 138, 62, .18); }
.inv-table th { font: .8rem var(--f-hand); text-transform: uppercase; letter-spacing: .15em; opacity: .6; }
.inv-table tbody tr:hover { background: rgba(255, 255, 255, .03); }
.link-cell { min-width: 250px; }
.link-cell .copy-src { font-size: .8rem !important; padding: .4em .5em !important; margin-bottom: 6px; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { display: inline-block; padding: .2em .65em; border-radius: 20px; font: .82rem var(--f-hand); border: 1px solid; white-space: nowrap; }
.badge-pending  { color: #f1cf8e; border-color: rgba(241, 207, 142, .5); }
.badge-accepted { color: #a7e09a; border-color: rgba(167, 224, 154, .5); background: rgba(90, 160, 80, .12); }
.badge-declined { color: #f0998a; border-color: rgba(240, 153, 138, .5); background: rgba(160, 60, 50, .12); }
.badge-new      { color: #f1cf8e; border-color: rgba(241, 207, 142, .5); }
.badge-burned   { color: #ffb070; border-color: rgba(255, 140, 60, .5); background: rgba(200, 90, 20, .14); }

.mini-card { display: flex; align-items: center; gap: 8px; font-family: var(--f-hand); font-size: .9rem; }
.mini-card img { width: 40px; height: auto; border-radius: 3px; }

.admin-cards { display: grid; gap: 18px; padding: 0 18px 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.admin-card { background: rgba(0, 0, 0, .25); border: 1px solid rgba(192, 138, 62, .25); border-radius: 6px; overflow: hidden; }
.admin-card-img { position: relative; padding: 12px 12px 0; }
.admin-card-img img { display: block; width: 100%; height: auto; border-radius: 6px; }
.card-num { position: absolute; top: 18px; left: 18px; padding: 2px 8px; font: .8rem var(--f-hand); background: rgba(0, 0, 0, .65); border-radius: 10px; }
.admin-card-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.row-form { display: flex; gap: 6px; width: 100%; align-items: center; }
.row-form input[type=text] { flex: 1; min-width: 0; padding: .4em .55em !important; font-size: .95rem !important; }
.row-form input[type=file] { flex: 1; min-width: 0; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.login-card {
  width: min(420px, 100%); padding: 34px 30px; text-align: center; color: var(--ink);
  display: flex; flex-direction: column; gap: 14px;
  background: var(--grain), var(--paper); border: 10px solid var(--frame);
  box-shadow: inset 0 0 0 2px var(--gold), 0 25px 70px #000;
}
.login-card h1 { margin: 0; font: 1.6rem/1.2 var(--f-title); color: var(--frame); }
.login-card label { text-align: left; }
.login-card .divider { margin: 0; }

/* ==========================================================================
   Адаптив
   ========================================================================== */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .guest-grid { gap: 24px 14px; }
  .guest-card { width: calc(50% - 7px); }
  .guest-name { font-size: 1.1rem; }
  .letter { border-width: 8px; }
  .letter::after { inset: -16px; }
  .letter-sky { height: 110px; }
  .letter-body p { font-size: 1.1rem; }
  .letter-actions .btn { min-width: 0; flex: 1 1 140px; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .pick { font-size: .8rem; }
  .pick-taken { font-size: .85rem; }
  .picker-foot { justify-content: stretch; }
  .picker-foot .btn { flex: 1 1 140px; }
  .picker-choice { width: 100%; text-align: center; }
  .form-grid { grid-template-columns: 1fr; }
  .env-seal { width: 60px; height: 60px; font-size: 1.6rem; }
  .env-address { font-size: 1.1rem; }
}

/* ==========================================================================
   Одноразовое письмо: От / Кому / Текст
   ========================================================================== */
.invite-warning { margin: 0; font: .95rem var(--f-hand); color: #f0a487; letter-spacing: .03em; }
.invite-error { margin: 0; max-width: 460px; font-family: var(--f-hand); color: #ffb4a0; }
.letter-error { margin: 1rem 0 0; font-family: var(--f-hand); color: #9b1414; }

.lost-letter { display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; }
.lost-letter p { margin: 0; }

.letter-row {
  display: flex; align-items: baseline; gap: .8em; text-align: left;
  padding: .5em 0; border-bottom: 1px dashed rgba(58, 14, 14, .28);
}
.letter-row-block { border-bottom: 0; padding-bottom: .2em; }
.row-label {
  flex: 0 0 4.6em;
  font: 1rem var(--f-hand); letter-spacing: .12em; text-transform: uppercase; color: var(--frame);
}
.row-to { font: 1.55rem/1.2 var(--f-hand); color: var(--accent); word-break: break-word; }
.letter-body { text-align: left; }

.runes {
  font-family: 'Noto Sans Runic', 'Segoe UI Historic', 'Segoe UI Symbol', serif;
  font-size: 1.65rem; line-height: 1.2; letter-spacing: .1em;
  color: #6a2aa8;
  text-shadow: 0 0 6px rgba(170, 90, 255, .85), 0 0 16px rgba(140, 60, 255, .55);
  word-break: break-all; user-select: none;
}
.runes span { display: inline-block; animation: runeFloat 2.4s ease-in-out infinite; transition: color .2s; }
.runes span.sp { width: .45em; }
.runes span.flick { color: #b783ff; text-shadow: 0 0 10px #e2c8ff, 0 0 22px #a060ff; }
@keyframes runeFloat { 0%, 100% { transform: translateY(0); opacity: .82; } 50% { transform: translateY(-3px); opacity: 1; } }

.letter-actions.gone { opacity: 0; pointer-events: none; transition: opacity .3s; }

/* ---------- Свиток ---------- */
.scroll-wrap { position: relative; max-width: 680px; margin: 0 auto; transform-origin: 50% 0; }
.rod {
  position: absolute; left: -26px; right: -26px; height: 24px; z-index: 3;
  border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .35s;
  background: linear-gradient(180deg, #b07a42 0%, #7a4a20 40%, #4a2a12 75%, #2e1a0a 100%);
  box-shadow: 0 5px 12px rgba(0, 0, 0, .55);
}
.rod::before, .rod::after {
  content: ''; position: absolute; top: 50%; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe7a6, #c99640 55%, #6b4a1a);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.rod::before { left: -16px; }
.rod::after { right: -16px; }
.rod-top { top: -12px; }
.rod-bottom { bottom: -12px; }
.letter-overlay.rolling { overflow: hidden; }
.letter-overlay.rolling .rod { opacity: 1; }
.scroll-ribbon {
  position: absolute; left: 50%; top: -30px; z-index: 4;
  width: 40px; height: 60px; margin-left: -20px;
  background: linear-gradient(90deg, #6e0b10, #c0121b 50%, #6e0b10);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
  opacity: 0; transform: scaleY(.2); transform-origin: 50% 0;
  transition: opacity .25s, transform .45s cubic-bezier(.3, 1.5, .5, 1);
}
.scroll-ribbon span {
  position: absolute; left: 50%; top: 14px; width: 34px; height: 34px; margin-left: -17px;
  display: grid; place-items: center; border-radius: 50%;
  font: 1rem/1 var(--f-title); color: #f5c9a0;
  background: radial-gradient(circle at 35% 30%, #e0473f, #8e0f16 60%, #4a050a);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.letter-overlay.rolled .scroll-ribbon { opacity: 1; transform: none; }

/* ---------- Финал «принято» ---------- */
.final-screen {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  display: grid; place-items: center; padding: 30px 16px;
  background: rgba(6, 2, 4, .9); opacity: 0; transition: opacity .5s;
}
.final-screen.show { opacity: 1; }
.final-box {
  max-width: 480px; padding: 30px 26px; color: var(--ink); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  background: var(--grain), var(--paper); border: 10px solid var(--frame);
  box-shadow: inset 0 0 0 2px var(--gold), 0 20px 70px #000;
}
.final-box h2 { margin: 0; font: clamp(1.5rem, 5vw, 2.1rem)/1.2 var(--f-title); color: var(--frame); }
.final-box p { margin: 0; }
.final-box .divider { margin: 0; }

/* ---------- Камин и феникс ---------- */
.letter-overlay.to-fire { z-index: 46; background: transparent; backdrop-filter: none; overflow: hidden; }
.fire-scene {
  position: fixed; inset: 0; z-index: 45; overflow: hidden;
  background: radial-gradient(ellipse at 50% 100%, #4a1206 0%, #1a0508 45%, #070103 100%);
  opacity: 0; transition: opacity .7s;
}
.fire-scene.show { opacity: 1; }
.fire-sky {
  position: absolute; inset: 0; opacity: .6;
  background-image:
    radial-gradient(1px 1px at 30px 40px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 160px 120px, #ffe1b0, transparent),
    radial-gradient(1px 1px at 260px 60px, #fff, transparent),
    radial-gradient(1px 1px at 90px 200px, #fff, transparent);
  background-size: 320px 260px;
  mask-image: linear-gradient(#000 0%, transparent 70%);
  -webkit-mask-image: linear-gradient(#000 0%, transparent 70%);
}
.fireplace {
  position: absolute; left: 50%; bottom: 0;
  width: min(560px, 96vw); height: auto;
  transform: translate(-50%, 105%);
  transition: transform .9s cubic-bezier(.2, .9, .3, 1);
}
.fire-scene.show .fireplace { transform: translate(-50%, 0); }

.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flick 1.1s ease-in-out infinite alternate; }
.flame.f2 { animation-duration: .8s; animation-delay: -.3s; }
.flame.f3 { animation-duration: 1.4s; animation-delay: -.6s; }
.flame.f4 { animation-duration: .6s; animation-delay: -.2s; }
@keyframes flick {
  0%   { transform: scale(1, 1) skewX(0); }
  33%  { transform: scale(.92, 1.08) skewX(3deg); }
  66%  { transform: scale(1.05, .94) skewX(-3deg); }
  100% { transform: scale(.97, 1.12) skewX(1deg); }
}
.fp-flames { transform-box: fill-box; transform-origin: 50% 100%; transition: transform 1.1s ease, opacity 1.1s ease; }
.fp-glow { transition: opacity 1s, transform 1s; transform-box: fill-box; transform-origin: 50% 50%; }
.fireplace.burning .fp-flames { transform: scale(1.4); }
.fireplace.burning .fp-glow { opacity: .8; }
.fp-paper { transform-box: fill-box; transform-origin: 50% 100%; }
.fireplace.burning .fp-paper { animation: paperBurn 1.8s ease-in forwards; }
@keyframes paperBurn {
  0%   { opacity: 1; filter: none; transform: none; }
  45%  { opacity: 1; filter: sepia(1) brightness(.55); transform: scaleY(.85); }
  100% { opacity: 0; filter: brightness(.1); transform: translateY(8px) scaleY(.2); }
}
.fireplace.ashes .fp-flames { transform: scale(.3); opacity: .55; }
.fireplace.ashes .fp-glow { opacity: .25; }
.fp-ash { transition: opacity 1.2s; }
.fireplace.ashes .fp-ash { opacity: 1; }
.ember { animation: emberPulse 1.1s ease-in-out infinite alternate; }
@keyframes emberPulse { from { opacity: .35; } to { opacity: 1; } }
.fireplace.rebirth .fp-glow { animation: rebirth 1.8s ease-out; }
@keyframes rebirth { 0% { opacity: .25; transform: scale(1); } 30% { opacity: 1; transform: scale(1.8); } 100% { opacity: .3; transform: scale(1); } }

.phoenix-wrap {
  position: fixed; left: 50%; top: 70%; z-index: 2;
  width: 220px; height: 220px; margin: -110px 0 0 -110px;
  opacity: 0; pointer-events: none;
}
.phoenix { display: block; width: 100%; height: 100%; overflow: visible; }

.fire-final {
  position: absolute; left: 0; right: 0; top: 14%; padding: 0 16px; text-align: center;
  opacity: 0; transform: translateY(12px); transition: opacity 1.2s, transform 1.2s;
}
.fire-final.show { opacity: 1; transform: none; }
.fire-final h2 { margin: 0 0 .4rem; font: 400 clamp(2rem, 7vw, 3.4rem)/1.1 var(--f-title); color: #f1cf8e; text-shadow: 0 0 24px rgba(255, 120, 40, .65); }
.fire-final p { margin: .2rem 0; font: italic 1.25rem var(--f-body); }

.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ==========================================================================
   Главная: роль/девиз, карточка участника
   ========================================================================== */
.home-nav { position: absolute; top: 14px; right: 18px; z-index: 5; font-family: var(--f-hand); }
.home-nav a { color: #f1cf8e; text-decoration: none; padding: .4em .8em; border: 1px solid rgba(241, 207, 142, .4); border-radius: 3px; background: rgba(0, 0, 0, .3); }
.home-nav a:hover { border-color: #f1cf8e; }
.guest-role { font: .95rem var(--f-hand); color: #e98a7a; }
.guest-motto { font-style: italic; font-size: .92rem; opacity: .75; word-break: break-word; }

.lightbox figure { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 20px 30px; max-width: 900px; }
.lightbox figcaption { display: flex; flex-direction: column; gap: .4rem; max-width: 380px; margin: 0; text-align: left; }
.lightbox figcaption span:empty { display: none; }
.lb-name { font: 1.8rem/1.2 var(--f-title); color: #f1cf8e; word-break: break-word; }
.lb-role { font: 1.15rem var(--f-hand); color: #e98a7a; }
.lb-motto { font-style: italic; font-size: 1.1rem; }
.lb-about { white-space: pre-line; font-size: 1.05rem; line-height: 1.5; opacity: .9; max-height: 45vh; overflow-y: auto; word-break: break-word; }
.lb-card { font: .9rem var(--f-hand); opacity: .6; }

/* ==========================================================================
   Личный кабинет
   ========================================================================== */
.page-account .login-card p { margin: 0; text-align: left; }
.page-account .login-card .flash { text-align: left; }
.acc-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 22px; align-items: start; }
.acc-card { padding: 16px; text-align: center; position: sticky; top: 76px; }
.acc-card img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
.acc-card p { margin: .2rem 0; }
.acc-nick { margin: .8rem 0 .2rem; font: 1.6rem/1.2 var(--f-title); color: #f1cf8e; word-break: break-word; }
.acc-role { font: 1.1rem var(--f-hand); color: #e98a7a; }
.acc-motto { font-style: italic; opacity: .85; word-break: break-word; }

.acc-picks { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-bottom: 16px; }
.acc-pick {
  position: relative; cursor: pointer; padding: 5px; border: 2px solid transparent; border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px; font: .82rem/1.2 var(--f-hand) !important; text-align: center;
  background: rgba(0, 0, 0, .25); transition: border-color .15s, transform .15s;
}
.acc-pick input { position: absolute; top: 9px; left: 9px; accent-color: #c08a3e; }
.acc-pick img { display: block; width: 100%; height: auto; border-radius: 5px; }
.acc-pick:hover:not(.is-taken) { transform: translateY(-3px); }
.acc-pick:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 16px rgba(220, 150, 40, .5); }
.acc-pick.is-mine span { color: #f1cf8e; }
.acc-pick.is-taken { cursor: not-allowed; opacity: .4; }
.acc-pick.is-taken img { filter: grayscale(1); }

@media (max-width: 760px) {
  .acc-grid { grid-template-columns: 1fr; }
  .acc-card { position: static; max-width: 320px; margin: 0 auto; }
  .home-nav { top: 10px; right: 10px; font-size: .9rem; }
  .hero { padding-top: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  /* фон и парящий конверт — спокойнее; сцены письма играются всегда */
  .night-sky, .envelope, .guest-card { animation: none; }
}

/* ==========================================================================
   3D-карты (card3d.js): наклон, толщина, блик, голографический отлив
   ========================================================================== */
.c3d { position: relative; display: inline-block; vertical-align: top; max-width: 100%; perspective: 900px; }
.card-zoom .c3d, .pick .c3d, .acc-card .c3d, .acc-pick .c3d, .admin-card-img .c3d { display: block; }
.letter-result .c3d { width: min(240px, 70%); }
.c3d .result-card { width: 100%; }
.c3d-inner {
  --rx: 0deg; --ry: 0deg; --px: 50%; --py: 50%; --lift: 0px;
  position: relative; display: block; border-radius: 8px;
  transform-style: preserve-3d;
  transform: translateZ(var(--lift)) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .45s;
  box-shadow: 0 14px 26px rgba(0, 0, 0, .55);
  will-change: transform;
}
.c3d.is-active .c3d-inner {
  transition: transform .08s linear, box-shadow .3s;
  box-shadow: calc(var(--ry) * -1.2) calc(18px + var(--rx) * 1.2) 40px rgba(0, 0, 0, .65), 0 0 30px rgba(220, 140, 50, .25);
}
.c3d-inner > img { position: relative; display: block; width: 100%; height: auto; border-radius: 8px; transform: translateZ(1px); backface-visibility: hidden; }
.lightbox .c3d-inner > img { width: auto; }
.c3d-edge {
  position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  background: linear-gradient(135deg, #e0b56a, #6b4219 45%, #c99a52 70%, #3a220c);
}
.c3d-glare, .c3d-foil {
  position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  transform: translateZ(2px); opacity: 0; transition: opacity .35s;
}
.c3d-glare {
  background: radial-gradient(circle at var(--px) var(--py), rgba(255, 245, 220, .55), rgba(255, 230, 180, .12) 28%, transparent 55%);
  mix-blend-mode: soft-light;
}
.c3d-foil {
  background:
    linear-gradient(115deg, transparent 20%, rgba(255, 120, 200, .35) 36%, rgba(120, 220, 255, .35) 46%, rgba(255, 240, 140, .35) 56%, transparent 72%);
  background-size: 250% 250%;
  background-position: var(--px) var(--py);
  mix-blend-mode: color-dodge;
}
.c3d.is-active .c3d-glare { opacity: 1; }
.c3d.is-active .c3d-foil { opacity: .28; }
.lightbox .c3d-inner, .lightbox .c3d-inner > img, .lightbox .c3d-edge, .lightbox .c3d-glare, .lightbox .c3d-foil { border-radius: 10px; }

/* в покое карты на главной слегка «дышат» в пространстве */
.guest-card .c3d:not(.is-active) .c3d-inner { animation: c3d-idle 7s ease-in-out infinite; }
.guest-card:nth-child(2n) .c3d:not(.is-active) .c3d-inner { animation-delay: -2.3s; }
.guest-card:nth-child(3n) .c3d:not(.is-active) .c3d-inner { animation-delay: -4.6s; }
@keyframes c3d-idle {
  0%, 100% { transform: rotateX(4deg) rotateY(-7deg); }
  50%      { transform: rotateX(-3deg) rotateY(7deg); }
}
.result-card + * { margin-top: 0; }
.letter-result .c3d-inner { animation: c3d-idle 6s ease-in-out infinite; }

/* старые плоские эффекты наведения уступают место 3D */
.card-zoom, .card-zoom:hover { filter: none; transform: none; overflow: visible; }
.result-card, .acc-card img { box-shadow: none; }
.c3d-small { perspective: 300px; }
.c3d-small .c3d-inner { transform: rotateY(-14deg); box-shadow: 2px 3px 6px rgba(0, 0, 0, .5); }
.c3d-small .c3d-inner, .c3d-small .c3d-inner > img, .c3d-small .c3d-edge { border-radius: 3px; }
/* ==========================================================================
   4K-фон под устройство: альбомный (ПК/ТВ) и вертикальный (телефон), 2 разрешения каждый
   ========================================================================== */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: #14050a url("bg-1920.webp") center 70% / cover no-repeat;
}
@media (min-width: 1921px), (min-width: 1000px) and (min-resolution: 1.5dppx) {
  body::before { background-image: url("bg-3840.webp"); }
}
@media (orientation: portrait) {
  body::before { background-image: url("bg-p1080.webp"); background-position: center 60%; }
}
@media (orientation: portrait) and (min-width: 1081px), (orientation: portrait) and (min-width: 500px) and (min-resolution: 2dppx) {
  body::before { background-image: url("bg-p2160.webp"); }
}
.night-sky { opacity: .35; }

/* ==========================================================================
   Адаптация: маленькие телефоны, телефон боком, планшеты, большие экраны и ТВ
   ========================================================================== */
.wrap, .admin-wrap {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(60px, env(safe-area-inset-bottom));
}
img { max-width: 100%; }

/* маленькие телефоны */
@media (max-width: 380px) {
  body { font-size: 16px; }
  .guest-grid { gap: 18px 10px; }
  .guest-card { width: calc(50% - 5px); }
  .guest-name { font-size: 1rem; }
  .hero { padding: 54px 12px 20px; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
  .btn { padding: .7em 1.1em; }
}

/* телефон боком (низкий экран) */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { padding-top: 40px; padding-bottom: 14px; }
  .guest-card { width: 170px; }
  .lightbox img { max-height: 86vh; }
  .lightbox figure { flex-wrap: nowrap; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* планшеты */
@media (min-width: 721px) and (max-width: 1100px) {
  .guest-grid { gap: 30px 22px; }
  .guest-card { width: calc(33.333% - 15px); max-width: 240px; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* большие мониторы */
@media (min-width: 1600px) {
  .wrap { max-width: 1520px; }
  .guest-card { width: 250px; }
  .picker { max-width: 1300px; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .lightbox img { max-width: min(560px, 92vw); }
}

/* 2K / 4K мониторы и телевизоры: всё пропорционально крупнее, чтобы читалось с дивана */
@media (min-width: 2200px) { html { zoom: 1.35; } }
@media (min-width: 3000px) { html { zoom: 1.8; } }
@media (min-width: 4500px) { html { zoom: 2.4; } }

/* ТВ и пульт: фокус хорошо видно */
@media (hover: none) and (pointer: coarse) and (min-width: 1200px), (min-width: 2200px) {
  .btn:focus-visible, .card-zoom:focus-visible, .pick:focus-visible { outline-width: 5px; outline-offset: 6px; }
}

/* сенсорные экраны: наклон от гироскопа (card3d.js) и без «залипания» hover */
@media (hover: none) {
  .c3d-inner { transform: translateZ(var(--lift)) rotateX(calc(var(--rx) + var(--grx, 0deg))) rotateY(calc(var(--ry) + var(--gry, 0deg))); }
  .gyro-on .c3d-inner { animation: none !important; transition: transform .25s ease-out; }
  .gyro-on .c3d-glare { opacity: .6; }
  .gyro-on .c3d-foil { opacity: .18; }
  .btn:hover { filter: none; transform: none; }
}
/* пока картинка грузится — тёмная «рубашка» карты вместо торца и alt-текста */
.c3d:not(.is-loaded) .c3d-edge { opacity: 0; }
.c3d:not(.is-loaded) .c3d-inner { background: linear-gradient(160deg, #2a0c12, #12050a); aspect-ratio: 300 / 370; box-shadow: inset 0 0 0 2px rgba(192, 138, 62, .35), 0 14px 26px rgba(0, 0, 0, .55); }
.c3d:not(.is-loaded) .c3d-inner > img { color: transparent; }
/* ==========================================================================
   Лупа: рассмотреть карту при выборе (card3d.js → .zoom-view)
   ========================================================================== */
.pick-cell { position: relative; }
.pick-cell > .pick, .pick-cell > .acc-pick { width: 100%; height: 100%; }
.zoom-btn {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  font-size: 1.05rem; line-height: 1; cursor: zoom-in;
  color: #fbecd0; background: rgba(20, 6, 10, .78); border: 1px solid var(--gold); border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5); transition: transform .15s, background .15s;
}
.zoom-btn:hover { transform: scale(1.1); background: rgba(94, 20, 20, .92); }
.zoom-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.zoom-view {
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(5, 2, 3, .93); opacity: 0; transition: opacity .2s;
}
.zoom-view.show { opacity: 1; }
.zoom-stage {
  position: relative; overflow: hidden; border-radius: 12px; cursor: zoom-in;
  box-shadow: 0 20px 60px #000, 0 0 0 2px rgba(192, 138, 62, .5);
  touch-action: manipulation;
}
.zoom-img {
  display: block; width: auto; height: auto;
  max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); max-width: 92vw;
  transition: transform .25s ease-out; transform-origin: 50% 50%;
}
.zoom-view.is-magnified .zoom-stage { cursor: zoom-out; touch-action: none; }
.zoom-view.is-magnified .zoom-img { transform: scale(2.6); transition: transform .25s ease-out, transform-origin .08s linear; }
.zoom-title { margin: 0; font: 1.3rem var(--f-hand); color: #f1cf8e; text-align: center; }
.zoom-hint { margin: 0; font: italic .95rem var(--f-body); opacity: .7; text-align: center; }
.zoom-close {
  position: absolute; top: max(8px, env(safe-area-inset-top)); right: 14px; z-index: 2;
  font-size: 2.6rem; line-height: 1; background: none; border: 0; color: var(--cream); cursor: pointer;
}
@media (max-width: 720px) {
  .zoom-btn { width: 32px; height: 32px; top: 7px; right: 7px; font-size: .9rem; }
  .zoom-title { font-size: 1.1rem; }
}
/* ==========================================================================
   Просмотр участника: карта слева, широкая колонка текста справа
   ========================================================================== */
.lightbox { overflow-y: auto; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); }
.lightbox figure {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
  gap: 28px 48px; width: min(1180px, 100%); max-width: none; margin: auto;
}
.lightbox figure > .c3d {
  width: min(400px, 34vw, calc((100vh - 60px) * 300 / 370));
  width: min(400px, 34vw, calc((100dvh - 60px) * 300 / 370));
}
.lightbox .c3d-inner { --lift: 0px !important; }          /* в просмотре карта не выезжает на текст */
.lightbox .c3d-inner > img { width: 100%; max-width: none; max-height: none; box-shadow: none; }
.lightbox figcaption {
  max-width: none; min-width: 0; gap: .55rem; padding: 26px 30px;
  background: rgba(16, 5, 8, .78); border: 1px solid rgba(192, 138, 62, .35); border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
}
.lb-name { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.lb-role { font-size: 1.25rem; }
.lb-motto { font-size: 1.2rem; color: #f1cf8e; }
.lb-about {
  font-size: 1.12rem; line-height: 1.6; max-height: min(58vh, 640px); padding-right: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(192, 138, 62, .6) transparent;
}

/* телефоны и узкие планшеты: карта сверху, текст под ней */
@media (max-width: 760px) {
  .lightbox { display: block; padding-top: 56px; }
  .lightbox figure { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 18px; }
  .lightbox figure > .c3d { width: min(300px, 72vw); }
  .lightbox figcaption { width: 100%; padding: 18px 18px; }
  .lb-about { max-height: none; overflow: visible; }
}
/* телефон боком: две колонки, карта по высоте экрана */
@media (max-height: 500px) and (orientation: landscape) {
  .lightbox { display: grid; padding-top: 14px; }
  .lightbox figure { grid-template-columns: auto minmax(0, 1fr); gap: 18px 24px; }
  .lightbox figure > .c3d { width: calc((100vh - 30px) * 300 / 370); width: calc((100dvh - 30px) * 300 / 370); }
  .lb-about { max-height: 50vh; overflow-y: auto; }
}.lightbox-close { position: fixed; z-index: 3; top: max(10px, env(safe-area-inset-top)); }

/* ---- Обновления (updates.php) ---- */
.updates-wrap { max-width: 860px; }
.update-card {
  margin: 0 0 22px; padding: 18px 22px;
  background: rgba(30, 13, 17, .85); border: 1px solid rgba(192, 138, 62, .45); border-radius: 6px;
  color: var(--cream);
}
.update-card > header { border-bottom: 1px solid rgba(192, 138, 62, .25); margin-bottom: 12px; padding-bottom: 8px; }
.update-card h2 { margin: 0; font: 1.45rem var(--f-title); color: #f1cf8e; }
.update-meta { font: italic .95rem var(--f-hand); opacity: .7; }
.update-body { font-size: 1.1rem; line-height: 1.5; overflow-wrap: anywhere; }
.update-body h3, .update-body h4, .update-body h5 { font-family: var(--f-hand); color: #f1cf8e; margin: 14px 0 6px; }
.update-body ul { margin: 6px 0; padding-left: 1.3em; }
.update-body p { margin: 6px 0; }
.update-body hr { border: 0; border-top: 1px solid rgba(192, 138, 62, .35); margin: 14px 0; }
.update-body a { color: #f1cf8e; }
.home-nav a + a { margin-left: 6px; }

/* ---- Меню сайта: активная вкладка ---- */
.home-nav a.active { border-color: #f1cf8e; background: rgba(110, 11, 16, .55); }
@media (max-width: 720px) { .home-nav { position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 10px 8px 0; } .home-nav a + a { margin-left: 0; } }

/* ---- Страницы-документы: Правила, Лаунчер ---- */
.hero-small { padding-top: 64px; padding-bottom: 10px; }
.doc-wrap { max-width: 880px; }
.blk { margin: 0 0 20px; padding: 18px 24px; border-radius: 8px; color: var(--cream); line-height: 1.55; font-size: 1.12rem;
  background: rgba(30, 13, 17, .86); border: 1px solid rgba(192, 138, 62, .4); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
.blk h2 { margin: 0 0 10px; font: 1.4rem var(--f-title); color: #f1cf8e; }
.blk p { margin: 6px 0; }
.blk a { color: #f1cf8e; }
.blk code { font-size: .92em; background: rgba(0, 0, 0, .35); padding: .1em .35em; border-radius: 3px; }
.blk ul, .blk ol { margin: 6px 0; padding-left: 1.4em; }
.blk li { margin: 5px 0; }
.blk-title { text-align: center; background: linear-gradient(180deg, rgba(110, 11, 16, .55), rgba(30, 13, 17, .86)); border-color: rgba(241, 207, 142, .6); }
.blk-title h2 { font-size: 2rem; margin-bottom: 4px; }
.blk-title p { font: italic 1.15rem var(--f-hand); opacity: .85; }
.blk-warn { background: linear-gradient(135deg, rgba(120, 14, 18, .82), rgba(50, 8, 10, .9)); border: 1px solid #e0473f; box-shadow: 0 0 0 1px rgba(224, 71, 63, .25), 0 6px 24px rgba(0, 0, 0, .4); }
.blk-warn h2 { color: #ffb4a8; }
.blk-warn h2::before { content: '⛔ '; }
.blk-info { background: linear-gradient(135deg, rgba(90, 64, 20, .55), rgba(30, 13, 17, .88)); border: 1px solid rgba(241, 207, 142, .75); }
.blk-info h2::before { content: '✨ '; }
.blk-list .rules-list { counter-reset: none; list-style: none; padding-left: 0; }
.blk-list ol li { position: relative; padding-left: 2.6em; margin: 10px 0; }
.blk-list ol { list-style: none; padding-left: 0; counter-reset: r var(--start, 0); }
.blk-list ol li::before { content: counter(list-item); position: absolute; left: 0; top: -.05em; width: 1.9em; height: 1.9em; border-radius: 50%;
  display: grid; place-items: center; font: .95rem var(--f-title); color: #2a120e; background: linear-gradient(180deg, #f1cf8e, #c08a3e); }
.blk-divider { text-align: center; color: #c08a3e; margin: 6px 0 20px; }
.blk-divider p { margin: 0; font: italic 1rem var(--f-hand); color: var(--cream); opacity: .75; }
.blk-download { text-align: center; }
.btn-big { font-size: 1.35rem; padding: .7em 1.6em; }
.faq dt { font-weight: 700; color: #f1cf8e; margin-top: 12px; }
.faq dd { margin: 4px 0 0 0; opacity: .92; }

/* ---- Админка: конструктор правил ---- */
.rule-edit-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; flex-wrap: wrap; }
.rule-edit-tools { margin-left: auto; display: flex; gap: 6px; }
.rule-preview { padding: 10px 16px 0; max-width: none; }
.rule-preview .blk { margin-bottom: 8px; font-size: 1rem; }
.rule-edit details > summary { cursor: pointer; padding: 8px 16px 12px; color: #f1cf8e; }

/* ---- Админка: бан ---- */
.ban-box { display: inline-block; vertical-align: top; }
.ban-box > summary { list-style: none; cursor: pointer; display: inline-block; }
.ban-box > summary::-webkit-details-marker { display: none; }
.ban-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 10px; min-width: 230px;
  background: rgba(60, 10, 12, .85); border: 1px solid #d4705a; border-radius: 6px; }
.ban-form select, .ban-form input[type=text] { font-size: .95rem !important; padding: .4em .5em !important; }

/* ---- Админка: монитор карточек ---- */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 30px; }
.mon-card { display: flex; gap: 12px; padding: 12px; border-radius: 8px; color: var(--cream);
  background: rgba(30, 13, 17, .88); border: 1px solid rgba(192, 138, 62, .4); }
.mon-card.is-banned { border-color: #e0473f; background: rgba(50, 8, 10, .9); }
.mon-img { position: relative; flex: 0 0 84px; }
.mon-img img { width: 84px; border-radius: 4px; display: block; }
.mon-card.is-banned .mon-img img { filter: grayscale(1) brightness(.6); }
.mon-noimg { width: 84px; height: 104px; display: grid; place-items: center; font-size: 2rem; border: 1px dashed rgba(192, 138, 62, .5); border-radius: 4px; opacity: .6; }
.mon-stamp { position: absolute; left: -4px; right: -4px; top: 40%; transform: rotate(-14deg); text-align: center;
  font: .8rem var(--f-title); color: #fff; background: #b3151b; border: 2px solid #ffb4a8; padding: 2px 0; }
.mon-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mon-body h3 { margin: 0; font: 1.1rem var(--f-title); color: #f1cf8e; overflow-wrap: anywhere; }
.mon-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.mon-ban { color: #ff9a8a; }
