:root {
  --bg: #15181f; --panel: #1f2430; --line: #343b4d; --text: #e7e3d8; --muted: #9a9fb0;
  --accent: #8fc1e3; --gold: #e3c47b; --bad: #e38f8f; --good: #9fd69b;
  font-family: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
button { font: inherit; background: #2c3446; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .35rem .8rem; cursor: pointer; }
button:hover, button:focus-visible { border-color: var(--accent); }
input { font: inherit; background: #10131a; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
.info { color: var(--gold); }

.card { max-width: 30rem; margin: 3rem auto; padding: 1.5rem 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card form { display: grid; gap: .8rem; }
.card label { display: grid; gap: .2rem; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.top nav { display: flex; gap: .8rem; align-items: center; }
.top form { margin: 0; }

.game { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 1fr); gap: 1rem; padding: 1rem; max-width: 1400px; margin: auto; }
.scene-col h2 { margin: 0 0 .5rem; }
.scene { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.scene img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.hs { position: absolute; padding: .2rem; display: flex; align-items: flex-end; justify-content: center; text-align: center;
  background: rgba(255,255,255,.04); border: 1px dashed rgba(255,255,255,.35); color: #fff; font-size: clamp(.65rem, 1.1vw, .9rem);
  text-shadow: 0 1px 3px #000; border-radius: 6px; }
.hs:hover, .hs:focus-visible { background: rgba(143,193,227,.18); border-style: solid; border-color: var(--accent); }
.hs-npc { border-color: rgba(227,196,123,.6); }
.hs-exit { border-color: rgba(143,193,227,.6); }

.narration { margin-top: .8rem; padding: .6rem 1rem; background: var(--panel); border-left: 3px solid var(--gold); border-radius: 4px; }
.narration p { margin: .3rem 0; }
.note { color: var(--gold); }

.chat { margin-top: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.chat header { display: flex; justify-content: space-between; align-items: center; }
#chat-log { max-height: 22rem; overflow-y: auto; margin: .6rem 0; display: flex; flex-direction: column; gap: .4rem; }
.line { margin: 0; padding: .4rem .7rem; border-radius: 8px; max-width: 85%; white-space: pre-wrap; }
.line.user { align-self: flex-end; background: #2c3a52; }
.line.npc { align-self: flex-start; background: #2b2f3a; }
.line.pending { color: var(--muted); }
.line.note { align-self: center; color: var(--gold); font-size: .9rem; }
.line.error { align-self: center; color: var(--bad); font-size: .9rem; }
#chat-form { display: flex; gap: .5rem; }
#chat-form input { flex: 1; }

.side { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; align-self: start; }
.side h3 { margin: .3rem 0 .5rem; }
.inv-item { display: block; padding: .3rem .5rem; border-radius: 6px; cursor: pointer; }
.inv-item input { position: absolute; opacity: 0; }
.inv-item:has(input:checked) { background: #2c3a52; outline: 1px solid var(--accent); }
.inv-item:has(input:focus-visible) { outline: 2px solid var(--accent); }
.inv-item small { display: none; color: var(--muted); }
.inv-item:has(input:checked) small { display: block; }
.journal { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.journal span { display: block; color: var(--muted); font-size: .9rem; }

.ending { max-width: 40rem; }
.epilogue { white-space: pre-line; }

.admin { padding: 1rem; max-width: 1400px; margin: auto; }
.admin table { width: 100%; border-collapse: collapse; }
.admin th, .admin td { border-bottom: 1px solid var(--line); padding: .4rem; text-align: left; vertical-align: top; }
.admin .actions form { display: inline-flex; gap: .3rem; margin: 0 .3rem .3rem 0; }
.st-pending { color: var(--gold); } .st-active { color: var(--good); } .st-rejected, .st-disabled { color: var(--bad); }
.msg { border-left: 3px solid var(--line); padding: .3rem .8rem; margin: .4rem 0; }
.msg p { margin: .2rem 0; white-space: pre-wrap; }
.msg .meta { color: var(--muted); font-size: .8rem; }
.role-user { border-color: var(--accent); } .role-assistant { border-color: var(--gold); }
.tool { font-family: monospace; color: var(--muted); }
.ok { color: var(--good); } .ko { color: var(--bad); }

@media (max-width: 800px) {
  .game { grid-template-columns: 1fr; padding: .5rem; }
  .top { flex-wrap: wrap; }
}
