﻿/* Witchwood: Night Run */
:root {
  --bg: #070b12; --card: rgba(12, 17, 26, .92); --line: rgba(214, 186, 120, .22); --text: #e8e2d2; --muted: #9a9688;
  --gold: #d9b56a; --gold2: #f3d58e; --hp: #c8343c; --sta: #4caf6a; --mag: #4a86e0; --warn: #ffb35a; --bad: #ff6a5a; --ok: #8fd68a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
.game { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Cinzel, Georgia, serif; font-weight: 700; letter-spacing: .02em; margin: 0; }
kbd { font: 600 11px Inter, sans-serif; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: #fff; }
a { color: var(--gold2); }

/* ---------- buttons ---------- */
.btn { font: 600 14px Inter, sans-serif; color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor: pointer; }
.btn:hover { background: rgba(255,255,255,.12); }
.btn.primary { background: linear-gradient(180deg, #e2c27a, #b88d3e); color: #1b1407; border-color: #f3d58e; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { font-size: 16px; padding: 13px 22px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { border-color: rgba(255,106,90,.4); color: #ffb0a6; }
.linkbtn { background: none; border: 0; color: var(--gold2); cursor: pointer; font: 600 13px Inter, sans-serif; padding: 0; }

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; z-index: 20; }
#pause, #results, #help, #loading { background: rgba(3,5,10,.62); }
#help { z-index: 30; }
.card { width: min(620px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.6); margin: auto; }
.card.small { width: min(440px, 100%); text-align: center; }
.card h2 { font-size: 26px; color: var(--gold2); margin-bottom: 4px; }
.card .sub { color: var(--muted); margin: 0 0 14px; }
.col { display: grid; gap: 8px; margin: 14px 0; }
.links { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.sets { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 12px; }
.sets input { accent-color: var(--gold); }
.ad-wrap { width: 100%; text-align: center; margin-top: 12px; }
.ad-wrap.ad-on { min-height: 100px; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; margin-left: auto; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

/* ---------- hub ---------- */
.hub { place-items: start center; padding-top: max(16px, 4vh); }
.hub-card { width: min(760px, 100%); background: rgba(10, 14, 22, .88); }
.hub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hub-head h1 { font-size: clamp(30px, 6vw, 44px); color: var(--gold2); text-shadow: 0 0 24px rgba(243,213,142,.25); line-height: 1; }
.tagline { margin: 4px 0 0; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.silver { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 20px; }
.silver b { color: var(--gold2); font-size: 22px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: 600 14px Inter, sans-serif; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); }
.tabpane h3 { font-size: 15px; color: var(--gold); margin: 16px 0 8px; }
.tabpane h3 small { font-family: Inter, sans-serif; color: var(--muted); font-weight: 400; font-size: 12px; letter-spacing: 0; }
.story { background: rgba(217,181,106,.07); border-left: 3px solid var(--gold); padding: 4px 14px; border-radius: 0 10px 10px 0; color: #d6d0bf; font-size: 14px; }
.story p { margin: 8px 0; }
.forecast { display: flex; gap: 14px; align-items: center; background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 12px; }
.fc-moon { font-size: 34px; }
.forecast b { display: block; }
.forecast span { color: var(--muted); font-size: 13px; }
em.warn { color: var(--warn); font-style: normal; }
.zones { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.zone, .g { text-align: left; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 10px 12px; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 3px; font: 13px/1.35 Inter, sans-serif; }
.zone:hover, .g:hover { background: rgba(255,255,255,.08); }
.zone b, .g b { font-size: 14px; color: #f2ead6; }
.zone span, .g span { color: var(--muted); }
.zone small { color: #8e8a7e; font-size: 11px; }
.zone i, .g i { font-style: normal; font-size: 12px; font-weight: 600; margin-top: auto; padding-top: 4px; color: var(--muted); }
.zone.sel, .g.sel { border-color: var(--gold); background: rgba(217,181,106,.1); }
.zone.locked, .g.locked { opacity: .82; }
.zone.locked b, .g.locked b { color: #c8c2b0; }
i.ok { color: var(--ok) !important; }
i.price { color: var(--gold2) !important; }
i.lockt { color: #8e8a7e !important; }
.g em { font-style: normal; color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.gear { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 14px; font-size: 13px; color: #cfc8b4; background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 12px; }
.go-row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.go-row .primary { flex: 1; min-width: 220px; }
.jour { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.je { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.je b { color: var(--gold2); }
.je p { margin: 4px 0 0; color: #bdb7a6; }
.je.unk b { color: #6c6a62; }
.je.unk p { color: #6c6a62; font-style: italic; }
.je small { color: var(--gold); }
.rec { display: flex; flex-wrap: wrap; gap: 8px; }
.rec span { background: rgba(255,255,255,.05); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.rec b { color: var(--text); margin-left: 4px; }

/* ---------- results ---------- */
.r-lines { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.r-lines li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: rgba(255,255,255,.04); border-radius: 8px; font-size: 14px; }
.r-lines li.ok { color: var(--ok); }
.r-lines li.no { color: #8a857a; }
.r-lines li.note { background: none; color: var(--muted); font-size: 12px; font-style: italic; padding: 2px 10px; }
.r-lines li.empty { color: var(--muted); }
.r-earn { text-align: center; font-size: 18px; margin: 14px 0 4px; }
.r-earn b { color: var(--gold2); font-size: 26px; display: block; }
.r-earn small { color: var(--muted); font-size: 13px; }
.r-journal { text-align: center; color: #b9a7ff; font-size: 13px; margin: 4px 0; }
.r-tip { text-align: center; color: var(--muted); font-size: 13px; font-style: italic; }
#results .btn.big { width: 100%; margin-top: 8px; }
.card.bad h2 { color: #ff8a7a; }
.help .keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; font-size: 13px; color: #cfc8b4; }
.help .tips { padding-left: 18px; font-size: 13.5px; color: #cfc8b4; }
.help .tips li { margin: 6px 0; }
.help h3 { color: var(--gold); font-size: 16px; margin-top: 14px; }
.help .btn { width: 100%; margin-top: 8px; }
.touch-only { display: none; font-size: 13px; color: #cfc8b4; }
body.touch .touch-only { display: block; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; font-size: 13px; text-shadow: 0 1px 2px #000; }
.hud button { pointer-events: auto; }
.hud-l { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); width: 250px; }
.bars { display: grid; gap: 5px; }
.bar { position: relative; height: 18px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.14); border-radius: 9px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 9px; transition: width .12s linear; }
.bar.hp i { background: linear-gradient(90deg, #8a1c24, var(--hp)); }
.bar.sta i { background: linear-gradient(90deg, #2a6a3a, var(--sta)); }
.bar.mag i { background: linear-gradient(90deg, #2a4a8a, var(--mag)); }
.bar span { position: relative; padding-left: 9px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; line-height: 16px; color: rgba(255,255,255,.85); }
.bar b { position: absolute; right: 8px; top: 0; font-size: 11px; line-height: 16px; }
.status { display: flex; gap: 6px; margin-top: 6px; font-size: 16px; min-height: 22px; }
.status .off { opacity: .8; }
.status .danger { animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.25); filter: drop-shadow(0 0 6px #f44); } }
.objs { list-style: none; padding: 8px 10px; margin: 6px 0 0; background: rgba(5,8,14,.55); border-radius: 10px; border: 1px solid rgba(255,255,255,.07); }
.objs li { margin: 2px 0; color: #e0d9c6; }
.objs li small { color: var(--gold); margin-left: 3px; }
.objs li em { font-style: normal; color: #8e8a7e; font-size: 11px; }
.objs li.done { color: var(--ok); }
.objs li.haul { color: var(--gold2); margin-top: 4px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 4px; }
.clock { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; display: flex; flex-direction: column; align-items: center; }
.clock b { font: 700 18px Cinzel, Georgia, serif; color: #f2ead6; }
.clock span { font-size: 12px; color: var(--muted); }
.clock span.warn { color: var(--warn); font-weight: 700; animation: pulse 1s infinite alternate; }
.sky { --p: 0; position: relative; width: 150px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #0b1430, #101a3a 70%, #4a4a6a 88%, #d89a5a); border: 1px solid rgba(255,255,255,.15); margin-bottom: 4px; }
.sky i { position: absolute; top: 50%; left: calc(var(--p) * 100%); width: 10px; height: 10px; border-radius: 50%; background: #f2efe0; box-shadow: 0 0 8px #fff; transform: translate(-50%, -50%); }
.hud-r { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.mini-wrap { width: 150px; height: 150px; border-radius: 50%; overflow: hidden; border: 2px solid rgba(217,181,106,.45); box-shadow: 0 0 20px rgba(0,0,0,.7); background: #05070a; }
.mini-wrap canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.hud-btns { display: flex; gap: 4px; }
.hb { background: rgba(5,8,14,.7); border: 1px solid rgba(255,255,255,.15); color: var(--text); border-radius: 8px; padding: 5px 8px; font: 600 12px Inter, sans-serif; cursor: pointer; }
.hb span.warn, #weight.warn { color: var(--warn); }
.compass { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle, #2a2418, #120e08); border: 2px solid #8a6a2a; position: relative; display: grid; place-items: center; }
.compass .needle { position: absolute; left: 50%; top: 6px; width: 4px; height: 42px; margin-left: -2px; background: linear-gradient(#ff5040 50%, #ddd 50%); border-radius: 2px; transition: transform .2s; }
.compass small { position: absolute; bottom: -16px; font-size: 10px; color: var(--gold2); white-space: nowrap; }
.toasts { position: absolute; left: 50%; top: 74px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(560px, 92vw); }
.toast { background: rgba(8,11,18,.82); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 7px 14px; text-align: center; color: #e8e2d2; animation: tin .35s ease-out; transition: opacity .6s, transform .6s; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.big { font: 700 16px Cinzel, Georgia, serif; color: var(--gold2); border-color: var(--line); }
.toast.warn { border-color: rgba(255,120,80,.5); color: #ffc8b0; }
.toast.good { border-color: rgba(140,214,138,.4); color: #d2f3c8; }
.toast.journal { border-color: rgba(185,167,255,.5); color: #d8ccff; }
.toast.tip { border-color: rgba(217,181,106,.4); color: #f2e2b8; }
.toast.obj { color: #f2e2b8; font-size: 12.5px; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.prompt { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(8,11,18,.85); border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px 9px; font-weight: 600; text-align: center; min-width: 200px; }
.pbar { height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: var(--gold2); }
.spellbar { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 5px; align-items: center; }
.slot { position: relative; width: 50px; height: 50px; border-radius: 10px; background: rgba(5,8,14,.75); border: 1px solid rgba(255,255,255,.18); color: #fff; font-size: 22px; cursor: pointer; overflow: hidden; display: grid; place-items: center; padding: 0; }
.slot.on { border-color: var(--gold2); box-shadow: 0 0 12px rgba(243,213,142,.45); }
.slot.dim span { opacity: .35; }
.slot kbd { position: absolute; left: 3px; top: 2px; font-size: 9px; padding: 0 3px; }
.slot .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.6); }
.slot b { position: absolute; right: 4px; bottom: 1px; font-size: 12px; }
.slot.pot { width: 44px; height: 44px; font-size: 18px; }
.sep { width: 8px; }

/* satchel & map */
.satchel { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 250px; width: min(330px, 92vw); max-height: calc(100% - 340px); min-height: 160px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; z-index: 12; }
.sat-head { display: flex; align-items: center; gap: 10px; }
.sat-head span { color: var(--muted); font-size: 12px; }
#sat-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
#sat-list li { display: grid; grid-template-columns: 28px 1fr auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; background: rgba(255,255,255,.04); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
#sat-list .si { grid-row: span 2; font-size: 20px; }
#sat-list small { color: var(--muted); grid-column: 2; }
#sat-list button { grid-row: 1 / span 2; grid-column: 3; }
#sat-list .empty { display: block; color: var(--muted); font-size: 13px; }
.sat-note { color: #7e7a6e; font-size: 11px; font-style: italic; margin: 0; }
.bigmap { position: absolute; inset: 0; display: grid; place-items: center; z-index: 12; background: rgba(0,0,0,.45); padding: 16px; }
.bm-card { width: min(92vmin, 900px); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.bm-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.bm-head span { color: var(--muted); font-size: 12px; }
#bigmap-cv { width: 100%; aspect-ratio: 1; display: block; border-radius: 8px; image-rendering: pixelated; }

/* touch */
.touch { position: absolute; inset: 0; z-index: 11; pointer-events: none; }
.stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 62%; pointer-events: auto; touch-action: none; }
.stick { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(0,0,0,.2); }
.knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%; background: rgba(243,213,142,.45); transform: translate(-50%,-50%); }
.tbtns { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(76px, calc(env(safe-area-inset-bottom) + 64px)); display: grid; grid-template-columns: repeat(3, 58px); gap: 8px; pointer-events: auto; direction: rtl; }
.tb { width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(5,8,14,.6); color: #fff; font-size: 24px; touch-action: none; }
.tb.big { width: 58px; height: 58px; background: rgba(60,90,150,.55); border-color: rgba(160,200,255,.6); }
.tb.sm { width: 46px; height: 46px; font-size: 18px; justify-self: center; }
.tb.on { background: rgba(243,213,142,.5); }
body.touch .spellbar { bottom: max(10px, env(safe-area-inset-bottom)); }
body.touch .slot { width: 42px; height: 42px; font-size: 18px; }
body.touch .slot.pot { width: 38px; height: 38px; }
body.touch .prompt { bottom: 200px; }

@media (max-width: 720px) {
  .hud-l { width: 180px; }
  .objs { font-size: 11.5px; padding: 6px 8px; }
  .mini-wrap { width: 104px; height: 104px; }
  .clock { top: auto; bottom: 66px; }
  .clock b { font-size: 14px; }
  .sky { width: 110px; }
  .toasts { top: 160px; }
  .toast { font-size: 12px; padding: 5px 10px; }
  .satchel { top: 190px; max-height: calc(100% - 260px); }
  .card { padding: 16px; }
}
@media (max-height: 520px) {
  .objs { display: none; }
  .mini-wrap { width: 90px; height: 90px; }
  .toasts { top: 40px; }
}
