/* Keller · style.css (shell from nights 052-053) */
:root {
  --bg: #070a16; --ui-text: #e8e3d6; --muted: #8d97ab; --amber: #e8a84a; --violet: #a98bff;
  --panel-bg: rgba(8, 12, 22, 0.74); --panel-border: rgba(255, 255, 255, 0.1); --field: rgba(10, 14, 27, 0.92);
  --mono: ui-monospace, Menlo, "SF Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ui-text); -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#cv { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; display: block;
  touch-action: none; cursor: pointer; background: #000; }

a.home { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: calc(14px + env(safe-area-inset-left, 0px)); z-index: 8;
  font-size: 12px; color: #8d9ab0; text-decoration: none; padding: 4px 7px; border-radius: 5px;
  background: rgba(6, 10, 22, 0.84); border: 1px solid var(--panel-border); }
a.home:hover, a.home:focus-visible { color: var(--amber); }

/* HUD and message log share one column: bottom-left on wide screens (log above HUD), top-left below the
   back link on narrower ones (HUD above log) */
.info { position: fixed; z-index: 8; left: calc(14px + env(safe-area-inset-left, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; max-width: calc(100vw - 28px); }
.hud { font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--muted); padding: 5px 8px; border-radius: 6px; white-space: pre-wrap;
  background: rgba(6, 10, 22, 0.84); border: 1px solid var(--panel-border); font-variant-numeric: tabular-nums; max-width: 100%; }
.hud .v { color: var(--ui-text); }
.hud .note { color: var(--amber); }

.title-overlay { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); z-index: 9;
  text-align: center; pointer-events: none; opacity: 1; transition: opacity 1s ease;
  max-width: min(440px, calc(100vw - 300px)); padding: 6px 18px; border-radius: 12px;
  background: rgba(8, 10, 18, 0.82); border: 1px solid var(--panel-border); }
.title-overlay.faded { opacity: 0; }
.title-overlay h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.06em; color: #f0e2c4; text-shadow: 0 1px 12px rgba(0,0,0,0.95); }
.title-overlay p { margin: 1px 0 0; font-size: 11.5px; color: #b3bccb; text-shadow: 0 1px 10px rgba(0,0,0,0.95); }
@media (min-width: 64rem) {
  .title-overlay { right: auto; left: 50%; transform: translateX(-50%); width: max-content; max-width: 520px; }
}

/* ---------- toolbar ---------- */
.bar { position: fixed; z-index: 8; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 5px; padding: 6px; border-radius: 11px;
  background: var(--panel-bg); border: 1px solid var(--panel-border); max-width: calc(100vw - 28px); }
.btn { flex: 0 0 auto; min-height: 40px; min-width: 40px; padding: 0 11px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-border); background: rgba(18, 24, 38, 0.7); border-radius: 8px; font-size: 13px; color: var(--ui-text); cursor: pointer; white-space: nowrap;
  touch-action: manipulation; }
.btn:hover { border-color: rgba(255,255,255,0.24); }
.btn.go { color: #10131c; background: var(--amber); border-color: var(--amber); font-weight: 600; }
.btn.go:hover { background: #f0b862; }
.btn.flash { color: var(--amber); border-color: rgba(232,168,74,0.7); }
.btn.go.flash { color: #10131c; }

/* ---------- help ---------- */
.help { position: fixed; z-index: 20; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px));
  max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px);
  width: min(420px, calc(100vw - 28px)); display: flex; flex-direction: column; border-radius: 12px; background: rgba(8, 12, 22, 0.96);
  border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--panel-border); }
.help-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.04em; color: #f0e2c4; }
.help-body { overflow: auto; padding: 6px 14px 14px; font-size: 12.5px; line-height: 1.45; -webkit-user-select: text; user-select: text; }
.help-body h3 { margin: 12px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--amber); font-weight: 600; }
.help-body p { margin: 6px 0; color: #b3bccb; }
.help-body dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
.help-body dt { font-family: var(--mono); font-size: 12px; color: var(--ui-text); }
.help-body dd { margin: 0; color: var(--muted); }
.help-body code { font-family: var(--mono); font-size: 12px; color: var(--ui-text); }

@media (prefers-reduced-motion: reduce) { .title-overlay { transition: none; } }

/* ---------- medium widths: the toolbar is wide, so the HUD sits above it ---------- */

/* ---------- phone ---------- */
@media (max-width: 34rem) {
  a.home { top: calc(10px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px)); }
  .hud { font-size: 10.5px; line-height: 1.45; padding: 4px 7px; }
  .title-overlay { top: calc(46px + env(safe-area-inset-top, 0px)); left: 10px; right: 10px; transform: none; width: auto; max-width: none;
    padding: 5px 12px; border-radius: 9px; background: rgba(8,10,18,0.94); transition: opacity 0.5s ease; }
  .title-overlay h1 { font-size: 15px; }
  .title-overlay p { font-size: 10.5px; margin-top: 1px; }
  .bar { left: calc(10px + env(safe-area-inset-left, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    max-width: none; flex-wrap: wrap; justify-content: space-between; gap: 4px; padding: 5px; }
  .btn { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 0 2px; font-size: 12px; }
  .help { top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; left: 8px; width: auto; max-height: calc(100dvh - 80px); }
  .help-head .btn { flex: 0 0 auto; padding: 0 12px; }
}
@media (max-width: 34rem) and (prefers-reduced-motion: reduce) { .title-overlay { transition: none; } }

/* ---------- graceful failure message ---------- */
.msg { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100vw - 40px);
  font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--ui-text); text-align: center; padding: 12px 16px; border-radius: 8px;
  background: rgba(6, 10, 22, 0.9); border: 1px solid var(--panel-border); }

/* ================= Keller additions ================= */
.hud .hp-low { color: #ff8f6b; }
.hud .key { color: var(--violet); }

/* message log: above the HUD on wide screens */
.log { max-width: min(460px, 100%); font-size: 12.5px; line-height: 1.4; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; }
.log div { padding: 1px 7px; border-radius: 4px; background: rgba(6, 10, 22, 0.72); color: #b3bccb; width: max-content; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log div.old1 { opacity: 0.78; } .log div.old2 { opacity: 0.6; } .log div.old3 { opacity: 0.45; } .log div.older { opacity: 0.35; }
.log div.good { color: #e9d3a6; } .log div.bad { color: #ff9f84; } .log div.note { color: #c7b8ff; }

/* toolbar items: name and count */
.btn.item { gap: 6px; }
.btn.item .ct { font-family: var(--mono); font-size: 12px; color: var(--amber); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { border-color: var(--panel-border); }

/* direction pad on coarse pointers */
.dpad { position: fixed; z-index: 8; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 4px; padding: 5px; border-radius: 12px;
  background: rgba(8, 12, 22, 0.42); border: 1px solid var(--panel-border); }
.dpad .btn { min-width: 0; min-height: 0; width: 46px; height: 46px; padding: 0; font-size: 18px; background: rgba(18, 24, 38, 0.62); }
.dpad .btn.wait { color: var(--amber); font-size: 22px; }

/* end of a run */
.end { position: fixed; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px));
  padding: 16px 18px 14px; border-radius: 14px; text-align: center; background: rgba(8, 12, 22, 0.93);
  border: 1px solid rgba(232, 168, 74, 0.35); box-shadow: 0 10px 50px rgba(0, 0, 0, 0.65); }
.end h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: 0.04em; color: #f0e2c4; }
.end p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: #b3bccb; font-variant-numeric: tabular-nums; }
.end.won { border-color: rgba(255, 214, 140, 0.7); box-shadow: 0 0 60px rgba(232, 168, 74, 0.35); }
.end-btns { display: flex; gap: 8px; justify-content: center; }
.end-btns .btn { flex: 1 1 0; max-width: 170px; }

/* help colours for the creatures and things */
.help-body dt.c-r { color: #d6b088; } .help-body dt.c-m { color: #ddd6ff; } .help-body dt.c-s { color: #c3a0ff; }
.help-body dt.c-S { color: #9aa6e0; } .help-body dt.c-W { color: #ff9f7f; }
.help-body dt.c-i0 { color: #e0bb85; } .help-body dt.c-i1 { color: var(--amber); } .help-body dt.c-i2 { color: #d29a68; }
.help-body dt.c-i3 { color: #ece6da; } .help-body dt.c-k { color: var(--violet); }

/* medium widths: HUD and log move to the top left, under the back link */
@media (max-width: 60rem) {
  .info { top: calc(48px + env(safe-area-inset-top, 0px)); bottom: auto; gap: 4px; }
  .hud { order: -1; }
}

@media (max-width: 34rem) {
  .info { top: calc(42px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px)); max-width: calc(100vw - 20px); }
  .log { font-size: 11px; }
  .log div { padding: 1px 6px; }
  .btn.item { flex-direction: column; gap: 0; line-height: 1.1; }
  .btn.item .nm { font-size: 10.5px; }
  .btn.item .ct { font-size: 11px; }
  .dpad { right: calc(10px + env(safe-area-inset-right, 0px)); bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 3px; padding: 4px; }
  .dpad .btn { flex: none; width: 44px; height: 44px; min-height: 0; }
  .end-btns .btn { flex: 1 1 0; }
}
