/* Shared interface of every living-NPC game. Games override the colour variables in their own page. */
  :root { --ink: #f3e9d2; --muted: #b8a98c; --panel: rgba(28, 22, 16, 0.86); --edge: #6b5133; --accent: #d9a441; --bad: #c0392b; --btn: #4a3520; }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: #1b1610; color: var(--ink); font: 14px/1.4 Georgia, 'Times New Roman', serif; overflow: hidden; }
  #c, canvas#c { display: block; width: 100vw; height: 100vh; touch-action: none; }
  #labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
  button, select, input { font: inherit; color: var(--ink); }
  button { background: var(--btn); border: 1px solid var(--edge); border-radius: 4px; padding: 6px 12px; cursor: pointer; }
  button:hover { filter: brightness(1.15); }
  select { background: var(--btn); border: 1px solid var(--edge); border-radius: 4px; padding: 4px 6px; }
  .panel { position: fixed; background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; }
  .hidden { display: none !important; }
  #hud { top: 10px; left: 10px; padding: 8px 12px; min-width: 200px; }
  #hud b { color: var(--accent); }
  #hpbar { height: 8px; background: #3a2a1a; border-radius: 4px; margin: 6px 0; overflow: hidden; }
  #hpfill { height: 100%; background: #6aa84f; width: 100%; transition: width .2s; }
  #target { color: var(--muted); }
  #tools { top: 10px; right: 10px; display: flex; gap: 6px; position: fixed; }
  #tools button { padding: 6px 10px; }
  #help { top: 52px; right: 10px; padding: 8px 12px; max-width: 290px; font-size: 12.5px; }
  #help summary { cursor: pointer; color: var(--accent); }
  #tok { top: 52px; right: 10px; padding: 10px 12px; width: min(420px, calc(100vw - 20px)); font-size: 12.5px; max-height: 70vh; overflow: auto; }
  #tok table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  #tok td, #tok th { padding: 2px 4px; text-align: right; border-bottom: 1px solid rgba(107, 81, 51, .5); white-space: nowrap; }
  #tok td:first-child, #tok th:first-child, #tok td:nth-child(2), #tok th:nth-child(2) { text-align: left; }
  #tok .sum { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; margin-bottom: 8px; }
  #tok .sum b { color: var(--accent); }
  #tok .note { color: var(--muted); margin-top: 6px; }
  #chat { left: 10px; bottom: 10px; width: min(440px, calc(100vw - 20px)); display: flex; flex-direction: column; }
  #log { height: 170px; overflow-y: auto; padding: 8px 10px; font-size: 13px; }
  #log div { margin-bottom: 3px; overflow-wrap: anywhere; }
  #log .who { color: var(--accent); font-weight: bold; }
  #log .sys { color: var(--muted); font-style: italic; }
  #log .faint { opacity: .6; font-style: italic; }
  #log .me .who { color: #8fc1e3; }
  #say { display: flex; border-top: 1px solid var(--edge); }
  #say input { flex: 1; background: transparent; border: 0; padding: 9px 10px; outline: none; min-width: 0; }
  #say button { border-radius: 0; border-width: 0 0 0 1px; }
  #say #mic, #say #voiceBtn { font-size: 16px; padding: 6px 10px; }
  #say #mic.rec { background: var(--bad); }
  #say #sendbtn { border-radius: 0 0 6px 0; }
  #btns { position: fixed; right: 10px; bottom: 10px; display: flex; gap: 8px; }
  #btns button { padding: 12px 16px; font-size: 15px; }
  #btns .danger { background: #6b1f1a; }
  .overlay { inset: 0; position: fixed; display: flex; align-items: center; justify-content: center; background: rgba(15, 10, 5, .6); z-index: 5; padding: 16px; }
  .overlay .panel { position: static; padding: 22px 26px; max-width: 460px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; }
  .overlay h2 { margin: 0 0 10px; font-size: 1.3rem; }
  #dead { background: rgba(40, 0, 0, .55); }
  #create .row { margin: 12px 0; }
  #create label.cap { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
  #create input#nm { width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--edge); border-radius: 4px; padding: 8px 10px; font-size: 16px; }
  #sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  #sugg button { padding: 3px 9px; font-size: 13px; }
  .swatches { display: flex; flex-wrap: wrap; gap: 6px; }
  .swatches button { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
  .swatches button.on { border-color: var(--accent); box-shadow: 0 0 0 2px #000 inset; }
  .seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 4px; overflow: hidden; }
  .seg button { border: 0; border-radius: 0; background: transparent; }
  .seg button.on { background: var(--btn); color: var(--accent); }
  #createErr { color: #e07a6a; min-height: 1.2em; }
  #preview { float: right; margin: 0 0 8px 12px; background: #5d7a3a; border: 1px solid var(--edge); border-radius: 6px; }
  .hint { color: var(--muted); font-size: 12.5px; }
  #mind { clear: both; border: 1px solid var(--edge); border-radius: 6px; padding: 10px 12px; margin: 10px 0; background: rgba(0,0,0,.18); }
  #mind .krow { display: flex; gap: 6px; }
  #mind input[type=password], #mind input[type=text] { flex: 1; min-width: 0; background: rgba(0,0,0,.3); border: 1px solid var(--edge); border-radius: 4px; padding: 7px 9px; }
  #keyStatus { min-height: 1.2em; font-size: 12.5px; margin-top: 4px; }
  #keyStatus.ok { color: #8fd18f; } #keyStatus.bad { color: #e07a6a; }
  #modelList { max-height: 180px; overflow: auto; border: 1px solid var(--edge); border-radius: 4px; margin-top: 4px; }
  #modelList button { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; padding: 5px 8px; font-size: 12.5px; }
  #modelList button:hover, #modelList button.on { background: var(--btn); }
  #modelList small { color: var(--muted); white-space: nowrap; }
  #modelCur b { color: var(--accent); }
  #tok #mind { margin-top: 10px; }
  #tok tr.mine td { color: #8fc1e3; }
  #vill label.opt { display: block; margin: 4px 0; cursor: pointer; }
  #vill textarea { width: 100%; min-height: 130px; background: rgba(0,0,0,.3); border: 1px solid var(--edge); border-radius: 4px; color: var(--ink); font: 12.5px/1.45 Georgia, serif; padding: 8px; resize: vertical; }
  #vill input#vcode { background: rgba(0,0,0,.3); border: 1px solid var(--edge); border-radius: 4px; padding: 5px 8px; width: 120px; }
  .side { top: 52px; right: 10px; padding: 10px 12px; width: min(460px, calc(100vw - 20px)); max-height: calc(100vh - 140px); overflow: auto; font-size: 12.5px; }
  .side h3 { margin: 0 0 6px; font-size: 14px; color: var(--accent); display: flex; justify-content: space-between; align-items: center; }
  .side h3 button { padding: 0 8px; }
  #relTable { border-collapse: collapse; font-variant-numeric: tabular-nums; }
  #relTable th { font-weight: normal; color: var(--muted); padding: 2px; white-space: nowrap; }
  #relTable thead th { writing-mode: vertical-rl; transform: rotate(180deg); height: 70px; text-align: left; }
  #relTable td { width: 26px; height: 22px; text-align: center; font-size: 10.5px; color: #111; border: 1px solid rgba(0,0,0,.25); }
  #relTable td.self { background: transparent; }
  #relTable td.na { color: var(--muted); background: transparent; }
  .bars .bar { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 6px; margin: 2px 0; }
  .bars .track { position: relative; height: 12px; background: rgba(255,255,255,.06); border-radius: 2px; }
  .bars .track::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; border-left: 1px solid var(--muted); }
  .bars .fill { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
  .bars .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
  .why { color: var(--muted); font-size: 11.5px; margin: -1px 0 4px 98px; }
  #share { margin: 6px 0; } #share input { width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--edge); border-radius: 4px; padding: 4px 6px; font-size: 12px; }
  #enter { width: 100%; padding: 10px; font-size: 16px; margin-top: 6px; background: #5a3d1c; }
  @media (max-width: 640px) {
    #chat { width: calc(100vw - 110px); } #log { height: 100px; } #hud { font-size: 12.5px; min-width: 150px; }
    #tools button span.lbl { display: none; }
  }
