/* TIDEWRACK — rain-slick muted teal + lantern amber */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: #08141a; overscroll-behavior: none; }
body {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  color: #b9c8c2;
}
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; touch-action: none; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; display: flex;
  justify-content: space-between; padding: 10px 14px; pointer-events: none;
  text-shadow: 0 1px 3px #08141a; font-size: 15px; letter-spacing: 0.04em;
}
.hud-k { color: #e0a95f; }
#hud-right { text-align: right; }
#minimap {
  position: fixed; right: 12px; bottom: 12px; width: 160px; height: 120px;
  border: 1px solid rgba(88,126,128,0.55); outline: 1px solid rgba(8,20,26,0.8);
  background: #08141a; image-rendering: pixelated; opacity: 0.92;
  box-shadow: 0 2px 12px rgba(8,20,26,0.7);
}
.hud-keys { opacity: 0.62; font-size: 12.5px; margin-top: 4px; }
#tidechart { background: rgba(8,20,26,0.45); border: 1px solid #14333e; margin-top: 4px; }
#flash {
  position: fixed; top: 18px; left: 50%; z-index: 45;
  width: min(700px, calc(100vw - 520px)); min-width: 360px;
  padding: 12px 22px 13px;
  background:
    linear-gradient(90deg, rgba(224,169,95,0.08), transparent 18%, transparent 82%, rgba(224,169,95,0.08)),
    rgba(8,20,26,0.94);
  border: 1px solid rgba(88,126,128,0.8); color: #b9c8c2;
  box-shadow: 0 8px 28px rgba(8,20,26,0.72), inset 0 1px rgba(185,200,194,0.05);
  font-size: 20px; text-align: center; line-height: 1.6;
  text-shadow: 0 1px 3px #08141a;
  opacity: 0; transform: translate(-50%, -10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
#flash::after {
  content: ''; position: absolute; top: -1px; left: 18%; right: 18%; height: 1px;
  background: #e0a95f; box-shadow: 0 0 9px rgba(224,169,95,0.42);
}
#flash[data-kind="guide"] { padding-top: 26px; border-color: rgba(224,169,95,0.58); }
#flash[data-kind="guide"]::before {
  content: 'Keeper’s duty'; position: absolute; top: 7px; left: 0; right: 0;
  color: #e0a95f; font-size: 13px; letter-spacing: 0.16em;
}
#flash.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  #flash { top: 76px; width: calc(100vw - 24px); min-width: 0; }
  #hud-pin { max-width: 80vw; }
  .cx-cols { grid-template-columns: 1fr; }
  .cx-frame { padding: 18px 16px; }
  .paper-body { padding: 26px 22px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #flash { transition: opacity 0.15s linear; transform: translate(-50%, 0); }
}

/* Title */
#title {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #14333e 0%, #08141a 70%);
  z-index: 50;
}
body.booted #title { background: radial-gradient(ellipse at 50% 30%, rgba(20,51,62,0.92) 0%, rgba(8,20,26,0.96) 70%); }
.title-card { text-align: center; padding: 40px; }
.title-card h1 {
  font-size: 64px; letter-spacing: 0.34em; color: #b9c8c2; font-weight: normal;
  text-shadow: 0 0 34px rgba(224,169,95,0.35);
}
.title-sub { color: #587e80; margin-top: 10px; font-style: italic; }
.title-blurb { margin-top: 26px; line-height: 1.8; color: #8fa39e; }
.title-btns { margin-top: 34px; display: flex; gap: 14px; justify-content: center; }
button {
  font-family: inherit; font-size: 17px; letter-spacing: 0.08em;
  background: transparent; color: #e0a95f; border: 1px solid #2f5f68;
  padding: 10px 26px; cursor: pointer; transition: all 0.25s;
}
button:hover { border-color: #e0a95f; background: rgba(224,169,95,0.08); }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.title-foot { margin-top: 44px; font-size: 12px; color: #587e80; font-style: italic; }

/* Aged paper letter */
#letter, #epilogue, #ending-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,20,26,0.62); z-index: 60;
}
.paper {
  width: min(680px, 92vw); max-height: 88vh; overflow: auto;
  background:
    linear-gradient(160deg, rgba(224,169,95,0.10), transparent 40%),
    linear-gradient(20deg, rgba(138,106,75,0.12), transparent 55%),
    linear-gradient(#cfc3a5, #c2b28e);
  color: #26332f; box-shadow: 0 18px 60px rgba(0,0,0,0.6);
  border-radius: 2px; position: relative;
}
.paper.big { width: min(760px, 92vw); }
.paper.small { width: min(520px, 92vw); }
.paper-edge { position: absolute; inset: 6px; border: 1px dashed rgba(38,51,47,0.25); pointer-events: none; }
.paper-body { padding: 38px 48px 30px; }
#lt-collection, .epi-title {
  font-size: 12.5px; letter-spacing: 0.22em; text-transform: uppercase; color: #6d5c3f;
}
.paper h2 { font-size: 26px; font-weight: normal; margin: 8px 0 4px; color: #1f2a26; }
#lt-voice { font-style: italic; color: #5b5140; font-size: 15.5px; margin-bottom: 20px; }
#lt-text { line-height: 1.85; font-size: 18.5px; white-space: pre-line; }
#lt-text p { margin-bottom: 12px; }
.paper button { display: block; margin: 22px auto 0; color: #4a4231; border-color: #8a7a5a; }
.paper button:hover { border-color: #4a4231; background: rgba(74,66,49,0.08); }
.keyhint { font-size: 11.5px; opacity: 0.7; }
.center { text-align: center; }
.epi-lines { margin: 20px 0; font-style: italic; line-height: 2; color: #1f2a26; font-size: 19px; }

/* Codex */
#codex, #endings {
  position: fixed; inset: 0; background: rgba(8,20,26,0.86); z-index: 55;  display: flex; align-items: center; justify-content: center;
}
#help {
  position: fixed; inset: 0; background: rgba(8,20,26,0.72); z-index: 57;
  display: flex; align-items: center; justify-content: center;
}
.cx-frame { width: min(860px, 94vw); max-height: 88vh; overflow: auto; padding: 26px 32px; border: 1px solid #2f5f68; background: rgba(8,20,26,0.92); }
.cx-head { display: flex; align-items: baseline; gap: 18px; border-bottom: 1px solid #14333e; padding-bottom: 12px; margin-bottom: 14px; }
.cx-head h2 { font-weight: normal; letter-spacing: 0.2em; color: #e0a95f; font-size: 23px; }
.cx-head div { flex: 1; color: #6d8f91; font-size: 14.5px; }
.cx-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 26px; }
.cx-sec h3 { font-weight: normal; letter-spacing: 0.14em; font-size: 16px; margin: 16px 0 8px; }
.cx-count { color: #6d8f91; font-size: 14px; }
.cx-row { font-size: 15.5px; padding: 6px 8px; cursor: pointer; border-left: 2px solid transparent; }
.cx-row:hover { background: rgba(47,95,104,0.18); border-left-color: #e0a95f; }
.cx-unknown { color: #3c565c; cursor: default; font-style: italic; }
.cx-unknown:hover { background: none; }
.cx-id { color: #6d8f91; font-size: 12.5px; margin-right: 6px; }
.cx-epilogue { margin-top: 22px; border-top: 1px dashed #2f5f68; padding-top: 12px; }
.cx-epilogue h3 { font-size: 12px; letter-spacing: 0.2em; color: #e0a95f; font-weight: normal; margin-bottom: 8px; }
.cx-ep-lines { font-style: italic; line-height: 1.9; font-size: 16.5px; }

/* Phonograph */
#phono { position: fixed; inset: 0; background: rgba(8,20,26,0.8); z-index: 58; display: flex; align-items: center; justify-content: center; }
.phono-box { border: 1px solid #2f5f68; background: rgba(8,20,26,0.95); padding: 30px 40px; text-align: center; max-width: 520px; }
.phono-box h3 { font-weight: normal; color: #e0a95f; letter-spacing: 0.16em; margin-bottom: 10px; }
#phono-seq { font-size: 26px; letter-spacing: 0.4em; margin: 18px 0; color: #b9c8c2; }
.phono-keys { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
#phono-msg { min-height: 48px; font-size: 16px; line-height: 1.6; color: #9db4ae; }
.dim { opacity: 0.8; font-size: 15.5px; line-height: 1.65; }
.dimbtn { font-size: 12px; padding: 6px 14px; margin-top: 10px; }
.ending-blurb { font-size: 16px; color: #9db4ae; margin: 8px 0 16px 2px; line-height: 1.65; }
.ending-btn { display: block; width: 100%; text-align: left; margin-bottom: 4px; }
#epilogue input {
  display: block; width: 100%; margin: 10px 0; padding: 8px 10px; font-family: inherit;
  font-size: 15px; color: #26332f; background: rgba(255,255,255,0.28);
  border: none; border-bottom: 1px solid #8a7a5a; outline: none;
}
#epilogue input::placeholder { color: rgba(38,51,47,0.4); font-style: italic; }

/* ===== v10: guidance layer, caseboard, prompt, accessibility ===== */
:root { --lt-scale: 1; }
#hud-inv {
  display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap;
  max-width: 420px; margin-top: 4px; pointer-events: auto;
}
#hud-inv .inv-slot {
  position: relative; width: 34px; height: 34px; border: 1px solid #2f5f68;
  background: rgba(8,20,26,0.66); display: flex; align-items: center; justify-content: center;
}
#hud-inv .inv-slot canvas { image-rendering: pixelated; }
#hud-inv .inv-slot .inv-name {
  position: absolute; bottom: -2px; left: 0; right: 0; font-size: 7px; line-height: 1;
  color: #8fa39e; text-align: center; letter-spacing: 0.04em; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; padding: 0 2px; opacity: 0.85;
}
#hud-inv .inv-slot:hover { border-color: #e0a95f; }
#hud-inv:empty::after { content: 'carrying — nothing yet'; font-size: 10px; color: #4d6662; font-style: italic; }

#hud-pin {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 0.12em; color: #e0a95f;
  background: rgba(8,20,26,0.78); border: 1px solid rgba(224,169,95,0.35);
  padding: 5px 18px; max-width: min(560px, 60vw); text-align: center;
  text-shadow: 0 1px 3px #08141a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#hud-pin::before { content: '▸ '; }
#prompt {
  position: fixed; left: 50%; bottom: 18%; z-index: 44;
  transform: translateX(-50%) translateY(6px);
  font-size: 18px; letter-spacing: 0.06em; color: #f4cf94;
  background: rgba(8,20,26,0.88); border: 1px solid rgba(224,169,95,0.55);
  padding: 9px 24px; text-shadow: 0 1px 3px #08141a;
  opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease; pointer-events: none;
}
#prompt.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { #prompt { transition: opacity 0.1s linear; } }
.title-duty { display: inline-block; margin-top: 14px; color: #e0a95f; letter-spacing: 0.06em; font-size: 14px; }
#flash[data-kind="hint"]::before { content: 'A thought, passing'; position: absolute; top: 7px; left: 0; right: 0; color: #8fa39e; font-size: 11.5px; letter-spacing: 0.16em; }
#flash[data-kind="hint"] { padding-top: 26px; border-color: rgba(143,163,158,0.5); }

/* letter: excerpt-first + optional full text */
#lt-text { font-size: calc(18.5px * var(--lt-scale)); }
#lt-question { font-size: 13.5px; letter-spacing: 0.14em; color: #5b5140; margin-top: 16px; }
#lt-more { display: inline-block; margin: 14px auto 0; font-size: 14.5px; }
.paper.hc, body.hc .paper { background: #efe8d2; color: #101613; }
body.hc #lt-text { color: #0c110f; }

/* caseboard */
#codex-questions { max-width: 520px; }
.cx-contra { font-size: 13px; color: #e0a95f; border-left: 2px solid #e0a95f; padding-left: 10px; margin: 6px 0; }
.cx-solved { font-size: 12px; color: #b9c8c2; letter-spacing: 0.08em; margin: 6px 0; }
.cx-hyp { margin: 8px 0 10px; }
.cx-hyp label { display: block; font-size: 10px; letter-spacing: 0.18em; color: #587e80; text-transform: uppercase; margin-bottom: 4px; }
.cx-hyp input {
  width: 100%; padding: 6px 8px; font-family: inherit; font-size: 13px;
  color: #b9c8c2; background: rgba(20,51,62,0.5); border: 1px solid #2f5f68; outline: none;
}
.cx-hyp input:focus { border-color: #e0a95f; }
#codex-archive h3, #codex-endings h3 { font-weight: normal; letter-spacing: 0.14em; font-size: 14px; margin: 14px 0 6px; color: #8fa39e; }

/* help + settings */
.cx-frame.narrow { width: min(520px, 94vw); }
.keys-table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.keys-table td { padding: 7px 9px; font-size: 15.5px; border-bottom: 1px solid rgba(47,95,104,0.3); vertical-align: top; }
.keys-table td:first-child { color: #e0a95f; white-space: nowrap; width: 150px; }
.set-row { display: block; font-size: 14px; padding: 7px 0; cursor: pointer; }
.set-row input, .set-row select { margin-right: 8px; accent-color: #e0a95f; }

/* ===== touch controls (phones / tablets / any coarse pointer) ===== */
#touch-controls { display: none; }
@media (pointer: coarse) {
  .hud-keys { display: none; }
  #touch-controls { display: block; }

  #joystick {
    position: fixed; z-index: 40; touch-action: none;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 118px; height: 118px; border-radius: 50%;
    background: rgba(8,20,26,0.55); border: 1px solid rgba(185,200,194,0.3);
  }
  #joystick-knob {
    position: absolute; top: 50%; left: 50%; width: 52px; height: 52px;
    margin: -26px 0 0 -26px; border-radius: 50%;
    background: rgba(224,169,95,0.3); border: 1px solid rgba(224,169,95,0.75);
    transition: none;
  }

  #touch-actions {
    position: fixed; z-index: 40;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  }
  .tbtn-row { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
  .tbtn {
    font-family: inherit; color: #e0a95f; background: rgba(8,20,26,0.6);
    border: 1px solid rgba(224,169,95,0.55); border-radius: 50%;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    display: flex; align-items: center; justify-content: center; padding: 0;
  }
  .tbtn:active { background: rgba(224,169,95,0.3); border-color: #e0a95f; }
  .tbtn-sm { width: 40px; height: 40px; font-size: 15px; }
  .tbtn-md { width: 50px; height: 50px; font-size: 17px; }
  .tbtn-lg { width: 72px; height: 72px; font-size: 22px; }

  /* the HUD still shows the contextual "E — verb" prompt; the physical
     keyboard legend is gone, replaced by the buttons themselves */
  #prompt { bottom: 158px; }

  /* the action-button stack owns the bottom-right corner now — move the
     minimap under the HUD text, top-right, so the two never overlap */
  #minimap {
    top: max(116px, env(safe-area-inset-top) + 100px); bottom: auto;
    right: max(10px, env(safe-area-inset-right));
    width: 128px; height: 96px;
  }
}

@media (pointer: coarse) and (max-width: 480px) {
  #joystick { width: 100px; height: 100px; }
  #joystick-knob { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .tbtn-sm { width: 36px; height: 36px; font-size: 14px; }
  .tbtn-md { width: 44px; height: 44px; font-size: 15px; }
  .tbtn-lg { width: 62px; height: 62px; font-size: 20px; }
  .tbtn-row { gap: 8px; }
  #touch-actions { gap: 8px; }
}
.set-row select { background: #14333e; color: #b9c8c2; border: 1px solid #2f5f68; font-family: inherit; }
.settings-row { margin-top: 14px; }
