:root {
  --bg: #0e1a2b; --surface: #17283f; --text: #eef3fb; --primary: #ff7a1a; --accent: #9fd3ff;
  --font: "PT Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --muted: color-mix(in srgb, var(--text) 72%, var(--bg));
  --line: color-mix(in srgb, var(--text) 16%, transparent);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.5 var(--font); }
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
header.top, main, .toast { position: relative; z-index: 1; }
header.top { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(4px); position: sticky; top: 0; }
#logo { height: 44px; width: auto; }
.top-title { flex: 1; min-width: 0; }
.tagline { color: var(--accent); font-size: 14px; letter-spacing: .06em; text-transform: uppercase; }
h1 { margin: 0; font-size: 26px; line-height: 1.2; }
h2 { font-size: 22px; margin: 0 0 10px; }
h3 { font-size: 19px; margin: 0 0 6px; }
.status { text-align: right; font-size: 15px; color: var(--muted); }
.status b { color: var(--text); font-size: 20px; display: block; font-variant-numeric: tabular-nums; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 24px 80px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.narration { font-size: 20px; white-space: pre-line; }
.act-label { color: var(--primary); font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.clue { border-left: 4px solid var(--accent); }
.clue.new { animation: glow 2.5s ease-out 1; }
.clue .kind { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.clue .body { white-space: pre-line; }
.char .role { color: var(--primary); font-size: 15px; }
.char .trait { color: var(--muted); font-size: 15px; font-style: italic; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.tabs button { background: transparent; color: var(--text); border: 1px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--primary); color: #111; border-color: var(--primary); }
button, .btn { font: inherit; font-size: 17px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--primary); background: var(--primary); color: #111; cursor: pointer; font-weight: 700; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 400; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select { font: inherit; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 160px; width: auto; }
.solved { color: var(--accent); font-weight: 700; }
.hint { color: var(--accent); border-left: 3px solid var(--accent); padding-left: 10px; margin-top: 8px; }
.muted { color: var(--muted); }
.login { max-width: 460px; margin: 8vh auto; text-align: center; }
.login input { text-align: center; font-size: 28px; letter-spacing: .2em; text-transform: uppercase; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; font-size: 15px; }
.score { font-size: 22px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.host-notes { border-left: 4px solid var(--primary); }
.secret { border: 1px dashed var(--primary); }
.log { font-size: 15px; max-height: 260px; overflow: auto; }
.ok { color: #7be0a4; } .bad { color: #ff9b9b; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary); color: #111; padding: 12px 20px; border-radius: 10px; font-weight: 700; z-index: 5; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 10px 14px; }
legend { padding: 0 6px; font-weight: 700; }
label.opt { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
label.opt input { width: auto; margin-top: 6px; }
@keyframes glow { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 640px) { html, body { font-size: 17px; } header.top { padding: 10px 14px; flex-wrap: wrap; gap: 6px 12px; } #logo { height: 30px; } .tagline { display: none; } .top-title { order: 3; flex-basis: 100%; } .status { margin-left: auto; } main { padding: 16px 14px 60px; } h1 { font-size: 20px; } }
summary { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { #snow { display: none; } .clue.new { animation: none; } }

/* Тема «манускрипт»: средневековая книжная миниатюра — лазурь, золото, киноварь, орнаментальные рамки, арки */
[data-theme="manuscript"] body { background:
  radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--surface) 70%, transparent), transparent 60%), var(--bg); }
[data-theme="manuscript"] h1, [data-theme="manuscript"] h2, [data-theme="manuscript"] h3, [data-theme="manuscript"] .act-label { font-family: "PT Serif", "Cormorant Garamond", Georgia, serif; }
[data-theme="manuscript"] .card {
  border: 2px solid var(--primary); border-radius: 4px;
  box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 5px color-mix(in srgb, var(--primary) 55%, transparent), 0 6px 18px rgba(0,0,0,.35);
  background-image: radial-gradient(color-mix(in srgb, var(--text) 4%, transparent) 1px, transparent 1px); background-size: 6px 6px; background-color: var(--surface);
}
[data-theme="manuscript"] main > section.card:first-of-type,
[data-theme="manuscript"] .host-notes { border-radius: 48% 48% 4px 4px / 64px 64px 4px 4px; padding-top: 34px; text-align: center; }
[data-theme="manuscript"] header.top { border-bottom: 3px double var(--primary); }
[data-theme="manuscript"] header.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 6px;
  background: repeating-linear-gradient(90deg, var(--primary) 0 6px, transparent 6px 12px, var(--accent) 12px 15px, transparent 15px 21px); opacity: .7; }
[data-theme="manuscript"] .clue { border-left-width: 2px; }
[data-theme="manuscript"] .clue .kind, [data-theme="manuscript"] .tagline { color: var(--accent); letter-spacing: .14em; }
[data-theme="manuscript"] .narration::first-letter { float: left; font: 700 3.1em/0.9 "PT Serif", Georgia, serif; color: var(--primary); padding: 4px 8px 0 0; }
[data-theme="manuscript"] main > section.card:first-of-type .narration::first-letter { float: none; font-size: 1.6em; }
[data-theme="manuscript"] button { border-radius: 3px; }

.art { display: block; width: 100%; height: auto; border-radius: 6px; border: 2px solid var(--primary); margin: 0 0 14px; }
.art-small { max-width: 420px; margin: 0 auto 12px; }
.portrait { display: block; width: 100%; max-height: 300px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--primary); margin-bottom: 10px; }
.login.with-cover { max-width: 760px; }
[data-theme="manuscript"] main > section.card:first-of-type .art { border-radius: 46% 46% 6px 6px / 48px 48px 6px 6px; }
