/* WILDMIND — survival field-kit UI: worn paper notes, stamped ink, stitched canvas, scuffed gauges. */
:root {
  --ink: #2a2419; --paper: #e7dcc2; --paper2: #d6c7a2; --rust: #c2672b; --rust2: #9c4a1c; --olive: #4f5a2c;
  --blood: #b0332a; --bone: #efe6d1; --char: #13120e; --khaki: #b9aa84; --moss: #7f9a4a;
  --stencil: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Medium", "Arial Black", sans-serif;
  --mono: "Courier New", Courier, "Lucida Console", monospace;
  --hand: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.2 0 0 0 0 0.12 0 0 0 0.42 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --specks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.9 0 0 0 0 0.85 0 0 0 0 0.7 0 0 0 0.18 -0.05'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--char); color: var(--bone); font-family: var(--hand); touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
svg.defs { position: absolute; width: 0; height: 0; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- screens */
#loading, #menu, #pause, #death, #help, #waterMenu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 10; }
#loading { flex-direction: column; gap: 14px; background: radial-gradient(ellipse at 50% 40%, #2a2a1f 0%, #121109 62%, #050504 100%); }
#loading::before, #menu::before, #pause::before, #death::before, #help::before, #waterMenu::before { content: ''; position: absolute; inset: 0; background: var(--specks); opacity: 0.6; pointer-events: none; }
#menu, #pause, #help, #waterMenu { background: radial-gradient(ellipse at 50% 45%, rgba(10, 9, 6, 0.05) 30%, rgba(5, 5, 3, 0.78) 100%); }
#death { background: radial-gradient(ellipse at 50% 45%, rgba(40, 4, 2, 0.35) 20%, rgba(12, 0, 0, 0.88) 100%); }

.journal {
  position: relative; max-width: 560px; width: calc(100vw - 32px); max-height: calc(100vh - 28px); overflow: auto;
  padding: 30px 34px 26px; color: var(--ink);
  background: var(--grain), radial-gradient(ellipse at 30% 20%, #f1e8d2 0%, var(--paper) 45%, var(--paper2) 100%);
  box-shadow: 0 2px 0 #b9a77e, 0 26px 60px rgba(0, 0, 0, 0.65), inset 0 0 40px rgba(110, 80, 30, 0.28);
  transform: rotate(-0.7deg);
  clip-path: polygon(0 1.2%, 6% 0, 18% 0.9%, 31% 0, 47% 0.7%, 62% 0, 79% 1%, 93% 0.2%, 100% 1.1%, 99.4% 22%, 100% 48%, 99.3% 76%, 100% 98.6%, 88% 100%, 71% 99.1%, 52% 100%, 36% 99.2%, 19% 100%, 4% 99.3%, 0 100%, 0.6% 71%, 0 46%, 0.7% 24%);
  scrollbar-width: thin; scrollbar-color: #8a7550 transparent;
}
.journal.small { max-width: 400px; text-align: center; }
.journal.wide { max-width: 640px; }
.journal.small button.big { font-size: 18px; padding: 13px; }
.journal.dark { color: var(--bone); text-align: center; max-width: 480px;
  background: var(--specks), radial-gradient(ellipse at 50% 30%, #2b1a14 0%, #160d09 70%); box-shadow: 0 26px 60px rgba(0, 0, 0, 0.8), inset 0 0 50px rgba(0, 0, 0, 0.6); }
.tape { position: absolute; width: 92px; height: 26px; background: rgba(214, 200, 160, 0.72); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.tape.tl { left: -18px; top: 12px; transform: rotate(-38deg); }
.tape.tr { right: -18px; top: 12px; transform: rotate(36deg); }

.stamp { display: inline-block; font-family: var(--stencil); letter-spacing: 0.14em; text-transform: uppercase; filter: url(#worn); }
.title { font-size: 60px; line-height: 1; color: #2e2b22; border: 5px solid currentColor; padding: 4px 16px 2px; transform: rotate(-2.4deg); margin: 4px 0 8px; }
#loading .title { color: var(--bone); font-size: 72px; }
.title.small { font-size: 38px; border-width: 4px; }
.title.red { color: #d13d2f; font-size: 56px; white-space: nowrap; }
.tagline { font-family: var(--mono); font-size: 12px; letter-spacing: 0.32em; color: #6b5d40; margin: 6px 0 12px; }
#loading .tagline { color: var(--khaki); }
.scribble { font-family: var(--hand); font-style: italic; font-size: 17px; color: #3d3222; margin: 6px 0 16px; transform: rotate(-0.4deg); }
.journal.dark .scribble { color: #f0c8b8; font-size: 22px; }
.note { font-family: var(--mono); font-size: 13px; color: #6a4a26; margin: 8px 0; }
.journal.dark .note { color: #c9b29c; }
.tip { font-family: var(--mono); font-size: 12px; color: #6f6447; margin-top: 14px; letter-spacing: 0.04em; }
#loading .tip { color: #8d8264; max-width: 460px; text-align: center; min-height: 16px; }
#status { font-family: var(--mono); color: var(--khaki); font-size: 13px; min-height: 18px; letter-spacing: 0.03em; }
.fuse { width: min(420px, 80vw); height: 12px; border: 2px solid #5d5338; background: #1d1b13 repeating-linear-gradient(90deg, transparent 0 9px, rgba(0, 0, 0, 0.5) 9px 11px); position: relative; }
#loadBar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #7a3a12, #d9792e 80%, #ffd27a); box-shadow: 0 0 12px #e88a33; transition: width 0.25s; }

button { font: inherit; cursor: pointer; }
button.big, button.small {
  font-family: var(--stencil); text-transform: uppercase; letter-spacing: 0.12em; color: var(--bone);
  background: var(--specks), linear-gradient(180deg, #4a4a33, #343423); border: none; border-radius: 4px;
  outline: 2px dashed rgba(239, 230, 209, 0.38); outline-offset: -7px; box-shadow: 0 3px 0 #1c1c12, 0 6px 14px rgba(0, 0, 0, 0.35);
}
button.big { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; font-size: 21px; padding: 15px; margin: 10px 0; }
button.small { padding: 10px 14px; font-size: 14px; }
button.primary { background: var(--specks), linear-gradient(180deg, #d0732f, #9c4a1c); box-shadow: 0 3px 0 #5e2a0c, 0 6px 14px rgba(0, 0, 0, 0.35); }
button.big:hover, button.small:hover { filter: brightness(1.12); }
button.big:active { transform: translateY(2px); box-shadow: 0 1px 0 #1c1c12; }
.key { font-family: var(--mono); font-size: 13px; letter-spacing: 0; background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 255, 255, 0.25); padding: 2px 7px; border-radius: 3px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 16px 0 6px; }
.row label { display: flex; flex-direction: column; gap: 4px; }
.lbl { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: #6b5a3a; }
select, input { font-family: var(--mono); font-size: 14px; color: var(--ink); background: rgba(255, 252, 240, 0.55); border: none; border-bottom: 2px solid #7d6a45; padding: 7px 6px; width: 160px; border-radius: 0; }
details { margin-top: 14px; font-size: 14px; line-height: 1.5; color: #3b3122; border-top: 1px dashed #9c8a62; padding-top: 10px; }
summary { cursor: pointer; font-family: var(--stencil); letter-spacing: 0.08em; text-transform: uppercase; color: #4b3d26; margin-bottom: 6px; }
details p { margin: 7px 0; }
.keys { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0 10px; }
.keys td { padding: 6px 4px; border-bottom: 1px dashed #b3a27c; vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 12px; }
kbd { font-family: var(--mono); font-size: 12px; background: #3a3626; color: var(--bone); padding: 2px 6px; border-radius: 3px; box-shadow: 0 2px 0 #1b1a12; margin-right: 3px; }
#deathCause { margin: 16px 0 6px; }

/* water settings */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 10px 0 6px; }
.opt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.opt select, .opt input[type=range] { width: 100%; }
.opt .lbl b { font-family: var(--mono); font-weight: normal; letter-spacing: 0.04em; color: #8a3d12; margin-left: 4px; }
.opt.chk { flex-direction: row; align-items: center; gap: 9px; font-size: 15px; color: #3b3122; cursor: pointer; }
.opt.chk i { font-size: 12.5px; color: #6f6447; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 12px 0 4px; padding-top: 10px; border-top: 1px dashed #9c8a62; }
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; flex: none; margin: 0; border: 2px solid #5d4c2e; background: rgba(255, 252, 240, 0.5); position: relative; cursor: pointer; padding: 0; }
input[type=checkbox]:checked::after { content: ''; position: absolute; left: 5px; top: 0; width: 6px; height: 12px; border: solid #9c3f14; border-width: 0 3px 3px 0; transform: rotate(40deg); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 26px; background: transparent; border: none; padding: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; background: repeating-linear-gradient(90deg, #7d6a45 0 2px, rgba(125, 106, 69, 0.35) 2px 10%); border-radius: 3px; }
input[type=range]::-moz-range-track { height: 6px; background: repeating-linear-gradient(90deg, #7d6a45 0 2px, rgba(125, 106, 69, 0.35) 2px 10%); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 22px; margin-top: -8px; background: linear-gradient(180deg, #d0732f, #9c4a1c); border: 2px solid #4b2a10; border-radius: 3px; }
input[type=range]::-moz-range-thumb { width: 14px; height: 18px; background: linear-gradient(180deg, #d0732f, #9c4a1c); border: 2px solid #4b2a10; border-radius: 3px; }
.row.end { justify-content: flex-end; align-items: center; }
.row.end button.big { width: auto; flex: 1; margin: 0; }
#wNote { min-height: 18px; }
.journal { touch-action: pan-y; -webkit-overflow-scrolling: touch; }
select:disabled, input[type=range]:disabled { opacity: 0.4; cursor: default; filter: grayscale(0.6); }
@media (max-width: 560px) { .opts, .checks { grid-template-columns: 1fr; } .journal { padding: 24px 20px 20px; } .title { font-size: 46px; padding: 4px 12px 2px; } .title.small { font-size: 34px; } .title.red { font-size: 44px; } }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--mono); color: var(--bone); text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.6); }
.ico { width: 20px; height: 20px; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8)); }

#compass { position: absolute; left: 50%; top: 12px; width: 380px; height: 34px; transform: translateX(-50%); overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 19, 13, 0.62), rgba(20, 19, 13, 0.25)); border-top: 1px solid rgba(239, 230, 209, 0.25);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
#compassTape { position: absolute; left: 0; top: 0; height: 100%; will-change: transform; }
#compassTape span { position: absolute; top: 3px; transform: translateX(-50%); font-size: 11px; color: #cfc5a8; }
#compassTape span.c { font-family: var(--stencil); font-size: 17px; top: 1px; color: var(--bone); letter-spacing: 0.05em; }
#compassTape span.c.n { color: #e8754a; }
#compassTape i { position: absolute; bottom: 0; width: 1px; height: 7px; background: rgba(239, 230, 209, 0.55); }
#compassTape i.m { height: 12px; background: rgba(239, 230, 209, 0.85); }
#compass .needle { position: absolute; left: 50%; bottom: 0; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 8px solid #e8754a; }
#bearing { position: absolute; left: 50%; top: 38px; transform: translateX(-50%); font-size: 11px; color: var(--khaki); }

#info { position: absolute; left: 16px; top: 14px; font-size: 13px; line-height: 1.7; }
#info .line { display: flex; align-items: center; gap: 8px; }
#info .line .ico { width: 18px; height: 18px; color: var(--khaki); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; max-width: 280px; }
.tag { font-family: var(--stencil); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; padding: 1px 7px; border: 2px solid currentColor; transform: rotate(-2deg); text-shadow: none; background: rgba(15, 14, 10, 0.55); }
.tag.bad { color: #e0573f; } .tag.warn { color: #e2a43c; } .tag.cold { color: #8cc4e8; } .tag.good { color: #a6c96a; }

#vitals { position: absolute; left: 16px; bottom: 16px; width: 270px; display: flex; flex-direction: column; gap: 7px; }
.vital { display: flex; align-items: center; gap: 9px; }
.vital .ico { width: 22px; height: 22px; }
.gauge { position: relative; flex: 1; height: 12px; background: rgba(12, 11, 8, 0.7); border: 1px solid rgba(239, 230, 209, 0.28); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8); }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.35s; box-shadow: 0 0 8px currentColor; background: currentColor; }
.gauge .fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 55%, rgba(0, 0, 0, 0.25)), var(--specks); }
.gauge::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(10, 9, 6, 0.9) calc(10% - 2px) 10%); }
.vital .val { width: 30px; text-align: right; font-size: 12px; color: #d9cfb3; }
.vital.low .ico { animation: pulse 0.9s infinite; }
.vital.low .val { color: #ff7a5c; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.88); } }

#inv { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.slot { position: relative; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--specks), rgba(18, 17, 12, 0.7); border: 1px solid rgba(239, 230, 209, 0.3); box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.7); }
.slot .ico { width: 28px; height: 28px; }
.slot.big { width: auto; min-width: 210px; height: 58px; justify-content: flex-start; gap: 10px; padding: 0 12px; }
.slot.big .ico { width: 36px; height: 36px; }
.slot.big .nm { font-family: var(--stencil); letter-spacing: 0.08em; text-transform: uppercase; font-size: 15px; }
.slot.big .wt { font-size: 11px; color: var(--khaki); }
.slot.sel { border-color: #e8a33c; box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(232, 163, 60, 0.6); }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: var(--bone); }
#bagSlots { display: flex; gap: 5px; }
#load { font-size: 11px; color: var(--khaki); display: flex; align-items: center; gap: 6px; }
#load .ico { width: 15px; height: 15px; }
#load.heavy { color: #e2a43c; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 1.5px solid rgba(239, 230, 209, 0.55); border-radius: 50%; box-shadow: 0 0 2px rgba(0, 0, 0, 0.6); }
#crosshair i { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%; background: var(--bone); }
#hint { position: absolute; left: 50%; top: calc(50% + 20px); transform: translateX(-50%); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bone); }
#hint:not(:empty) { background: rgba(15, 14, 10, 0.55); border: 1px solid rgba(239, 230, 209, 0.25); padding: 2px 8px; }
#toasts { position: absolute; left: 50%; top: 76px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast { font-family: var(--hand); font-style: italic; font-size: 17px; color: var(--ink); text-shadow: none; padding: 7px 18px 6px;
  background: var(--grain), linear-gradient(180deg, #efe5cd, var(--paper2)); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45); transform: rotate(-1.2deg); transition: opacity 0.7s, transform 0.7s; }
.toast:nth-child(even) { transform: rotate(1deg); }
.toast.fade { opacity: 0; transform: translateY(-8px) rotate(-1deg); }
#fps { position: absolute; right: 12px; top: 10px; font-size: 12px; color: #b9d8a0; }

/* ---------------------------------------------------------------- touch */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#stick { position: absolute; left: 22px; bottom: 26px; width: 140px; height: 140px; border-radius: 50%; pointer-events: auto;
  background: radial-gradient(circle, rgba(20, 19, 13, 0.15) 40%, rgba(20, 19, 13, 0.5) 41%, rgba(20, 19, 13, 0.4) 68%, transparent 69%), repeating-conic-gradient(rgba(239, 230, 209, 0.35) 0 1deg, transparent 1deg 30deg);
  border: 2px dashed rgba(239, 230, 209, 0.35); }
#stick .rose { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font-family: var(--stencil); font-size: 13px; color: #e8754a; }
#knob { position: absolute; left: 45px; top: 45px; width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #6a634a, #2e2b1f); border: 2px solid rgba(239, 230, 209, 0.45); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); }
#tbtns { position: absolute; right: 12px; bottom: 18px; display: grid; grid-template-columns: repeat(3, 66px); gap: 7px; pointer-events: auto; }
#tbtns button { height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-family: var(--stencil); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bone);
  background: var(--specks), rgba(40, 38, 26, 0.72); border: none; outline: 1.5px dashed rgba(239, 230, 209, 0.35); outline-offset: -5px; border-radius: 6px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45); }
#tbtns button b { font-size: 18px; font-weight: normal; line-height: 1; }
#tbtns button:active { background: rgba(194, 103, 43, 0.75); }

@media (pointer: coarse) {
  #vitals { bottom: auto; top: 118px; width: 190px; gap: 5px; }
  #info { top: 44px !important; }
  #bearing { display: none; }
  .vital .ico { width: 18px; height: 18px; }
  .gauge { height: 9px; }
  #info { font-size: 11px; top: 12px; }
  #compass { width: 230px; top: 8px; height: 28px; }
  #inv { bottom: auto; top: 44px; }
  .slot.big { min-width: 150px; height: 46px; }
  .slot.big .ico { width: 28px; height: 28px; }
  .slot { width: 36px; height: 36px; }
  .slot .ico { width: 22px; height: 22px; }
  #toasts { top: 58px; }
  .toast { font-size: 14px; }
}
