/* ==========================================================================
   WILDERNEX — design system & interface
   Palette: pine black, bone, moss, ember. Type: Barlow Condensed + Inter.
   ========================================================================== */

@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/BarlowCondensed-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/BarlowCondensed-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/BarlowCondensed-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/Inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/Inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/Inter-600.woff2') format('woff2');
}

:root {
  --bg: #070b09;
  --bg-2: #0b1210;
  --panel: rgba(11, 17, 14, 0.93);
  --panel-2: rgba(18, 26, 21, 0.96);
  --panel-soft: rgba(22, 31, 25, 0.72);
  --line: rgba(214, 190, 148, 0.18);
  --line-strong: rgba(214, 190, 148, 0.4);
  --ink: #ece6d6;
  --ink-soft: #cfc9b9;
  --muted: #909c8e;
  --gold: #d8b678;
  --gold-strong: #f0d7a3;
  --gold-dim: #9e8459;
  --moss: #8fa98a;
  --green: #7e9a6a;
  --red: #d0654d;
  --red-dark: #7e2f25;
  --blue: #83b2c6;
  --orange: #dfa05c;
  --radius: 3px;
  --radius-lg: 6px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--gold); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; outline: none; }

#ui { position: absolute; inset: 0; pointer-events: none; z-index: 2; }

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  z-index: 20;
}

/* ============================ shared type bits ============================ */

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.eyebrow.danger { color: var(--red); }

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink);
}

.subhead {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink-soft);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 4px 9px;
  border-radius: 999px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ================================ buttons ================================ */

.btn {
  --btn-bg: rgba(255, 255, 255, 0.03);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)), var(--btn-bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, color 160ms ease;
}
.btn:hover, .btn:focus-visible {
  border-color: var(--gold);
  background: rgba(216, 182, 120, 0.12);
  color: var(--gold-strong);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #e7cd97, #c9a86c);
  border-color: #e7cd97;
  color: #15160f;
}
.btn.primary:hover, .btn.primary:focus-visible {
  background: linear-gradient(180deg, #f4dfb2, #d7b97f);
  color: #0c0d08;
}
.btn.ghost { background: transparent; }
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}
.btn small {
  font-family: var(--font-body);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: none;
  opacity: 0.7;
}

.icon-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 12, 9, 0.55);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  transition: border-color 140ms, color 140ms, background 140ms;
}
.icon-btn:hover, .icon-btn:focus-visible {
  border-color: var(--gold);
  color: var(--gold-strong);
  background: rgba(216, 182, 120, 0.1);
}
.icon-btn.active { color: var(--gold); border-color: var(--gold); }

:focus-visible { outline: 2px solid var(--gold-strong); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* ================================= title ================================= */

.title-screen {
  background:
    radial-gradient(120% 90% at 78% 18%, rgba(190, 150, 96, 0.12), transparent 55%),
    linear-gradient(90deg, rgba(4, 7, 5, 0.96) 0%, rgba(4, 7, 5, 0.82) 38%, rgba(4, 7, 5, 0.18) 72%, rgba(4, 7, 5, 0.5) 100%),
    linear-gradient(0deg, rgba(4, 7, 5, 0.9), transparent 35%, transparent 70%, rgba(4, 7, 5, 0.65));
  align-items: center;
  animation: screen-in 700ms ease both;
}
.title-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(75% 75% at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.title-content {
  position: relative;
  z-index: 2;
  padding: clamp(24px, 6vh, 64px) clamp(22px, 6vw, 96px);
  max-width: 760px;
  width: 100%;
}
.title-content .eyebrow { margin-bottom: 14px; }
h1#game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(4.4rem, 13.5vw, 11.5rem);
  line-height: 0.82;
  letter-spacing: 0.035em;
  color: #f1ecdf;
  text-shadow: 0 10px 60px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 245, 220, 0.8);
  margin-left: -0.06em;
  position: relative;
}
h1#game-title::after {
  content: '';
  position: absolute;
  left: 0.08em;
  bottom: -0.1em;
  width: min(58%, 460px);
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(216, 182, 120, 0));
}
.tagline {
  margin-top: 24px;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold-strong);
}
.title-menu {
  margin-top: clamp(28px, 5vh, 48px);
  display: flex;
  flex-direction: column;
  width: min(100%, 380px);
  border-top: 1px solid var(--line);
}
.menu-btn {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'label num' 'meta num';
  align-items: center;
  gap: 2px 14px;
  padding: 15px 6px 15px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
  transition: color 160ms, padding 200ms, background 160ms;
}
.menu-btn .menu-label {
  grid-area: label;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.menu-btn .menu-num {
  grid-area: num;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
}
.menu-btn small {
  grid-area: meta;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}
.menu-btn::before {
  content: '';
  position: absolute;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--gold);
}
.menu-btn:hover:not(:disabled),
.menu-btn:focus-visible {
  color: var(--gold-strong);
  padding-left: 14px;
  background: linear-gradient(90deg, rgba(216, 182, 120, 0.1), transparent 80%);
}
.menu-btn:hover .menu-num { color: var(--gold); }
.menu-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-btn:disabled:hover { padding-left: 2px; background: transparent; color: var(--ink-soft); }
.title-foot {
  margin-top: clamp(30px, 6vh, 64px);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 0.64rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #707b6c;
  max-width: 560px;
}
.title-version { color: var(--gold-dim); }
.title-aside {
  position: absolute;
  right: clamp(20px, 5vw, 64px);
  bottom: clamp(24px, 6vh, 60px);
  z-index: 2;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  max-width: 390px;
}
.title-aside .rule { width: 60px; height: 1px; background: var(--gold); margin-bottom: 8px; flex: none; }
.title-aside p {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  line-height: 1.8;
  text-transform: uppercase;
  color: #8d988a;
  text-align: right;
}

/* =============================== loading ================================ */

.loading-screen {
  background:
    radial-gradient(60% 60% at 50% 50%, rgba(22, 33, 26, 0.9), rgba(4, 7, 5, 0.98));
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.loading-inner {
  width: min(440px, 84vw);
  text-align: center;
  padding: 32px;
}
.loading-inner h2 {
  margin: 14px 0 26px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.loading-track {
  height: 2px;
  width: 100%;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
#loading-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-strong));
  transition: width 220ms ease;
}
.loading-status {
  margin-top: 14px;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.loading-tip {
  margin-top: 36px;
  font-size: 0.78rem;
  color: #8d988a;
  line-height: 1.6;
  font-style: italic;
  min-height: 2.6em;
}

/* ================================== HUD ================================= */

#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: none; }
#hud .icon-btn, #hud .hotbar .slot, #hud .prompt { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 clamp(14px, 2.2vw, 30px);
  gap: 16px;
}
.clock-block {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(7, 12, 9, 0.7), rgba(7, 12, 9, 0.38));
  backdrop-filter: blur(8px);
}
.clock-text { display: flex; flex-direction: column; line-height: 1.1; }
.clock-text span {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.clock-text strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.weather-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.weather-chip .ico { width: 16px; height: 16px; color: var(--gold); }

#compass {
  position: absolute;
  left: 50%;
  top: calc(16px + var(--safe-top));
  transform: translateX(-50%);
  width: min(300px, 34vw);
  height: 28px;
  overflow: hidden;
  opacity: 0.72;
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}
.compass-strip {
  position: absolute;
  top: 2px;
  left: 50%;
  display: flex;
  gap: 0;
  will-change: transform;
}
.compass-strip span {
  width: 48px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}
.compass-mark {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 6px;
  background: var(--gold);
  transform: translateX(-50%);
}
.hud-actions { display: flex; gap: 7px; }

.hud-left {
  position: absolute;
  left: clamp(14px, 2.2vw, 30px);
  bottom: calc(112px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.vitals {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 14px;
  min-width: 230px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(9, 14, 11, 0.76), rgba(9, 14, 11, 0.36));
  backdrop-filter: blur(9px);
}
.vital {
  display: grid;
  grid-template-columns: 16px 1fr 34px;
  align-items: center;
  gap: 9px;
}
.vital .ico { width: 15px; height: 15px; color: #b8b3a2; }
.vital[data-vital='health'] .ico { color: #cf7660; }
.vital[data-vital='hunger'] .ico { color: #c99a63; }
.vital[data-vital='thirst'] .ico { color: #74a9bd; }
.vital[data-vital='stamina'] .ico { color: #c8c17a; }
.vital[data-vital='temp'] .ico { color: #9fb8a3; }
.vital-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}
.vital-fill {
  height: 100%;
  width: 100%;
  background: var(--green);
  transition: width 220ms linear, background-color 300ms;
}
.vital[data-vital='health'] .vital-fill { background: linear-gradient(90deg, #8e3f34, #d0654d); }
.vital[data-vital='hunger'] .vital-fill { background: linear-gradient(90deg, #8e6535, #d2a05c); }
.vital[data-vital='thirst'] .vital-fill { background: linear-gradient(90deg, #3c6b80, #83b2c6); }
.vital[data-vital='stamina'] .vital-fill { background: linear-gradient(90deg, #7b7a3c, #c8c17a); }
.vital[data-vital='temp'] .vital-fill { background: linear-gradient(90deg, #3f6570, #9fb8a3); }
.vital-fill.low { animation: pulse-danger 1.15s ease-in-out infinite; }
.vital-val {
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-align: right;
}
.status-effects { display: flex; flex-wrap: wrap; gap: 6px; max-width: 260px; }
.effect {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border: 1px solid rgba(216, 101, 77, 0.35);
  background: rgba(80, 30, 22, 0.45);
  color: #e5a898;
  border-radius: 999px;
}
.effect.cold { border-color: rgba(131, 178, 198, 0.4); background: rgba(28, 53, 63, 0.5); color: #b8d9e4; }
.effect.sick { border-color: rgba(150, 170, 90, 0.4); background: rgba(52, 60, 24, 0.5); color: #cfd9a0; }
.effect.warm { border-color: rgba(216, 182, 120, 0.4); background: rgba(72, 57, 28, 0.5); color: var(--gold-strong); }

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: min(560px, 94vw);
}
.equip-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  font-family: var(--font-display);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.equip-indicator .durability {
  width: 56px;
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.equip-indicator .durability i { display: block; height: 100%; background: var(--gold); }
.hotbar { display: flex; gap: 6px; }
.slot {
  position: relative;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(14, 21, 17, 0.9), rgba(8, 12, 10, 0.76));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms, transform 120ms, background 120ms;
  backdrop-filter: blur(7px);
}
.slot:hover { border-color: var(--line-strong); }
.slot.selected {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(64, 53, 31, 0.7), rgba(17, 22, 16, 0.85));
  box-shadow: inset 0 0 0 1px rgba(216, 182, 120, 0.25);
}
.slot.selected::after {
  content: '';
  position: absolute;
  inset: auto 6px -1px;
  height: 2px;
  background: var(--gold);
}
.slot-num {
  position: absolute;
  left: 4px;
  top: 2px;
  font-family: var(--font-display);
  font-size: 0.56rem;
  color: #7e8a7b;
  letter-spacing: 0.06em;
}
.slot-icon {
  font-size: 1.72rem;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}
.slot-icon.emoji-grey { filter: grayscale(0.35) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55)); }
.slot-qty {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--ink);
  text-shadow: 0 1px 3px #000;
  font-variant-numeric: tabular-nums;
}
.slot-dura {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 2px;
  background: rgba(0, 0, 0, 0.45);
}
.slot-dura i { display: block; height: 100%; background: var(--gold); }
.slot.empty .slot-icon { opacity: 0.12; }
.hud-stats {
  min-height: 14px;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: #7d897a;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px #000;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
  transition: opacity 160ms;
}
.crosshair i {
  position: absolute;
  background: rgba(242, 235, 218, 0.82);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}
.crosshair i:nth-child(1) { width: 1px; height: 6px; left: 50%; top: 0; }
.crosshair i:nth-child(2) { width: 1px; height: 6px; left: 50%; bottom: 0; }
.crosshair i:nth-child(3) { width: 6px; height: 1px; top: 50%; left: 0; }
.crosshair i:nth-child(4) { width: 6px; height: 1px; top: 50%; right: 0; }
.crosshair b {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  background: rgba(242, 235, 218, 0.9);
}
.crosshair.active i { background: var(--gold-strong); }
.crosshair.hit b { background: #e8806a; transform: scale(2.4); transition: transform 90ms; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: calc(128px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 9px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  background: rgba(7, 11, 8, 0.7);
  backdrop-filter: blur(8px);
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  animation: prompt-in 140ms ease;
}
.prompt kbd { border-color: var(--gold-dim); color: var(--gold-strong); }
.prompt .sub { color: var(--muted); font-family: var(--font-body); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: none; }

.notifications {
  position: absolute;
  top: calc(74px + var(--safe-top));
  right: clamp(14px, 2.2vw, 30px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(330px, 60vw);
}
.toast {
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 7px 12px;
  border-right: 2px solid var(--gold);
  background: linear-gradient(90deg, rgba(9, 14, 10, 0.15), rgba(9, 14, 10, 0.82));
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-soft);
  animation: toast-in 220ms ease both;
}
.toast strong { color: var(--ink); font-weight: 600; }
.toast.warn { border-color: var(--red); color: #e8b3a5; }
.toast.good { border-color: var(--moss); }
.toast.discovery { border-color: var(--gold-strong); background: rgba(22, 17, 8, 0.88); }
.toast.discovery strong { color: var(--gold-strong); font-family: var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.86rem; }
.toast.out { animation: toast-out 300ms ease both; }

#hud > .build-actions {
  pointer-events: auto;
}
.build-actions {
  position: absolute;
  left: 50%;
  bottom: calc(190px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  padding: 7px;
  background: rgba(7, 11, 8, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.build-actions .btn { min-height: 40px; font-size: 0.78rem; padding: 0 16px; }
body.touch-mode .build-actions { bottom: calc(248px + var(--safe-bottom)); }
@media (max-width: 680px) {
  .build-actions { bottom: calc(210px + var(--safe-bottom)); }
  .build-actions .btn { min-height: 44px; padding: 0 12px; font-size: 0.7rem; }
}

.toast-progress {
  position: absolute;
  left: 50%;
  bottom: calc(180px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(300px, 70vw);
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: rgba(7, 11, 8, 0.84);
  text-align: center;
}
.toast-progress span {
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.track { height: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.track > div { height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold-strong)); width: 0%; }

#damage-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 110% at 50% 50%, transparent 35%, rgba(150, 36, 22, 0.55));
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}
#damage-flash.show { opacity: 1; transition: opacity 60ms ease; }
.weather-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(95% 90% at 50% 45%, transparent 55%, rgba(16, 26, 26, 0.55) 100%);
  transition: opacity 1.2s ease;
}
#click-hint {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-strong);
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 16px;
  border: 1px solid var(--line);
  pointer-events: none;
  animation: pulse-soft 2.4s ease-in-out infinite;
}

/* ================================ panels ================================ */

.panel-screen {
  background: radial-gradient(80% 80% at 50% 40%, rgba(9, 15, 11, 0.72), rgba(3, 5, 4, 0.94));
  backdrop-filter: blur(7px);
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vh, 36px) clamp(10px, 3vw, 28px);
  animation: screen-in 220ms ease both;
}
.panel {
  width: min(660px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(165deg, rgba(16, 24, 19, 0.97), rgba(8, 13, 10, 0.98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  padding: clamp(18px, 3vw, 30px);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.panel.wide { width: min(1040px, 100%); }
.panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), rgba(216, 182, 120, 0));
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin-top: 4px; }
.panel-head-actions { display: flex; align-items: center; gap: 9px; }
.panel-copy {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
  max-width: 66ch;
}
.panel-copy strong { color: var(--ink-soft); font-weight: 500; }

/* inventory */
.inv-layout {
  display: grid;
  grid-template-columns: 1fr 256px;
  gap: 22px;
  margin-top: 20px;
}
.inv-main { min-width: 0; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.inv-slot {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid rgba(214, 190, 148, 0.13);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.028), rgba(0, 0, 0, 0.18));
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: border-color 120ms, background 120ms;
  padding: 0;
  color: var(--ink);
}
.inv-slot:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.045); }
.inv-slot.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(216, 182, 120, 0.3); }
.inv-slot .slot-icon { font-size: 1.65rem; }
.inv-slot.empty { cursor: default; }
.inv-slot.hot::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 0;
  height: 0;
  border-top: 5px solid var(--gold-dim);
  border-right: 5px solid transparent;
}
.inv-slot .slot-flag {
  position: absolute;
  left: 3px;
  top: 2px;
  font-family: var(--font-display);
  font-size: 0.5rem;
  color: var(--gold-dim);
  letter-spacing: 0.04em;
}
.inv-hint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.62rem;
  color: #7f8a7b;
  line-height: 1.5;
}
.inv-side { border-left: 1px solid var(--line); padding-left: 20px; min-width: 0; }
.inv-side .subhead { margin-bottom: 9px; }
.equip-slots { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.equip-slot {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  text-align: left;
  color: var(--ink-soft);
}
.equip-slot .eq-label { font-size: 0.57rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
.equip-slot .eq-item { font-size: 0.72rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.equip-slot .eq-icon { font-size: 1.1rem; }
.equip-slot:hover { border-color: var(--line-strong); }
.inv-detail {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  min-height: 180px;
}
.inv-detail h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.inv-detail .detail-cat {
  font-size: 0.56rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.inv-detail .detail-desc { margin-top: 9px; color: var(--muted); font-size: 0.71rem; line-height: 1.65; }
.inv-detail .detail-stats { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.inv-detail .detail-stat { display: flex; justify-content: space-between; font-size: 0.64rem; color: var(--ink-soft); }
.inv-detail .detail-stat span:first-child { color: var(--muted); }
.detail-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.detail-actions .btn { min-height: 38px; font-size: 0.8rem; padding: 0 12px; }
.empty-note { color: #78836f; font-size: 0.72rem; line-height: 1.6; }
.storage-wrap { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.storage-wrap .subhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.storage-grid { grid-template-columns: repeat(8, 1fr); max-width: 560px; }
.storage-wrap .inv-hint { max-width: 560px; }

/* crafting */
.craft-layout { display: grid; grid-template-columns: 170px 1fr; gap: 22px; margin-top: 20px; }
.craft-cats { display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line); padding-right: 16px; }
.craft-cat {
  text-align: left;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.94rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 140ms, background 140ms, border-color 140ms;
}
.craft-cat .count { float: right; font-family: var(--font-body); font-size: 0.58rem; color: var(--gold-dim); letter-spacing: 0; }
.craft-cat:hover { color: var(--ink); background: rgba(255, 255, 255, 0.03); }
.craft-cat.active { color: var(--gold-strong); border-left-color: var(--gold); background: rgba(216, 182, 120, 0.075); }
.craft-main { min-width: 0; }
.craft-active {
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid rgba(216, 182, 120, 0.35);
  background: rgba(52, 42, 22, 0.35);
}
.craft-active-label { display: flex; justify-content: space-between; margin-bottom: 7px; font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-strong); }
.craft-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.12));
  transition: border-color 150ms, background 150ms;
}
.recipe-card:hover { border-color: rgba(216, 182, 120, 0.33); background: rgba(255, 255, 255, 0.04); }
.recipe-card.cannot { opacity: 0.72; }
.recipe-top { display: flex; gap: 10px; align-items: center; }
.recipe-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  font-size: 1.45rem;
}
.recipe-name { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; letter-spacing: 0.04em; line-height: 1.1; }
.recipe-meta { font-size: 0.58rem; letter-spacing: 0.08em; color: var(--gold-dim); text-transform: uppercase; margin-top: 3px; }
.recipe-desc { font-size: 0.66rem; line-height: 1.5; color: var(--muted); min-height: 2.9em; }
.recipe-mats { display: flex; flex-wrap: wrap; gap: 4px; }
.mat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.6rem;
  color: var(--ink-soft);
}
.mat.missing { color: #d99482; border-color: rgba(208, 101, 77, 0.4); }
.mat .mat-ico { font-size: 0.68rem; }
.recipe-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.recipe-actions .btn { min-height: 34px; font-size: 0.72rem; padding: 0 12px; flex: 1; }
.recipe-owned { font-size: 0.6rem; color: var(--moss); }
.craft-empty { grid-column: 1 / -1; color: var(--muted); font-size: 0.78rem; padding: 20px 0; }

/* build */
.build-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.build-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.build-card .recipe-icon { width: 48px; height: 48px; font-size: 1.6rem; }
.build-card .build-info { min-width: 0; flex: 1; }
.build-card .recipe-name { font-size: 1.15rem; }
.build-card .build-note { font-size: 0.63rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.build-card .btn { min-height: 36px; font-size: 0.72rem; padding: 0 12px; }
.build-empty { color: var(--muted); font-size: 0.78rem; padding: 16px 0; grid-column: 1 / -1; }
.build-tip {
  margin-top: 14px;
  padding: 10px 13px;
  border-left: 2px solid var(--gold-dim);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.6;
}

/* =============================== pause/death ============================ */

.pause-screen {
  background: linear-gradient(90deg, rgba(4, 7, 5, 0.94) 0%, rgba(4, 7, 5, 0.78) 55%, rgba(4, 7, 5, 0.55));
  backdrop-filter: blur(5px);
  align-items: center;
  padding: clamp(20px, 6vw, 90px);
  animation: screen-in 200ms ease both;
}
.pause-box { width: min(440px, 100%); }
.pause-box h2 { font-size: clamp(2.4rem, 5vw, 3.6rem); margin: 8px 0 18px; }
.pause-recap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 0.66rem;
  color: var(--muted);
}
.pause-recap span {
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}
.pause-menu { display: flex; flex-direction: column; gap: 7px; max-width: 330px; }
.pause-menu .btn { justify-content: space-between; padding-left: 18px; }
.pause-foot { margin-top: 22px; font-size: 0.62rem; color: #78836f; letter-spacing: 0.04em; }

.death-screen {
  background:
    radial-gradient(80% 90% at 50% 50%, rgba(40, 10, 7, 0.55), rgba(3, 4, 3, 0.97) 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 4px);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  animation: screen-in 700ms ease both;
}
.death-box { width: min(620px, 100%); }
.death-box h2 { font-size: clamp(3rem, 7vw, 5.5rem); margin: 10px 0 12px; color: #e8ddd0; }
.death-cause { font-size: 0.82rem; color: var(--red); letter-spacing: 0.1em; text-transform: uppercase; }
.death-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin: 26px 0;
}
.death-stat { min-width: 100px; }
.death-stat strong { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 500; color: var(--ink); }
.death-stat span { font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.death-quote { font-size: 0.8rem; font-style: italic; color: #9aa394; line-height: 1.7; max-width: 46ch; margin: 0 auto 26px; }
.death-actions { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }
.death-actions .btn { min-width: 190px; }

.victory-screen {
  background:
    radial-gradient(80% 90% at 50% 45%, rgba(70, 55, 22, 0.42), rgba(3, 5, 3, 0.96) 72%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px);
}
.victory-screen .death-box {
  background: rgba(5, 8, 5, 0.58);
  border: 1px solid rgba(216, 182, 120, 0.25);
  padding: clamp(22px, 4vw, 42px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}
.victory-screen .eyebrow { color: var(--gold-strong); }
.victory-screen .death-stat strong { color: var(--gold-strong); }
.victory-screen .death-stat span { color: #b9c0af; }
.victory-cause { color: var(--gold); letter-spacing: 0.08em; text-transform: none; font-size: 0.9rem; }
.victory-screen .death-quote { color: var(--gold-strong); opacity: 0.85; }

/* ================================ dialogs =============================== */

.dialog {
  border: 1px solid var(--line-strong);
  background: transparent;
  padding: 0;
  color: var(--ink);
  width: min(620px, calc(100vw - 24px));
  max-height: min(88vh, 760px);
  overflow: visible;
}
.dialog::backdrop { background: rgba(2, 4, 3, 0.78); backdrop-filter: blur(5px); }
.dialog-inner {
  background: linear-gradient(165deg, rgba(17, 25, 20, 0.99), rgba(8, 12, 10, 1));
  border-top: 2px solid var(--gold);
  padding: clamp(18px, 3.2vw, 30px);
  max-height: min(88vh, 760px);
  overflow: auto;
  position: relative;
}
.dialog .panel-head { padding-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.field > span { display: flex; justify-content: space-between; gap: 10px; }
.field output { color: var(--gold); letter-spacing: 0.02em; }
.field select {
  height: 40px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line-strong);
  padding: 0 10px;
  font-size: 0.8rem;
  color: var(--ink);
  border-radius: 2px;
}
.field input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 24px;
  background: transparent;
  accent-color: var(--gold);
}
.field input[type='range']::-webkit-slider-runnable-track { height: 3px; background: rgba(255, 255, 255, 0.14); }
.field input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #15160f;
}
.field input[type='range']::-moz-range-track { height: 3px; background: rgba(255, 255, 255, 0.14); }
.field input[type='range']::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid #15160f; }
.field.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding-top: 20px;
}
.field.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.dialog-note { margin-top: 18px; font-size: 0.68rem; line-height: 1.65; color: #7e897b; }
.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.dialog-actions .btn { min-height: 40px; font-size: 0.76rem; }
#btn-clear-save { border-color: rgba(208, 101, 77, 0.4); color: #d99482; }
#btn-clear-save:hover { border-color: var(--red); background: rgba(208, 101, 77, 0.12); color: #eeb7a8; }

.credits-body { display: grid; grid-template-columns: 1fr 1.15fr; gap: 24px; margin-top: 18px; }
.credits-controls ul { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.credits-controls li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed rgba(214, 190, 148, 0.12); font-size: 0.7rem; color: var(--ink-soft); }
.credits-notes h3 { margin-bottom: 10px; }
.credits-notes li { position: relative; padding-left: 18px; margin-bottom: 7px; font-size: 0.72rem; line-height: 1.55; color: var(--ink-soft); }
.credits-notes li::before { content: counter(list-item, decimal-leading-zero); position: absolute; left: 0; color: var(--gold-dim); font-family: var(--font-display); font-size: 0.68rem; }
.credits-notes ol { counter-reset: list-item; margin-bottom: 16px; }
.credits-notes p { font-size: 0.66rem; line-height: 1.7; color: #7e897b; }
.credits-notes .credits-tag { margin-top: 12px; color: var(--gold); font-family: var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.74rem; }

.fade {
  position: absolute;
  inset: 0;
  background: #050805;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
  z-index: 95;
}
.fade.show { opacity: 1; pointer-events: auto; }

/* =============================== touch UI =============================== */

#touch-controls { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
#touch-controls > * { pointer-events: auto; }
.joystick {
  position: absolute;
  left: calc(20px + env(safe-area-inset-left, 0px));
  bottom: calc(24px + var(--safe-bottom));
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(214, 190, 148, 0.3);
  background: radial-gradient(circle at 50% 50%, rgba(10, 16, 12, 0.5), rgba(5, 8, 6, 0.34));
  touch-action: none;
}
.joystick-ring {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  border: 1px dashed rgba(214, 190, 148, 0.18);
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 1px solid rgba(216, 182, 120, 0.65);
  background: radial-gradient(circle at 40% 35%, rgba(216, 182, 120, 0.32), rgba(20, 27, 21, 0.8));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.touch-cluster { position: absolute; display: flex; gap: 8px; }
.touch-cluster-left {
  left: calc(20px + env(safe-area-inset-left, 0px));
  bottom: calc(156px + var(--safe-bottom));
}
.touch-cluster-right {
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: 52px 52px 52px;
  grid-template-areas:
    'inv craft flash'
    'jump mid big'
    'run run big';
  gap: 7px;
  align-items: start;
}
.touch-cluster-right [data-action='inventory'] { grid-area: inv; }
.touch-cluster-right [data-action='craft'] { grid-area: craft; }
.touch-cluster-right [data-action='flashlight'] { grid-area: flash; }
.touch-cluster-right [data-action='jump'] { grid-area: jump; }
.touch-cluster-right [data-action='interact'] { grid-area: mid; }
.touch-cluster-right [data-action='attack'] { grid-area: big; align-self: end; height: 111px; }
.touch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(214, 190, 148, 0.35);
  border-radius: 50%;
  background: rgba(9, 14, 11, 0.55);
  backdrop-filter: blur(4px);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn.small { width: 52px; height: 52px; font-size: 0.56rem; }
.touch-btn.mid { width: 52px; height: 52px; font-size: 0.54rem; }
.touch-btn.big {
  width: 111px;
  height: 111px;
  border-radius: 50%;
  border-color: rgba(216, 182, 120, 0.55);
  background: radial-gradient(circle at 40% 35%, rgba(216, 182, 120, 0.22), rgba(9, 14, 11, 0.6));
  color: var(--gold-strong);
  font-size: 0.7rem;
}
.touch-btn:active, .touch-btn.active { background: rgba(216, 182, 120, 0.25); border-color: var(--gold); color: var(--gold-strong); }
.touch-btn .ico { width: 20px; height: 20px; }

/* ============================== animations ============================== */

@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes prompt-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }
@keyframes pulse-danger { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes pulse-soft { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

/* =============================== responsive ============================= */

@media (max-width: 900px) {
  .inv-layout { grid-template-columns: 1fr; gap: 16px; }
  .inv-side { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 14px; }
  .inv-detail { min-height: 0; }
  .detail-actions { flex-direction: row; flex-wrap: wrap; }
  .detail-actions .btn { flex: 1 1 120px; }
  .credits-body { grid-template-columns: 1fr; }
  .craft-layout { grid-template-columns: 1fr; gap: 14px; }
  .craft-cats { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 10px; }
  .craft-cat { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .craft-cat.active { border-bottom-color: var(--gold); }
  .storage-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 680px) {
  body { font-size: 14px; }
  .title-content { padding: 76px 22px 100px; align-self: flex-start; }
  h1#game-title { font-size: clamp(3.9rem, 19vw, 6rem); }
  .title-screen { align-items: flex-start; overflow-y: auto; }
  .title-aside { display: none; }
  .title-foot { font-size: 0.56rem; gap: 6px; flex-direction: column; }
  .tagline { font-size: 0.9rem; letter-spacing: 0.24em; }
  .menu-btn { padding: 12px 4px; }
  .menu-btn .menu-label { font-size: 1.15rem; }
  .hud-left { bottom: calc(104px + var(--safe-bottom)); }
  .vitals { min-width: 176px; padding: 9px 10px; gap: 5px; }
  .vital { grid-template-columns: 13px 1fr 28px; gap: 7px; }
  .vital-val { font-size: 0.54rem; }
  .clock-block { padding: 6px 9px; gap: 7px; }
  .weather-chip { display: none; }
  .hud-actions .icon-btn { width: 38px; height: 38px; }
  #compass { display: none; }
  .hotbar { gap: 4px; }
  .slot { width: 46px; height: 46px; }
  .slot-icon { font-size: 1.35rem; }
  .hud-bottom { bottom: calc(10px + var(--safe-bottom)); width: 96vw; }
  .prompt { bottom: calc(118px + var(--safe-bottom)); font-size: 0.78rem; padding: 6px 10px; }
  .notifications { top: calc(64px + var(--safe-top)); max-width: 62vw; }
  .toast { font-size: 0.66rem; padding: 6px 9px; }
  .panel { padding: 16px; max-height: 94vh; }
  .panel-head h2 { font-size: 1.7rem; }
  .inv-grid { grid-template-columns: repeat(5, 1fr); }
  .storage-grid { grid-template-columns: repeat(5, 1fr); }
  .storage-grid .inv-slot:nth-child(n + 11) { display: none; }
  .craft-list, .build-list { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .pause-screen { padding: 24px 20px; }
  .death-stats { gap: 14px; }
  .death-stat strong { font-size: 1.6rem; }
  .death-actions .btn { min-width: 100%; }
  .field.check { padding-top: 0; }
  .dialog-actions .btn { width: 100%; }
  .equip-slots { display: grid; grid-template-columns: 1fr 1fr; }
  .equip-slot { grid-template-columns: 22px 1fr; }
  .equip-slot .eq-label { display: none; }
}

@media (max-width: 420px) {
  .hud-left { left: 8px; }
  .vitals { min-width: 158px; }
  .slot { width: 42px; height: 42px; }
  .slot-icon { font-size: 1.2rem; }
  .hud-actions { gap: 4px; }
  .hud-actions .icon-btn { width: 34px; height: 34px; }
  .clock-block .ico { display: none; }
  .touch-btn.small { width: 46px; height: 46px; }
  .touch-cluster-right { grid-template-columns: repeat(3, 46px); grid-template-rows: 46px 46px 46px; }
  .touch-btn.mid { width: 46px; height: 46px; }
  .touch-btn.big { width: 99px; height: 99px; }
}

/* ------------------------- touch layout overrides ----------------------- */

body.touch-mode .hud-left {
  bottom: auto;
  top: calc(72px + var(--safe-top));
  left: 10px;
}
body.touch-mode .vitals { min-width: 154px; padding: 8px 10px; opacity: 0.94; }
body.touch-mode .status-effects { max-width: 190px; }
body.touch-mode .hud-bottom {
  bottom: calc(230px + var(--safe-bottom));
  width: auto;
  left: 50%;
}
body.touch-mode .hotbar { gap: 5px; }
body.touch-mode .slot { width: 48px; height: 48px; }
body.touch-mode .slot-icon { font-size: 1.5rem; }
body.touch-mode .equip-indicator { display: none; }
body.touch-mode .prompt { bottom: calc(296px + var(--safe-bottom)); font-size: 0.8rem; }
body.touch-mode .toast-progress { bottom: calc(334px + var(--safe-bottom)); }
body.touch-mode .notifications {
  top: calc(268px + var(--safe-top));
  right: 10px;
  max-width: 58vw;
}
body.touch-mode .toast { font-size: 0.64rem; padding: 6px 9px; }
body.touch-mode .build-actions { bottom: calc(360px + var(--safe-bottom)); }
body.touch-mode .hud-actions .icon-btn { width: 44px; height: 44px; }
body.touch-mode #click-hint { display: none !important; }

/* joystick stays bottom-left */
body.touch-mode .joystick {
  left: calc(18px + env(safe-area-inset-left, 0px));
  bottom: calc(20px + var(--safe-bottom));
  width: 116px;
  height: 116px;
}
body.touch-mode .touch-cluster-left {
  left: calc(20px + env(safe-area-inset-left, 0px));
  bottom: calc(170px + var(--safe-bottom));
  gap: 7px;
}
body.touch-mode .touch-cluster-left .touch-btn {
  width: 54px;
  height: 54px;
}

/* right-hand action pad: absolute, never overflows the screen */
body.touch-mode .touch-cluster-right {
  position: absolute;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + var(--safe-bottom));
  width: 172px;
  height: 172px;
  display: block;
  pointer-events: none;
}
body.touch-mode .touch-cluster-right .touch-btn {
  position: absolute;
  pointer-events: auto;
  width: 50px;
  height: 50px;
  font-size: 0.54rem;
}
body.touch-mode .touch-cluster-right [data-action='attack'] {
  width: 100px;
  height: 100px;
  right: 0;
  bottom: 0;
  font-size: 0.68rem;
  border-color: rgba(216, 182, 120, 0.55);
  background: radial-gradient(circle at 40% 35%, rgba(216, 182, 120, 0.22), rgba(9, 14, 11, 0.6));
  color: var(--gold-strong);
}
body.touch-mode .touch-cluster-right [data-action='interact'] {
  width: 60px;
  height: 60px;
  right: 106px;
  bottom: 0;
  font-size: 0.52rem;
}
body.touch-mode .touch-cluster-right [data-action='jump'] {
  width: 60px;
  height: 60px;
  right: 106px;
  bottom: 66px;
}
body.touch-mode .touch-cluster-right [data-action='inventory'] {
  right: 0;
  bottom: 116px;
}
body.touch-mode .touch-cluster-right [data-action='craft'] {
  right: 56px;
  bottom: 116px;
}
body.touch-mode .touch-cluster-right [data-action='flashlight'] {
  right: 112px;
  bottom: 116px;
}

@media (max-width: 680px) {
  body.touch-mode .hud-bottom { bottom: calc(222px + var(--safe-bottom)); }
  body.touch-mode .vitals { min-width: 146px; }
  .hud-top { padding: 0 10px; }
  .hud-actions .icon-btn { width: 38px; height: 38px; }
}

@media (max-height: 560px) {
  body.touch-mode .hud-bottom { bottom: calc(168px + var(--safe-bottom)); }
  body.touch-mode .slot { width: 42px; height: 42px; }
  body.touch-mode .notifications { top: calc(180px + var(--safe-top)); }
  body.touch-mode .joystick { width: 96px; height: 96px; bottom: 12px; }
  body.touch-mode .touch-cluster-right { transform: scale(0.86); transform-origin: bottom right; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------- item glyphs (inline SVG) ----------------------- */

.item-glyph {
  width: 24px;
  height: 24px;
  display: block;
  overflow: visible;
  pointer-events: none;
}
.slot-icon { display: flex; align-items: center; justify-content: center; }
.slot-icon .item-glyph { width: 66%; height: 66%; }
.inv-slot .slot-icon .item-glyph { width: 64%; height: 64%; }
.recipe-icon .item-glyph { width: 62%; height: 62%; }
.mat .item-glyph { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; stroke-width: 2; }
.equip-glyph { width: 17px; height: 17px; }
.eq-icon .item-glyph { width: 18px; height: 18px; }
.equip-empty { color: #7c8779; letter-spacing: 0.12em; font-size: 0.64rem; }
.equip-light { color: var(--muted); font-size: 0.62rem; letter-spacing: 0.04em; }
.equip-indicator .item-glyph { color: var(--gold); }
.inv-detail h3 { display: flex; align-items: center; gap: 8px; }
.boot-error {
  position: fixed; inset: 0; z-index: 999; display: grid; place-content: center;
  text-align: center; padding: 2rem; background: #060906; color: #ece6d6;
  font-family: var(--font-body);
}
.boot-error h1 { font-family: var(--font-display); font-size: 4rem; letter-spacing: 0.1em; color: var(--gold); }
.boot-error p { margin-top: 1rem; max-width: 46ch; line-height: 1.6; }
.boot-error .small { color: var(--muted); font-size: 0.8rem; }
