:root {
  --ink: #f3ead8;
  --ink-dim: #b9ad95;
  --panel: rgba(24, 20, 16, 0.82);
  --panel-line: rgba(243, 234, 216, 0.14);
  --accent: #e8a948;
  --accent-ink: #2a1c08;
  --good: #8fd16a;
  --warn: #f0a24a;
  --bad: #ec5f52;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0f12; color: var(--ink);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#mini { width: 600px; max-width: 70vw; height: auto; image-rendering: pixelated; border: 1px solid var(--panel-line); border-radius: 6px; background: #000; box-shadow: 0 4px 18px rgba(0,0,0,.45); }
#status { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 999px; padding: 4px 14px; font-weight: 600; letter-spacing: .02em; }
#status .warn { color: var(--warn); }
#hazard { background: rgba(120,30,20,.88); border: 1px solid rgba(255,140,110,.5); border-radius: 999px; padding: 5px 16px; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
#hazard.urgent { animation: hzPulse .6s ease-in-out infinite alternate; }
@keyframes hzPulse { from { transform: scale(1); } to { transform: scale(1.06); background: rgba(170,40,25,.95); } }
#status .bad { color: var(--bad); }

#left { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 8px; width: 220px; }
.panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; padding: 10px 12px; }
.panel h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); display: flex; justify-content: space-between; }
.res { display: flex; justify-content: space-between; padding: 1px 0; font-variant-numeric: tabular-nums; }
.res .n { font-weight: 700; }
.res.zero { opacity: .45; }
.bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin: 4px 0 8px; }
.bar > i { display: block; height: 100%; background: var(--good); }
.state { margin-top: 6px; font-weight: 600; }
.state.warn { color: var(--warn); } .state.bad { color: var(--bad); } .state.good { color: var(--good); }
.keys { margin-top: 6px; font-size: 12px; color: var(--ink-dim); }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--panel-line); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,.06); font: 600 11px/16px "Segoe UI", system-ui, sans-serif; text-align: center; color: var(--ink); }

#events { position: absolute; top: 10px; right: 10px; width: 330px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.ev { background: var(--panel); border: 1px solid var(--panel-line); border-left: 3px solid var(--ink-dim); border-radius: 8px; padding: 6px 10px; animation: evIn .25s ease-out; transition: opacity .6s; }
.ev.warn { border-left-color: var(--warn); }
.ev.big { border-left-color: var(--accent); font-weight: 600; }
@keyframes evIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

#center { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 22px; font-weight: 700; text-align: center; text-shadow: 0 2px 10px #000; }
#toast { position: absolute; bottom: 104px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 14px; opacity: 0; transition: opacity .25s; max-width: 70vw; text-align: center; }
#toast.show { opacity: 1; }

#hotbar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: auto; }
.slot { width: 102px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 5px 6px 6px; cursor: pointer; position: relative; }
.slot .k { position: absolute; top: 3px; right: 6px; font-size: 11px; color: var(--ink-dim); font-weight: 700; }
.slot .nm { font-weight: 600; font-size: 12px; line-height: 1.15; min-height: 28px; padding-right: 12px; }
.slot .c { font-size: 11px; color: var(--ink-dim); }
.slot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.slot.sel .nm { color: var(--accent); }
.slot.na .c { color: var(--bad); }

.slot.fart { width: 96px; border-color: rgba(176,186,96,.55); }
.slot.fart .nm { color: #cfd88a; }
.slot.fart .c { color: var(--good); font-weight: 700; }
.slot.fart.cool { opacity: .6; }
.slot.fart.cool .c { color: var(--ink-dim); font-weight: 400; }
#tip { position: absolute; background: rgba(14,12,10,.92); border: 1px solid var(--panel-line); border-radius: 8px; padding: 7px 10px; max-width: 280px; font-size: 13px; display: none; }
#tip b { display: block; margin-bottom: 2px; }
#tip .ok { color: var(--good); } #tip .no { color: var(--ink-dim); } #tip .far { color: var(--bad); }
#helpHint { position: absolute; bottom: 14px; right: 14px; font-size: 12px; color: var(--ink-dim); background: var(--panel); padding: 3px 8px; border-radius: 6px; }

/* Overlays */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20,16,12,.72), rgba(5,5,7,.92)); z-index: 10; padding: 16px; }
.card { background: #1d1813; border: 1px solid var(--panel-line); border-radius: 14px; padding: 26px 30px; width: 460px; max-width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); user-select: text; }
.card.wide { width: 760px; }
.title { font: 800 40px/1 Georgia, "Times New Roman", serif; letter-spacing: .14em; color: var(--accent); }
.title.small { font-size: 26px; letter-spacing: .06em; }
.sub { color: var(--ink-dim); margin: 8px 0 18px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
input, select { font: inherit; color: var(--ink); background: #120f0c; border: 1px solid var(--panel-line); border-radius: 8px; padding: 9px 10px; text-transform: none; letter-spacing: 0; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--panel-line); background: #2b241c; color: var(--ink); padding: 9px 16px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
button:hover { filter: brightness(1.08); }
h3 { margin: 4px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-dim); }
#plist { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px; }
#plist li { display: flex; align-items: center; gap: 6px; background: #120f0c; border: 1px solid var(--panel-line); border-radius: 999px; padding: 4px 10px 4px 6px; }
#plist .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.4); }
.hint { color: var(--ink-dim); font-size: 13px; }
.hint.err { color: var(--bad); margin: -4px 0 12px; }
#addr b { color: var(--ink); user-select: all; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); }
.helpBody { font-size: 13.5px; }
.helpBody h4 { margin: 14px 0 6px; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
.helpBody ul { margin: 0; padding-left: 18px; }
.helpBody li { margin: 3px 0; }
.helpCols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
@media (max-width: 700px) { .helpCols { grid-template-columns: 1fr; } #left { width: 170px; } .slot { width: 64px; } .slot .c { display: none; } }

/* Ton */
.audioCtl { margin: 14px 0 4px; padding: 10px 12px; background: #120f0c; border: 1px solid var(--panel-line); border-radius: 10px; }
.audioRow { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.audioRow span { width: 92px; flex: none; }
.audioRow input[type=range] { flex: 1; accent-color: var(--accent); padding: 0; background: none; border: 0; }
.audioCtl .hint { margin: 6px 0 0; font-size: 12px; }
.audioHead { margin: 18px 0 0; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }

@media (max-width: 1460px) { #helpHint { bottom: 98px; } }
