@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Cormorant+SC:wght@600;700&family=Marck+Script&display=swap');

:root {
  --night: #15100c;
  --night-2: #221a13;
  --parchment: #eadcbc;
  --parchment-2: #dcc89c;
  --ink: #2b1d10;
  --ink-soft: #5b4630;
  --gold: #c9a24a;
  --gold-bright: #f0cf72;
  --blood: #8b1a1a;
  --dark-mark: #2f6b3a;
  --ok: #5a8f3c;
  --radius: 10px;
  --font: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-title: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.4;
  color: var(--parchment);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(240, 180, 80, 0.12), transparent 55%),
    radial-gradient(ellipse at 85% 10%, rgba(240, 180, 80, 0.08), transparent 50%),
    var(--night);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-title); color: var(--gold-bright); margin: 0 0 .4em; letter-spacing: .02em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
a { color: var(--gold-bright); }
.muted { opacity: .7; }
.small { font-size: .85em; }
.center { text-align: center; }
.hidden { display: none !important; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 520px; }

/* Пергамент */
.card {
  background: linear-gradient(160deg, var(--parchment), var(--parchment-2));
  color: var(--ink);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45), inset 0 0 40px rgba(120, 80, 30, .25);
  margin-bottom: 16px;
}
.card h1, .card h2, .card h3 { color: var(--ink); }
.card .muted { color: var(--ink-soft); opacity: 1; }

.panel {
  background: rgba(255, 240, 210, .05);
  border: 1px solid rgba(201, 162, 74, .3);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

/* Формы и кнопки */
input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #a88a55;
  background: #fffaf0;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); }
label { display: block; margin: 10px 0 4px; font-weight: 600; }

button, .btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid #8a6a2a;
  background: linear-gradient(180deg, #e7c46a, #b88a2e);
  color: #2a1a06;
  text-decoration: none;
  display: inline-block;
  transition: transform .05s, filter .15s;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.ghost { background: transparent; color: var(--gold-bright); border-color: rgba(201, 162, 74, .5); }
.card button.ghost { color: var(--ink); border-color: #a88a55; }
button.small { padding: 4px 10px; font-size: .85em; }
button.danger { background: linear-gradient(180deg, #b84a3a, #7d2418); color: #fff; border-color: #5a1a10; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; }
.error { color: #ffb3a3; min-height: 1.2em; margin-top: 8px; }
.card .error { color: var(--blood); }

/* Шапка игрока */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  padding: 10px 16px;
  background: rgba(21, 16, 12, .92);
  border-bottom: 1px solid rgba(201, 162, 74, .35);
  backdrop-filter: blur(6px);
}
.topbar .who { font-family: var(--font-title); font-size: 1.2rem; color: var(--gold-bright); }
.stat { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.stat-label { opacity: .7; }

.house-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; color: #fff;
  border: 1px solid rgba(255, 255, 255, .25);
}
.house-badge.none { background: #4a3d2f; color: #d8c8a8; font-weight: 600; }

/* Заряды */
.charges { display: inline-flex; gap: 4px; }
.charge { width: 14px; height: 14px; border-radius: 50%; background: var(--gold-bright); box-shadow: 0 0 8px var(--gold); }
.charge.spent { background: #3b3024; box-shadow: none; border: 1px solid #6b5a40; }

/* Шкала Тёмной метки */
.scale { display: inline-flex; gap: 3px; }
.pip { width: 12px; height: 18px; border-radius: 3px; background: #2a231b; border: 1px solid #4a3d2f; }
.pip.on { background: var(--dark-mark); border-color: #7fd18c; box-shadow: 0 0 6px rgba(127, 209, 140, .6); }
.pip.threshold { border-color: #a05050; }
.scale.big .pip { width: 26px; height: 40px; border-radius: 5px; }

/* Куски карты в шапке */
.pieces { display: inline-flex; gap: 3px; }
.piece-dot { width: 14px; height: 14px; transform: rotate(45deg); background: #2a231b; border: 1px solid #6b5a40; }
.piece-dot.on { background: var(--parchment); border-color: var(--gold); }

/* Журнал */
.log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; font-size: .95rem; }
.log li { padding: 5px 0; border-bottom: 1px dashed rgba(201, 162, 74, .2); }
.log time { opacity: .55; font-size: .8em; margin-right: 6px; }
.log .curse { color: #ff9c8a; }
.log .map { color: var(--gold-bright); }
.log .scale { color: #9fe0a8; }
.log .announce { color: #fff; font-weight: 600; }

/* Карта Мародёров */
.map-svg { width: 100%; height: auto; display: block; }
.map-tile text { font-family: var(--font-title); }

/* Таблица игроков */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(201, 162, 74, .2); vertical-align: middle; }
th { font-family: var(--font-title); color: var(--gold); font-weight: 600; }
td select { width: auto; padding: 4px 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #6b5a40; margin-right: 6px; }
.dot.on { background: #6fdc7a; box-shadow: 0 0 6px #6fdc7a; }

.script { font-style: italic; font-size: 1.1rem; white-space: pre-wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.connection {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--blood); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: .9rem; z-index: 50;
}

.phase-title { font-family: var(--font-title); color: var(--gold); font-size: 1rem; text-transform: uppercase; letter-spacing: .1em; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-size: .85rem; }

/* Письмо */
.letter { text-align: center; }
.letter .seal {
  width: 64px; height: 64px; margin: 6px auto 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c0392b, #6e1410 70%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .4), inset 0 0 10px rgba(0, 0, 0, .4);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 1.8rem; color: #f3c9a0;
}
.letter .letter-text { font-size: 1.25rem; font-style: italic; min-height: 5.5em; margin: 8px auto 14px; max-width: 30em; }
.letter .sign { text-align: right; font-family: var(--font-title); max-width: 30em; margin: 0 auto 12px; }

/* Почта */
.mail { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.mail li { padding: 8px 0; border-bottom: 1px dashed rgba(201, 162, 74, .2); }
.mail .mail-head { font-size: .8em; opacity: .65; }
.mail .done { color: #9fe0a8; font-size: .85em; }

/* Проклятия */
.curse-banner {
  background: linear-gradient(90deg, #3a1010, #5a1a1a);
  border: 1px solid #a33; color: #ffd8cf;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
}
.curse-banner b { color: #fff; }
.curse-list { list-style: none; padding: 0; margin: 0; }
.curse-list li { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

/* Окно способностей */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal .card { max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; margin: 0; }
.option { border-top: 1px solid rgba(90, 60, 20, .25); padding: 12px 0; }
.option:first-of-type { border-top: 0; }
.option p { margin: 0 0 8px; }
.option select { margin-bottom: 8px; }

.log .ability { color: #c9b8ff; }
.log .mail { color: #e8c8a0; }
.log .clue { color: #ffd27a; }

/* Карта Мародёров */
.mm-wrap { position: relative; }
.mm-title {
  text-align: center; font-family: 'Marck Script', 'Cormorant Garamond', cursive;
  color: var(--gold-bright); font-size: 2.4rem; line-height: 1.1; margin: 4px 0 2px;
  text-shadow: 0 0 18px rgba(240, 207, 114, .25);
}
.mm-sub { text-align: center; font-style: italic; opacity: .75; margin-bottom: 10px; }
.mm { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .55)); }
.mm-hole { fill: rgba(255, 240, 210, .025); stroke: rgba(201, 162, 74, .35); stroke-width: 1.5; stroke-dasharray: 5 7; }
.mm-hole-current { fill: rgba(240, 207, 114, .07); stroke: var(--gold); animation: mm-pulse 2.4s ease-in-out infinite; }
@keyframes mm-pulse { 50% { fill: rgba(240, 207, 114, .14); } }
.mm-q { font-family: var(--font-title); font-size: 64px; fill: rgba(201, 162, 74, .3); }
.mm-seek { font-family: 'Marck Script', cursive; font-size: 30px; fill: var(--gold-bright); }
.mm-seek-place { font-family: var(--font); font-style: italic; font-size: 22px; fill: rgba(240, 207, 114, .75); }
.mm-place { font-family: 'Marck Script', cursive; font-size: 30px; fill: #3a1f0c; }
.mm-word { font-family: var(--font); font-style: italic; font-size: 21px; fill: #8b1a1a; }

/* Новый кусок: медленно проступает чернилами */
.mm-fresh { animation: mm-reveal 3.5s ease-out both; }
@keyframes mm-reveal { 0% { opacity: 0; filter: blur(6px) sepia(1); } 60% { opacity: .85; } 100% { opacity: 1; filter: none; } }
.mm-fresh-text { opacity: 0; animation: mm-fade 2s ease-out 2.5s forwards; }
@keyframes mm-fade { to { opacity: 1; } }
.mm-ribbon .mm-word { font-size: 15px; }

/* Громовещатели */
.hw-form label { font-weight: 600; margin-top: 12px; }
.hw-form input { margin-top: 2px; }
.hw-word { color: #8b1a1a; background: rgba(139, 26, 26, .08); padding: 0 3px; border-radius: 3px; font-weight: 700; }

/* Письмо на пергаменте */
.letter-wrap { scroll-margin-top: 110px; position: relative; max-width: 640px; margin: 44px auto 12px; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .5)); animation: letter-unfold .8s ease-out both; }
.letter-wrap.compact { max-width: none; margin-top: 40px; }
@keyframes letter-unfold { from { opacity: 0; transform: translateY(40px) scaleY(.55); } to { opacity: 1; transform: none; } }
.letter-seal { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); z-index: 2; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .45)); }
.letter-paper {
  padding: 64px 48px 30px; color: #2b1d10;
  background:
    linear-gradient(to bottom, transparent 32.6%, rgba(255, 255, 255, .45) 33%, rgba(120, 90, 50, .22) 33.4%, transparent 34%, transparent 65.6%, rgba(255, 255, 255, .45) 66%, rgba(120, 90, 50, .22) 66.4%, transparent 67%),
    radial-gradient(ellipse at 25% 15%, rgba(255, 255, 255, .4), transparent 55%),
    radial-gradient(ellipse at 85% 95%, rgba(150, 105, 55, .3), transparent 55%),
    radial-gradient(ellipse at 5% 80%, rgba(150, 105, 55, .22), transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence baseFrequency='.85' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .24  0 0 0 0 .1  0 0 0 .13 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    linear-gradient(165deg, #f1e6c8, #e5d3a9 55%, #d9c393);
}
.letter-head { text-align: center; font-family: var(--font-title); letter-spacing: .3em; font-size: .85rem; color: #5b4630; line-height: 1.7; }
.letter-rule { border-top: 1.5px dashed rgba(90, 60, 30, .35); margin: 14px 0 18px; }
.letter-title { text-align: center; font-family: var(--font); font-weight: 700; font-size: 1.9rem; color: #2b1d10; margin: 4px 0 14px; letter-spacing: 0; }
.letter-body p { font-size: 1.22rem; line-height: 1.65; margin: 0 0 12px; }
.letter-wrap.big .letter-body p { font-size: 1.5rem; }
.letter-sign { text-align: right; margin-top: 14px; }
.ls-name { color: #8b1a1a; font-size: 1.55rem; font-family: var(--font); font-weight: 600; }
.ls-role { font-style: italic; color: #5b4630; font-size: .95rem; }
.letter-footer { text-align: center; }
@media (max-width: 560px) { .letter-paper { padding: 56px 22px 24px; } .letter-title { font-size: 1.5rem; } }

/* Конверт */
.env-stage { text-align: center; padding: 6px 0 4px; }
.env { position: relative; width: min(420px, 92%); aspect-ratio: 1.6; margin: 18px auto 14px; perspective: 900px; }
.env > div { position: absolute; border-radius: 6px; }
.env-back { inset: 0; }
.env-sheet { left: 7%; right: 7%; top: 8%; height: 84%; z-index: 1; border-radius: 3px !important;
  background: repeating-linear-gradient(to bottom, transparent 0 18px, rgba(90, 60, 30, .15) 18px 19px), #f3e7c9;
  transition: transform .9s .5s ease-in-out; }
.env-pocket { inset: 0; z-index: 2; clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); }
.env-flap { left: 0; right: 0; top: 0; height: 60%; z-index: 3; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .6s ease-in, z-index 0s .3s; }
.env-wax { left: 50%; top: 58%; transform: translate(-50%, -50%); z-index: 4; transition: transform .45s, opacity .45s; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.env-label { left: 0; right: 0; bottom: 9%; z-index: 3; font-family: 'Marck Script', cursive; font-size: 1.35rem; }
.env-cream .env-back { background: #c9ae7e; } .env-cream .env-pocket { background: linear-gradient(170deg, #ead9b3, #dcc697); } .env-cream .env-flap { background: linear-gradient(180deg, #d8c08e, #c7aa74); } .env-cream .env-label { color: #4a2a14; }
.env-red .env-back { background: #6e1410; } .env-red .env-pocket { background: linear-gradient(170deg, #b8291f, #92201a); } .env-red .env-flap { background: linear-gradient(180deg, #a82219, #861a14); } .env-red .env-label { color: #ffe0c8; }
.env-open .env-wax { transform: translate(-50%, -50%) scale(1.35) rotate(25deg); opacity: 0; }
.env-open .env-flap { transform: rotateX(180deg); z-index: 0; }
.env-open .env-sheet { transform: translateY(-62%); }
.env-shake { animation: env-shake 1.6s ease-in-out infinite; }
@keyframes env-shake { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-1.6deg); } 20% { transform: rotate(1.6deg); } 30% { transform: rotate(-1deg); } 40% { transform: rotate(0); } }
.env-note { font-size: 1.1rem; margin: 4px auto 12px; max-width: 30em; }
.stage-panel .env-note { color: var(--parchment); }

.spy-note { margin: 14px auto; max-width: 30em; padding: 22px 18px; background: #2a2016; color: #e9dcbc; border: 1px solid #5a4a36; border-radius: 4px; transform: rotate(-1.2deg); box-shadow: 0 8px 20px rgba(0, 0, 0, .5); }
.spy-note p { margin: 0; font-family: 'Marck Script', cursive; font-size: 1.7rem; text-align: center; }

/* Люди на карте */
.mm-name { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 8.4px; fill: #2b1708; }
.mm-name-me { fill: #9b1c12; font-style: italic; font-size: 9.4px; }
.mm-foot { opacity: 0; animation: mm-walk 4.8s ease-in-out infinite; }
@keyframes mm-walk { 6% { opacity: .92; } 50% { opacity: .92; } 78%, 100% { opacity: 0; } }
.mm-tag { filter: drop-shadow(0 1px 1px rgba(60, 30, 10, .45)); }

/* Детальная карта */
.md-main { font-family: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif; font-weight: 700; fill: #3b2210; letter-spacing: .06em; }
.md-sub { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; fill: #3b2210; }
.md-seal { font-family: 'Cormorant SC', Georgia, serif; font-weight: 700; fill: #f3d9b0; letter-spacing: .12em; }
.md-seal-sub { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; fill: #f3d9b0; }
.md-sweets rect { stroke: #8b1a1a; stroke-width: 6; }
.md-paw { opacity: 0; animation: md-paw 6s ease-in-out infinite; }
@keyframes md-paw { 8% { opacity: .9; } 55% { opacity: .9; } 80%, 100% { opacity: 0; } }
.mm-step { opacity: 0; animation: mm-step 4.2s ease-in-out infinite; }
@keyframes mm-step { 10% { opacity: .85; } 45% { opacity: .85; } 70%, 100% { opacity: 0; } }
.mm-complete .mm { filter: drop-shadow(0 0 30px rgba(240, 207, 114, .45)) drop-shadow(0 10px 24px rgba(0, 0, 0, .55)); }

/* Вкладки */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid rgba(201, 162, 74, .35); margin-bottom: 14px; }
.tabs button {
  background: transparent; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; color: var(--parchment); opacity: .65; padding: 8px 14px; font-weight: 600;
}
.tabs button:hover { opacity: 1; filter: none; }
.tabs button.active { opacity: 1; color: var(--gold-bright); border-color: rgba(201, 162, 74, .35); background: rgba(255, 240, 210, .05); margin-bottom: -1px; border-bottom: 1px solid var(--night); }
.tabs .badge { display: inline-block; min-width: 1.4em; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--blood); color: #fff; font-size: .75em; text-align: center; }

/* Шапка пульта */
.hostbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center;
  padding: 10px 16px; margin-bottom: 14px;
  background: rgba(21, 16, 12, .95);
  border-bottom: 1px solid rgba(201, 162, 74, .35);
}
.hostbar .room { font-family: var(--font-title); color: var(--gold-bright); font-size: 1.3rem; letter-spacing: .15em; }
.hostbar .phase { min-width: 220px; }
.hostbar .phase b { font-family: var(--font-title); color: var(--gold-bright); font-size: 1.15rem; }
.notice { border-left: 4px solid var(--gold); background: rgba(201, 162, 74, .1); padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; }
.notice.danger { border-color: #c0392b; background: rgba(192, 57, 43, .15); }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  background: #7d2418; color: #fff; font-weight: 600;
}
.toast.ok { background: #3d6b2a; }

/* Свеча */
.candle { display: inline-block; width: 8px; height: 22px; background: #f3e6c4; border-radius: 2px; position: relative; margin: 0 6px; vertical-align: middle; }
.candle::before { content: ''; position: absolute; left: 50%; top: -12px; width: 8px; height: 12px; margin-left: -4px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #fff6c0, #f5a623 60%, transparent 70%); animation: flicker 1.8s infinite alternate; }
@keyframes flicker { 0% { transform: scale(1) rotate(-2deg); opacity: .9; } 50% { transform: scale(1.1, .9) rotate(2deg); } 100% { transform: scale(.95, 1.1) rotate(-1deg); opacity: 1; } }

/* ---------- Глава 2: Испорченный портрет ---------- */
.portrait-art { display: block; width: 100%; height: auto; }
.pt-orig { max-width: 560px; margin: 0 auto 6px; animation: pt-fade .4s ease-out; }
.pt-frame {
  border: 14px solid #b8892e; border-image: linear-gradient(135deg, #f3d37a, #b8892e 35%, #f0cc6e 60%, #8a6420) 1;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55), inset 0 0 0 2px #6b4a14; background: #f6f2ea;
}
.pt-frame img { display: block; width: 100%; height: auto; }
.pt-head { margin-bottom: 6px; font-family: var(--font-title); color: var(--gold-bright); }
.pt-task { margin: 4px 0 8px; }
.pt-prompt {
  background: linear-gradient(160deg, var(--parchment), var(--parchment-2)); color: var(--ink);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font-size: 1.15rem; font-style: italic;
  box-shadow: inset 0 0 20px rgba(120, 80, 30, .25);
}
.pt-img { display: block; width: 100%; max-width: 560px; margin: 0 auto 10px; border-radius: 8px; border: 3px solid #8a6420; background: #fff; }
.pt-actions { margin-top: 10px; }
.pt-text { margin-top: 4px; }

/* Таймер */
.pt-timer {
  display: inline-block; min-width: 3.2em; text-align: center;
  padding: 2px 10px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1px solid rgba(201, 162, 74, .6); color: var(--gold-bright); background: rgba(0, 0, 0, .25);
}
.pt-timer.low { color: #ffb3a3; border-color: #a05050; animation: pt-pulse 1s infinite; }
.pt-timer.big { font-size: 1.6rem; }
.card .pt-timer { color: var(--ink); background: rgba(255, 255, 255, .35); border-color: #a88a55; }
.card .pt-timer.low { color: var(--blood); }
@keyframes pt-pulse { 50% { opacity: .55; } }
@keyframes pt-fade { from { opacity: 0; transform: translateY(6px); } }

/* Холст */
.pt-padwrap { position: relative; max-width: 640px; margin: 0 auto; }
.pt-actions { justify-content: center; }
.pt-peek { position: absolute; inset: 44px 0 0; display: flex; justify-content: center; background: rgba(21, 16, 12, .85); border-radius: 8px; z-index: 2; }
.pt-peek .pt-frame { align-self: center; max-width: 92%; max-height: 100%; }
.pt-peek .pt-frame img { max-height: 70vh; width: auto; max-width: 100%; }
.pad-tools {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 8px; margin-bottom: 6px; border-radius: 8px;
  background: rgba(255, 240, 210, .06); border: 1px solid rgba(201, 162, 74, .3);
}
.pad-tools button { padding: 0; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.pad-color { border: 2px solid rgba(255, 255, 255, .25); }
.pad-color.active { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.pad-size, .pad-btn { background: transparent; color: var(--gold-bright); border: 1px solid rgba(201, 162, 74, .5); font-size: 1.1rem; }
.pad-size span { display: block; border-radius: 50%; background: var(--gold-bright); }
.pad-size.active, .pad-btn.active { background: rgba(201, 162, 74, .3); border-color: var(--gold-bright); }
.pad-sep { width: 1px; height: 26px; background: rgba(201, 162, 74, .35); margin: 0 2px; }
.pad canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3;
  background: #fff; border-radius: 8px; border: 3px solid #8a6420; cursor: crosshair;
  touch-action: none; /* рисовать пальцем, а не прокручивать страницу */
  box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
}
.pad.locked canvas { pointer-events: none; filter: saturate(.6) brightness(.92); }
.pad.locked .pad-tools { pointer-events: none; opacity: .4; }

/* Слизерин: шаг до предыдущего */
.pt-peek2 { border: 1px dashed rgba(127, 209, 140, .6); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.pt-peek2 img { display: block; max-width: 220px; width: 100%; border-radius: 6px; background: #fff; margin-top: 4px; }
.pt-peek2 p { margin: 4px 0 0; font-style: italic; }

/* Ход шагов на общем экране */
.pt-steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.pt-dot { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; border: 1px solid #6b5a40; background: #2a231b; opacity: .6; }
.pt-dot.done { background: rgba(201, 162, 74, .35); border-color: var(--gold); opacity: 1; }
.pt-dot.now { border-color: var(--gold-bright); box-shadow: 0 0 10px var(--gold); opacity: 1; }
.pt-verdict { font-size: 1.2rem; font-style: italic; color: var(--gold-bright); margin: 6px 0; }
.card .pt-verdict { color: var(--ink); }

/* Галерея */
.pg { margin: 6px 0; }
.pg-head { font-family: var(--font-title); color: var(--gold-bright); margin-bottom: 8px; }
.card .pg-head { color: var(--ink); }
.pg-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pg-arrow { color: var(--gold); font-size: 1.3rem; opacity: .7; }
.pg-card {
  width: 190px; background: linear-gradient(160deg, var(--parchment), var(--parchment-2)); color: var(--ink);
  border-radius: 8px; padding: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.pg-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; border-radius: 4px; border: 2px solid #8a6420; }
.pg-text .pg-body, .pg-empty .pg-body { min-height: 100px; display: flex; align-items: center; justify-content: center; text-align: center; font-style: italic; padding: 6px; }
.pg-empty .pg-body { color: var(--ink-soft); }
.pg-by { font-size: .8rem; color: var(--ink-soft); text-align: center; margin-top: 4px; }
.pg-orig { border: 2px solid var(--gold-bright); }
.pg-new { animation: pt-fade .5s ease-out; }
.pg.big .pg-row { gap: 14px; justify-content: center; }
.pg.big .pg-card { flex: 1 1 180px; width: auto; max-width: 320px; padding: 8px; }
.pg.big .pg-text .pg-body { min-height: 180px; font-size: 1.35rem; }
.pg.big .pg-by { font-size: 1rem; }
.pg.big .pg-head { text-align: center; font-size: 1.4rem; }
@media (max-width: 600px) {
  .pg-card { width: calc(50% - 22px); }
  .pg-arrow { display: none; }
  .pad-tools button { width: 30px; height: 30px; }
}

/* Экран входа: письмо из Хогвартса — картинка на весь экран */
.join-scene {
  position: relative; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 24px 18px 28px;
  background: url('/img/letter.webp') 52% 40% / cover no-repeat;
}
.join-art { display: none; }
.join-panel { width: 100%; max-width: 420px; }
.join-head { text-align: center; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid rgba(122, 79, 23, .25); }
.join-head h1 { margin: 0 0 2px; font-size: 1.8rem; line-height: 1.1; color: #6e4514; }
.join-scene .card { margin: 0; }
.join-scene .card input { margin-top: 6px; }
.join-scene .card button { width: 100%; margin-top: 14px; }

/* Широкий экран: форма справа, по центру по высоте */
@media (min-width: 900px) and (min-aspect-ratio: 6/5) {
  .join-scene { align-items: flex-end; justify-content: center; padding: 24px 3vw; background-position: 100% 40%; }
  .join-panel { width: 26vw; min-width: 340px; max-width: 400px; }
  .join-head h1 { font-size: 2rem; }
}

/* Стартовый экран: Большой зал */
.hall-scene { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.hall-art {
  height: 46vh; height: 46dvh; flex: none;
  background: url('/img/hall.webp') 60% 40% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent);
          mask-image: linear-gradient(to bottom, #000 65%, transparent);
}
.hall-panel { position: relative; z-index: 1; width: 100%; max-width: 460px; margin: -8vh auto 0; padding: 0 18px 28px; }
.hall-head { text-align: center; margin-bottom: 18px; text-shadow: 0 2px 12px rgba(0, 0, 0, .8); }
.hall-head h1 { margin: 12px 0 2px; font-size: 2.3rem; line-height: 1.1; }
.hall-scene .card { margin-bottom: 14px; }
.hall-scene .card h2 { margin-bottom: 0; }
.hall-scene .card button { width: 100%; margin-top: 14px; }
.hall-host { margin: 0; }
.hall-host h3 { margin-bottom: 2px; }
.hall-host p { margin: 0 0 10px; }

/* Широкий экран: зал справа, форма слева — на светлом крае картины */
@media (min-width: 900px) and (min-aspect-ratio: 6/5) {
  .hall-scene { flex-direction: row; align-items: center; background: #f6ead2; color: var(--ink); }
  .hall-art {
    position: absolute; top: 0; bottom: 0; right: 0; width: 78%; height: auto;
    background-position: 100% 50%;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 22%);
            mask-image: linear-gradient(to right, transparent, #000 22%);
  }
  .hall-art::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to right, #f6ead2 0%, rgba(246, 234, 210, .85) 18%, transparent 40%);
  }
  .hall-panel { width: 30%; min-width: 360px; max-width: 420px; margin: 0 0 0 max(4vw, calc((30% - 420px) / 2)); padding: 24px 0; }
  .hall-head { text-shadow: none; }
  .hall-head .candle { background: #fbf3df; box-shadow: 0 0 0 1px rgba(122, 79, 23, .4), 0 2px 6px rgba(122, 79, 23, .25); }
  .hall-head h1 { color: #7a4f17; font-size: 2.6rem; }
  .hall-head .muted { color: var(--ink-soft); opacity: 1; }
  .hall-host { background: rgba(255, 250, 238, .7); border-color: rgba(122, 79, 23, .3); backdrop-filter: blur(3px); }
  .hall-host h3 { color: #7a4f17; }
  .hall-host .muted { color: var(--ink-soft); opacity: 1; }
  .hall-host button.ghost { color: var(--ink); border-color: #a88a55; }
  .hall-host .error { color: var(--blood); }
}

/* Письмо-приглашение: текст лежит на пергаменте картинки.
   Картинка всегда накрывает экран (как cover), а пергамент (центр на 61.7% ширины) держим по центру экрана. */
.invite-scene { position: fixed; inset: 0; z-index: 5; overflow: hidden; background: var(--night); container-type: size; }
.invite-art, .invite-text {
  --W: max(178.43cqh, 100cqw);
  --H: calc(var(--W) * 0.5604);
  --L: clamp(calc(100cqw - var(--W)), calc(50cqw - var(--W) * 0.6168), 0px);
}
.invite-art { position: absolute; top: 0; left: var(--L); width: var(--W); height: var(--H); max-width: none; display: block; }
.invite-text {
  position: absolute;
  left: calc(var(--L) + var(--W) * 0.6168);
  top: calc(var(--H) * 0.31);
  transform: translateX(-50%);
  width: min(calc(100cqw - 36px), calc(var(--W) * 0.33));
  max-height: calc(100cqh - var(--H) * 0.31 - 16px);
  overflow-y: auto;
  padding-bottom: 12px;
  color: #3a2612;
  font-size: clamp(15px, calc(var(--W) * 0.0118), 21px);
  line-height: 1.38;
  animation: invite-in 1.2s ease-out both;
}
.invite-text p { margin: 0 0 .7em; }
.invite-hello { font-family: var(--font-title); font-size: 1.3em; color: #5a3410; }
.invite-sign { font-style: italic; }
.invite-sign span { font-family: 'Marck Script', cursive; font-style: normal; font-size: 1.3em; color: #4a2c10; }
.invite-text button { width: 100%; margin-top: .4em; }
@keyframes invite-in { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }

/* Распределяющая Шляпа: статус на экране игрока и флаги на общем экране */
.sort-status { display: flex; align-items: center; gap: 18px; margin-top: 14px; padding: 14px 16px; border: 1px solid rgba(201, 162, 74, .3); border-radius: var(--radius); background: rgba(255, 240, 210, .04); }
.sort-status p { margin: 0 0 8px; }
.sort-flag { width: 64px; height: auto; flex: none; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5)); }
.sort-hat { width: 96px; height: auto; flex: none; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5)); }
.sort-hall { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; text-align: center; }
@media (max-width: 700px) { .sort-hall { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sort-hall img { height: clamp(140px, 18vw, 230px); width: auto; max-width: 100%; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .5)); }
.sort-hall .sh-name { font-family: var(--font-title); color: var(--gold-bright); font-size: 1.2rem; margin-top: 6px; }
.sort-hall .sh-list { font-size: 1.25rem; line-height: 1.35; }
.sort-hall .sh-list b { display: block; animation: sh-in .8s ease both; }
@keyframes sh-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sort-wait { text-align: center; font-size: 1.3rem; }
.sort-wait img { width: 180px; height: auto; display: block; margin: 0 auto 8px; }

/* Глава 1: директор по секрету и первый кусок карты */
.dir-scene { position: relative; container-type: inline-size; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); }
.dir-scene img { display: block; width: 100%; height: auto; }
/* Облачко нарисовано на картинке: x 7–31%, y 29–67%. */
.dir-bubble {
  position: absolute; left: 8.2%; top: 31%; width: 21.8%; height: 34%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: #3b2614; font-family: var(--font); font-weight: 600; font-style: italic;
  font-size: 1.62cqw; line-height: 1.22;
  animation: dir-in 1.2s ease-out .4s both;
}
.dir-bubble p { margin: 0; }
@keyframes dir-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dir-piece { text-align: center; }
.dir-piece .mm-wrap { max-width: 620px; margin: 0 auto; animation: dir-in 1s ease-out both; }
.dir-piece-note { font-style: italic; opacity: .85; margin: 0 0 10px; }
.dir-piece-place { font-family: 'Marck Script', 'Cormorant Garamond', cursive; color: var(--gold-bright); font-size: 2rem; margin: 6px 0 0; }
.mm-mark path { fill: none; stroke: #b3261e; stroke-width: 9; stroke-linecap: round; opacity: .9;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: mm-mark-draw 1.4s ease-in-out .9s forwards; }
@keyframes mm-mark-draw { to { stroke-dashoffset: 0; } }

/* Тест Шляпы пройден: ученик в Большом зале ждёт церемонии — картинка на весь экран, больше ничего.
   Тест и церемония (z-index 60) открываются поверх. */
.hall-wait { position: fixed; inset: 0; z-index: 50; background: #140c06; animation: hall-in 1s ease-out both; }
.hall-wait img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 52% 50%; }
.hall-wait-text {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
  padding: 90px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(20, 12, 6, .9) 0%, rgba(20, 12, 6, .6) 55%, transparent 100%);
}
.hall-wait-text p { margin: 0 auto 14px; max-width: 34em; font-size: clamp(1.1rem, 2.2vw, 1.6rem); text-shadow: 0 1px 4px rgba(0, 0, 0, .85); }
body:has(.hall-wait) { overflow: hidden; }
@keyframes hall-in { from { opacity: 0; } to { opacity: 1; } }

/* Читы ведущего на экране ученика (только в браузере ведущего) */
.cheats { position: fixed; left: 10px; bottom: 10px; z-index: 70; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
.cheats-wand { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 17px; opacity: .35; background: rgba(20, 12, 6, .7); border: 1px solid rgba(201, 162, 74, .4); }
.cheats-wand:hover { opacity: 1; }
.cheats-box { display: flex; flex-direction: column; gap: 4px; padding: 10px; width: 300px; border-radius: var(--radius); background: rgba(20, 12, 6, .94); border: 1px solid rgba(201, 162, 74, .45); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); font-size: .9rem; }
.cheats-box.hidden { display: none; }
.cheats-box button { text-align: left; display: flex; gap: 8px; align-items: center; }
.cheats-box kbd { flex: none; min-width: 62px; font: 600 .75rem var(--font); color: var(--gold); opacity: .85; }
.cheats-head { font-family: var(--font-title); color: var(--gold-bright); margin-bottom: 4px; }
.cheats-foot { font-size: .75rem; opacity: .55; margin-top: 4px; }

/* ---------- Глава 3: Тайная комната, Детектив ---------- */
/* Надпись на мокрой каменной стене коридора. */
.dt-wall {
  position: relative; text-align: center; padding: 34px 20px 26px; margin-bottom: 14px; border-radius: 10px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(240, 180, 80, .22), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(0, 0, 0, .35) 38px 40px),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(0, 0, 0, .25) 78px 80px),
    linear-gradient(180deg, #4a4036, #2b241d);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .7), 0 10px 26px rgba(0, 0, 0, .5);
  animation: pt-fade .8s ease-out;
}
.dt-wall-text {
  font-family: 'Marck Script', 'Cormorant Garamond', cursive; font-size: 2rem; line-height: 1.25;
  color: #c0281c; text-shadow: 0 0 10px rgba(192, 40, 28, .45), 0 2px 0 rgba(0, 0, 0, .6);
  animation: dt-write 2.2s ease-out both;
}
.dt-wall-sign { font-family: 'Marck Script', cursive; font-size: 1.6rem; color: #c0281c; margin-top: 6px; text-align: right; padding-right: 12%; animation: dt-write 1s ease-out 1.8s both; }
.dt-wall.big { padding: 70px 20px 50px; }
.dt-wall.big .dt-wall-text { font-size: 3.4rem; }
.dt-wall.big .dt-wall-sign { font-size: 2.6rem; }
@keyframes dt-write { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }

.dt-round { font-family: var(--font-title); color: var(--gold-bright); margin-bottom: 10px; }
.dt-h { margin: 18px 0 4px; }
.dt-hint { margin: 0 0 8px; }

/* Доска: три колонки карточек на пергаменте. */
.dt-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .dt-board { gap: 6px; } }
.dt-col { display: flex; flex-direction: column; gap: 6px; }
.dt-col-title { font-family: var(--font-title); color: var(--gold-bright); text-align: center; font-size: 1.1rem; }
.dt-card {
  position: relative; display: flex; flex-direction: column; text-align: left; gap: 1px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid #a88a55; font-weight: 600;
  background: linear-gradient(160deg, var(--parchment), var(--parchment-2)); color: var(--ink);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35); transition: opacity .2s, transform .1s;
}
button.dt-card { cursor: pointer; }
button.dt-card:hover { filter: brightness(1.05); }
.dt-name { line-height: 1.15; }
.dt-note { font-weight: 400; font-size: .8em; color: var(--ink-soft); font-style: italic; }
.dt-by { font-weight: 400; font-size: .72em; color: var(--ink-soft); }
.dt-card.crossed { opacity: .45; }
.dt-card.crossed .dt-name { text-decoration: line-through; text-decoration-color: var(--blood); text-decoration-thickness: 2px; }
.dt-card.certain { opacity: .38; }
.dt-card.certain::after {
  content: '✕'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%) rotate(-8deg);
  font-size: 1.6rem; color: var(--blood); font-weight: 700;
}
.dt-card.culprit { border: 2px solid var(--gold-bright); box-shadow: 0 0 18px rgba(240, 207, 114, .7); animation: pt-fade .6s ease-out; }
@media (max-width: 640px) { .dt-card { padding: 6px 7px; font-size: .85rem; } .dt-note { display: none; } }

/* Свои улики факультета. */
.dt-mine { border: 1px solid rgba(201, 162, 74, .45); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; background: rgba(201, 162, 74, .08); }
.dt-mine h3 { margin: 0 0 2px; }
.dt-mine p { margin: 0 0 8px; }
.dt-mine.quiet { background: transparent; border-color: rgba(201, 162, 74, .25); padding: 8px 12px; }
.dt-mine.quiet summary { cursor: pointer; color: var(--gold-bright); font-family: var(--font-title); }
.dt-mine-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dt-mine-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: rgba(255, 240, 210, .06); }
.dt-mine-list li button { flex: none; }
.dt-mine-list li.on-table { opacity: .6; }
.dt-tag { flex: none; font-size: .75em; padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(201, 162, 74, .5); color: var(--gold-bright); }

/* Улики на столе. */
.dt-clues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dt-clues li { border-left: 4px solid var(--hc, var(--gold)); padding: 6px 10px; background: rgba(255, 240, 210, .05); border-radius: 0 8px 8px 0; animation: pt-fade .5s ease-out; }
.dt-clue-house { display: block; font-size: .75em; opacity: .7; }

/* Обвинение. */
.dt-proposal { border: 2px solid var(--gold); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; background: rgba(201, 162, 74, .12); animation: pt-fade .4s ease-out; }
.card .dt-proposal { background: rgba(201, 162, 74, .18); border-color: #a88a55; }
.dt-proposal-main { font-size: 1.2rem; margin: 2px 0 4px; }
.dt-vote { margin: 8px 0 4px; }
.dt-accuse { margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(201, 162, 74, .45); border-radius: var(--radius); }
.dt-accuse h3 { margin: 0; }
.dt-accuse-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 640px) { .dt-accuse-grid { grid-template-columns: 1fr; } }
.dt-board + .center { margin-top: 14px; }
.dt-history { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 4px; }
.dt-history li.bad { color: #ffb3a3; }
.dt-history li.ok { color: #b9e39a; }
.card .dt-history li.bad { color: var(--blood); }
.card .dt-history li.ok { color: var(--ok); }
.dt-questions { margin-top: 10px; }

/* Развязка. */
.dt-solved { text-align: center; margin-bottom: 12px; }
.dt-squeak { font-family: 'Marck Script', cursive; font-size: 2.4rem; color: var(--gold-bright); margin: 0; animation: dt-squeak .7s ease-out; }
.dt-solved blockquote { font-style: italic; margin: 10px auto; max-width: 36em; padding: 10px 16px; border-left: 3px solid var(--gold); text-align: left; }
@keyframes dt-squeak { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
