:root { --indigo:#2b3a67; --ochre:#c9962b; --green:#3f5e3a; --rust:#a4492e; --cream:#efe6d2; --ink:#151515; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9d9b4; font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; color: var(--ink); }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#grain { position: fixed; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .62; z-index: 5; }
.hidden { display: none !important; }
.card { background: var(--cream); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 18px 20px; position: relative; }
.card::after { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(21,21,21,.35); pointer-events: none; }
.card.small { padding: 10px 12px; box-shadow: 3px 3px 0 var(--ink); border-width: 2px; }
.kicker { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--rust); font-weight: bold; }
h1 { margin: 6px 0 14px; font-size: 44px; letter-spacing: .08em; color: var(--indigo); text-shadow: 3px 3px 0 var(--ochre); }
h2 { margin: 4px 0 12px; color: var(--indigo); }
.screen { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(380px, 92vw); z-index: 10; }
label { display: block; font-size: 13px; font-weight: bold; margin: 8px 0; }
input { width: 100%; font: inherit; padding: 8px 10px; border: 2px solid var(--ink); background: #fbf6ea; margin-top: 4px; }
input:focus { outline: 3px solid var(--ochre); }
button { font: inherit; font-weight: bold; padding: 9px 14px; border: 2px solid var(--ink); background: var(--indigo); color: var(--cream); cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
button.alt { background: var(--ochre); color: var(--ink); }
button.link { background: none; border: 0; box-shadow: none; color: var(--rust); padding: 4px 0 0; font-size: 12px; text-decoration: underline; }
.row { display: flex; gap: 10px; margin-top: 14px; } .row button { flex: 1; }
.err { color: var(--rust); font-weight: bold; min-height: 1.2em; margin-top: 8px; font-size: 14px; }
#creator { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.creator-card { position: absolute; right: 4vw; top: 50%; transform: translateY(-50%); width: min(400px, 92vw); pointer-events: auto; }
.opt { margin: 10px 0; } .opt > span { display: block; font-size: 12px; font-weight: bold; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { padding: 5px 10px; font-size: 13px; background: var(--cream); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.choices button.on { background: var(--indigo); color: var(--cream); }
.choices button.sw { width: 30px; height: 30px; padding: 0; }
.choices button.sw.on { outline: 3px solid var(--ochre); outline-offset: 1px; }
#enterBtn { width: 100%; margin-top: 8px; background: var(--rust); }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
#hud > * { pointer-events: auto; }
#tutorial { position: absolute; left: 14px; top: 14px; width: 260px; }
#tutorial ol { margin: 6px 0 0; padding-left: 0; list-style: none; font-size: 14px; }
#tutorial li { margin: 4px 0; padding-left: 24px; position: relative; }
#tutorial li::before { content: ""; position: absolute; left: 0; top: 2px; width: 13px; height: 13px; border: 2px solid var(--ink); background: #fbf6ea; }
#tutorial li.ok { color: #6d6658; text-decoration: line-through; }
#tutorial li.ok::before { background: var(--green); box-shadow: inset 0 0 0 2px var(--cream); }
#tutorial li.cur { font-weight: bold; }
#profile { position: absolute; right: 14px; top: 14px; width: 170px; }
.pname { font-weight: bold; font-size: 18px; color: var(--indigo); border-bottom: 2px solid var(--ink); margin-bottom: 4px; padding-bottom: 2px; overflow: hidden; text-overflow: ellipsis; }
.prow { display: flex; justify-content: space-between; font-size: 13px; }
#camsel { position: absolute; right: 14px; bottom: 14px; }
.camicons { display: flex; gap: 6px; }
.camicons button { width: 42px; height: 38px; padding: 3px; background: #fbf6ea; box-shadow: 2px 2px 0 var(--ink); display: grid; place-items: center; }
.camicons button svg { width: 30px; height: 26px; }
.camicons button.on { background: var(--ochre); }
.camlabel { text-align: center; font-weight: bold; font-size: 13px; letter-spacing: .15em; margin-top: 6px; }
kbd { border: 1.5px solid var(--ink); padding: 0 4px; font-size: 11px; background: #fbf6ea; }
#chat { position: absolute; left: 14px; bottom: 14px; width: min(360px, 60vw); }
#chatLog { max-height: 150px; overflow-y: auto; font-size: 13px; background: rgba(239,230,210,.86); border: 2px solid var(--ink); padding: 6px 8px; margin-bottom: 6px; }
#chatLog:empty { display: none; }
#chatLog div { margin: 2px 0; word-wrap: break-word; } #chatLog b { color: var(--indigo); } #chatLog .npc b { color: var(--green); } #chatLog .sys { color: var(--rust); font-style: italic; }
#chatIn { margin: 0; background: rgba(251,246,234,.92); }
#prompt { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); font-weight: bold; }
#done { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); width: min(360px, 90vw); text-align: center; }
#conn { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); }
#help { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; background: rgba(239,230,210,.8); padding: 3px 8px; border: 1.5px solid var(--ink); white-space: nowrap; }
@media (max-width: 900px) { #help { display: none; } #tutorial { width: 210px; font-size: 13px; } }
#tutCount { color: var(--ink); margin-left: 4px; } .chev { float: right; color: var(--ink); }
#tutorial { cursor: pointer; } #tutorial.collapsed ol { display: none; } #tutorial.collapsed { width: auto; } #tutorial.collapsed .chev { transform: rotate(-90deg); display: inline-block; }
#joy, .mbtn { display: none; }
@media (max-width: 760px), (pointer: coarse) {
  #help { display: none; }
  #tutorial { left: 8px; top: 8px; width: min(230px, 60vw); padding: 6px 9px; font-size: 12px; }
  #tutorial ol { font-size: 12px; } #tutorial li { padding-left: 20px; } #tutorial li::before { width: 10px; height: 10px; }
  #profile { right: 8px; top: 8px; width: auto; min-width: 0; padding: 5px 8px; }
  #profile .pname { font-size: 13px; margin: 0; padding: 0; border: 0; } #profile .prow { font-size: 11px; gap: 8px; } #profile .prow span { display: none; }
  #profile .link { font-size: 10px; padding: 0; }
  #camsel { right: 8px; bottom: 8px; padding: 5px 6px; } .camicons button { width: 32px; height: 30px; } .camicons button svg { width: 22px; height: 20px; } .camlabel { font-size: 11px; margin-top: 3px; }
  #camsel .camlabel kbd { display: none; }
  #chat { left: auto; right: 8px; bottom: 132px; width: min(240px, 62vw); }
  #chatLog { max-height: 64px; font-size: 11px; padding: 3px 6px; margin-bottom: 4px; background: rgba(239,230,210,.75); }
  #chatIn { display: none; font-size: 16px; } #chat.open #chatIn { display: block; }
  #joy { display: block; position: absolute; left: 18px; bottom: 22px; width: 116px; height: 116px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(239,230,210,.55); touch-action: none; }
  #joyKnob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--indigo); border: 3px solid var(--ink); pointer-events: none; }
  .mbtn { display: grid; place-items: center; position: absolute; right: 8px; width: 48px; height: 44px; padding: 0; font-size: 20px; background: var(--cream); }
  #mChat { bottom: 80px; right: 8px; } #mCam { display: none; }
  #done { top: 30%; } #prompt { bottom: 150px; }
  .creator-card { left: 50%; right: auto; top: auto; bottom: 8px; transform: translateX(-50%); padding: 10px 12px; max-height: 56vh; overflow-y: auto; }
  .creator-card h2 { font-size: 18px; margin: 2px 0 6px; } .opt { margin: 6px 0; }
  h1 { font-size: 34px; }
}
