@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Medium.ttf"); font-weight: 500; }
@font-face { font-family: "Cormorant"; src: url("fonts/CormorantGaramond.ttf"); font-weight: 300 700; }

:root {
  --gold: #d9b978; --text: #e9eef4; --muted: #a4b4c6; --navy: #091522; --line: #405164;
  --good: #76e6bd; --warn: #ffb58a; --field: #06101b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #050b13 url("img/title_bg.png") center / cover fixed;
  color: var(--text); font: 16px "Alegreya Sans", sans-serif;
  display: flex; flex-direction: column;
}
body::before { content: ""; position: fixed; inset: 0; background: rgba(4, 9, 15, .86); z-index: -1; }
button {
  font: 500 15px "Alegreya Sans", sans-serif; color: var(--text); background: #0b1828;
  border: 1px solid color-mix(in srgb, var(--acc, var(--gold)) 55%, transparent); border-radius: 7px;
  padding: 6px 12px; cursor: pointer;
}
button:hover, button:focus-visible { background: #142438; border-color: var(--acc, var(--gold)); outline: none; }
button:disabled { opacity: .35; cursor: default; }
button.good { --acc: var(--good); } button.warn { --acc: var(--warn); } button.line { --acc: #7d8fa3; } button.gold { --acc: var(--gold); }
button.mini { padding: 2px 8px; font-size: 14px; }
input, textarea, select {
  font: 16px "Alegreya Sans", sans-serif; color: var(--text); background: var(--field);
  border: 1px solid rgba(217, 185, 120, .3); border-radius: 5px; padding: 6px 10px; caret-color: var(--gold);
}
input:focus, textarea:focus, select:focus { border-color: rgba(217, 185, 120, .75); outline: none; }
select option { background: var(--navy); }
textarea { resize: vertical; width: 100%; line-height: 1.3; }

#top {
  display: flex; align-items: center; gap: 18px; margin: 8px 16px 0; padding: 6px 14px;
  background: rgba(9, 21, 34, .96); border: 1px solid rgba(217, 185, 120, .6); border-radius: 7px;
}
h1, h2, .serif { font-family: "Cormorant", serif; font-weight: 650; color: var(--gold); margin: 0; }
h1 { font-size: 26px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
#status { flex: 1; color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status.warn { color: var(--warn); } #status.good { color: var(--good); }
.tools { display: flex; gap: 6px; }

main { flex: 1; display: flex; gap: 10px; margin: 8px 16px; min-height: 0; }
#left, #editor, #preview-wrap {
  background: rgba(9, 21, 34, .96); border: 1px solid rgba(217, 185, 120, .45); border-radius: 7px;
}
#left { width: 340px; display: flex; flex-direction: column; padding: 8px; min-height: 0; }
#filter { width: 100%; margin-bottom: 6px; }
#list { flex: 1; overflow-y: auto; outline: none; font-size: 15px; }
#list .group { color: var(--gold); text-transform: uppercase; font-size: 13px; letter-spacing: .06em; padding: 10px 6px 3px; }
#list .item { padding: 3px 6px 3px 16px; border-radius: 4px; cursor: pointer; }
#list .item:hover { background: #102033; }
#list .item.sel { background: #142438; color: var(--gold); box-shadow: inset 2px 0 var(--gold); }
#list .item.empty { color: #6f8091; }
#list .item.changed::after { content: " •"; color: var(--warn); }

#right { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
#editor { flex: 1; overflow-y: auto; padding: 10px 16px 14px; min-height: 160px; }
#editor .head { margin-bottom: 8px; }
h2 { font-size: 23px; }
#desc { color: var(--muted); font-size: 14px; margin: 2px 0 0; }

.line-row {
  display: grid; grid-template-columns: 34px 220px 1fr auto; gap: 8px; align-items: start;
  padding: 6px; border-radius: 6px; border: 1px solid transparent;
}
.line-row.cur { border-color: rgba(217, 185, 120, .55); background: rgba(20, 36, 56, .6); }
.line-row .n { color: var(--muted); font-size: 14px; padding-top: 7px; text-align: right; }
.line-row .who { display: flex; flex-direction: column; gap: 4px; }
.line-row .who select { width: 100%; }
.line-row .who img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 1px solid rgba(217,185,120,.3); }
.line-row .who img.face { width: 64px; height: 64px; aspect-ratio: 1; object-fit: cover; border-radius: 4px; border: 1px solid rgba(217,185,120,.35); }
.line-row .acts { display: flex; flex-direction: column; gap: 3px; }
.line-row .count { color: var(--muted); font-size: 13px; }
.line-row .count.over { color: var(--warn); }
.add-first { margin: 6px 0; }
.form { display: grid; grid-template-columns: 260px 1fr; gap: 10px 14px; align-items: center; max-width: 900px; }
.form label { color: var(--muted); }
.form .row { display: flex; gap: 8px; align-items: center; }
.form input[type=text] { width: 100%; }
.hintline { color: var(--muted); font-size: 14px; margin-top: 6px; }
.big-face { width: 128px; height: 128px; object-fit: cover; border: 1px solid rgba(217,185,120,.45); border-radius: 7px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: #06101b; border: 1px solid rgba(217,185,120,.25); border-radius: 6px; padding: 6px; }
.gallery figure.new { border-color: var(--good); }
.gallery img { width: 100%; height: 110px; object-fit: contain; display: block; }
.gallery figcaption { font-size: 13px; color: var(--muted); word-break: break-all; margin-top: 4px; display: flex; justify-content: space-between; gap: 4px; }
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; padding: 10px; border: 1px dashed rgba(217,185,120,.4); border-radius: 7px; }

#preview-wrap { padding: 6px 10px 10px; }
.preview-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.grow { flex: 1; }
#preview { width: min(100%, calc(42vh * 16 / 9)); aspect-ratio: 16 / 9; margin: 0 auto; }
body.big #editor { display: none; }
body.big #preview { width: min(100%, calc((100vh - 170px) * 16 / 9)); }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 0 8px; }

/* ---------- кадр 1280×720, как в игре ---------- */
.stage-box { position: relative; overflow: hidden; background: #03030a; border-radius: 4px; }
.stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
.stage * { position: absolute; margin: 0; }
.stage .bg { inset: 0; background: url("img/title_bg.png") center / cover; }
.stage .shade { inset: 0; background: rgba(4.6, 9, 15.3, .55); }
.stage .t { font-family: "Alegreya Sans", sans-serif; color: var(--text); white-space: pre-wrap; overflow: hidden; line-height: 1.22; }
.stage .h { font-family: "Cormorant", serif; font-weight: 650; color: var(--gold); white-space: nowrap; overflow: hidden; line-height: 1.2; }
.stage .center { text-align: center; }
.stage .panel { background: rgba(9, 21, 34, .96); border: 1px solid; border-radius: 7px; }
.stage .rule { height: 1px; }
.stage .pic { object-fit: cover; width: 1280px; height: 720px; left: 0; top: 0; }
.stage .hint { font-size: 14px; color: var(--muted); text-align: right; font-family: "Alegreya Sans", sans-serif; white-space: pre; }

#player { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; align-items: center; justify-content: center; }
#player-stage { width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; }

#toast-msg {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 60;
  background: rgba(9, 21, 34, .98); border: 1px solid var(--gold); border-radius: 7px; padding: 10px 18px; max-width: 80vw;
}
