/* Fogwake client — design tokens
   Abyss #0B1620 · Fogbank #1C2B36 · Mist #8FA8B2 · Bone #E8E2D4 · Lantern #E0A458 · Kelp #3E6B5C */
:root {
  --abyss: #0b1620;
  --fogbank: #1c2b36;
  --panel: #16242e;
  --mist: #8fa8b2;
  --bone: #e8e2d4;
  --lantern: #e0a458;
  --kelp: #3e6b5c;
  --danger: #c4694f;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
body {
  background: var(--abyss);
  color: var(--bone);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
}
input, textarea, select, .panel.auth-panel, .panel.auth-panel * {
  -webkit-user-select: text; user-select: text;
}
#game-root, #game-canvas, .inv-panel, .slot-cell, .equip-slot, .inv-hslot,
.hud-top, .hud-left, .hud-right, .hud-br, .bag-btn, .action-btn, .joy-zone,
.note-host, .death-screen, button {
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

/* ---- signature: drifting fog ---- */
#fog-layer {
  position: fixed; inset: -20%;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 40% at 20% 70%, rgba(143,168,178,.10), transparent 70%),
    radial-gradient(50% 35% at 75% 25%, rgba(143,168,178,.07), transparent 70%),
    radial-gradient(70% 45% at 55% 85%, rgba(62,107,92,.08), transparent 70%);
  animation: fog-drift 46s ease-in-out infinite alternate;
}
@keyframes fog-drift {
  from { transform: translate3d(-3%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  #fog-layer { animation: none; }
}

/* ---- version stamp (loading, menu, in-game) ---- */
.version-stamp {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .82);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  pointer-events: none;
  user-select: none;
}

/* ---- boot ---- */
.boot {
  position: fixed; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 38%, rgba(62, 107, 92, .14), transparent 70%),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(11, 22, 32, .9), var(--abyss));
}
.boot-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, .55) 100%);
}
.boot-mark {
  position: relative; z-index: 1;
  text-align: center; width: min(360px, 88vw);
  padding: 28px 24px 20px;
}
.boot-crest {
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.boot-lantern {
  display: block; width: 36px; height: 44px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 35%, rgba(255, 220, 160, .95), rgba(224, 164, 88, .5) 55%, transparent 70%),
    linear-gradient(180deg, rgba(224, 164, 88, .35), rgba(224, 164, 88, .08));
  border-radius: 50% 50% 45% 45%;
  box-shadow: 0 0 28px rgba(224, 164, 88, .35), 0 0 60px rgba(224, 164, 88, .12);
  animation: lantern-glow 3.2s ease-in-out infinite alternate;
}
@keyframes lantern-glow {
  from { filter: brightness(1); transform: scale(1); }
  to   { filter: brightness(1.12); transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-lantern { animation: none; }
}
.wordmark {
  font-family: var(--display);
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  letter-spacing: .34em;
  margin-left: .34em;
  color: var(--bone);
  text-shadow: 0 0 32px rgba(224, 164, 88, .22), 0 2px 12px rgba(0, 0, 0, .4);
}
.boot-tagline {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--mist);
}
.compass-rule {
  display: flex; align-items: center; justify-content: center;
  margin: 16px auto 14px; width: min(260px, 60vw); height: 9px;
  border-top: 1px solid rgba(224, 164, 88, .55);
  position: relative;
}
.compass-rule span {
  position: absolute; top: -5px;
  width: 9px; height: 9px; transform: rotate(45deg);
  background: var(--lantern);
}
.boot-progress {
  height: 3px; width: min(240px, 70vw); margin: 0 auto 12px;
  background: rgba(143, 168, 178, .15);
  border-radius: 99px; overflow: hidden;
}
.boot-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--kelp), var(--lantern));
  border-radius: 99px;
  transition: width .25s ease-out;
}
.boot-status { color: var(--mist); font-size: .82rem; font-family: var(--mono); min-height: 1.2em; }
.boot-status.error { color: var(--danger); }
.boot-version {
  position: fixed; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 6;
}

/* ---- app frame ---- */
#app { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; }
.screen {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  position: relative;
}
.screen-shell {
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(62, 107, 92, .12), transparent 55%),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(11, 22, 32, .5), transparent 70%);
}
.panel {
  width: min(420px, 100%);
  background: linear-gradient(165deg, rgba(28, 43, 54, .97), rgba(22, 36, 46, .98));
  border: 1px solid rgba(143, 168, 178, .2);
  border-radius: 14px;
  padding: 26px 24px 22px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, .5),
    inset 0 1px 0 rgba(255, 255, 255, .04);
  position: relative;
}
.panel::before {
  content: "";
  position: absolute; left: 18px; right: 18px; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--lantern), transparent);
  border-radius: 2px; opacity: .65;
}
.panel.auth-panel, .panel.menu-panel { padding-top: 22px; }
.brand-block { text-align: center; margin-bottom: 18px; }
.brand-block .brand-crest {
  display: inline-block; width: 28px; height: 34px; margin-bottom: 10px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 35%, rgba(255, 220, 160, .9), rgba(224, 164, 88, .45) 60%, transparent 75%);
  border-radius: 50% 50% 42% 42%;
  box-shadow: 0 0 18px rgba(224, 164, 88, .25);
}
.panel h1 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: .22em; margin-left: .22em;
  text-align: center;
  font-size: 1.55rem;
  margin-bottom: 4px;
}
.panel .sub {
  text-align: center; color: var(--mist); font-size: .82rem;
  margin-bottom: 18px; line-height: 1.45;
}
.panel .sub.member-since {
  font-family: var(--mono); font-size: .68rem;
  letter-spacing: .06em; color: rgba(143, 168, 178, .9);
  margin-top: -10px; margin-bottom: 16px;
}
.panel-footer {
  margin-top: 18px; padding-top: 12px;
  border-top: 1px solid rgba(143, 168, 178, .12);
  text-align: center;
}
.panel-footer .version-stamp { position: static; display: inline-block; }

/* ---- forms ---- */
label { display: block; font-size: .78rem; color: var(--mist); letter-spacing: .06em; text-transform: uppercase; margin: 14px 0 6px; }
input[type=text], input[type=password] {
  width: 100%; padding: 12px 14px;
  font-size: 1rem; font-family: var(--body);
  color: var(--bone); background: var(--abyss);
  border: 1px solid rgba(143,168,178,.25);
  border-radius: 8px; outline: none;
}
input:focus-visible { border-color: var(--lantern); box-shadow: 0 0 0 2px rgba(224,164,88,.25); }
.hint { font-size: .78rem; color: var(--mist); margin-top: 6px; min-height: 1.1em; }
.hint.ok { color: #7fb89a; }
.hint.bad { color: var(--danger); }

button {
  font-family: var(--body); font-size: 1rem; cursor: pointer;
  border-radius: 8px; border: 1px solid transparent;
  padding: 12px 16px; width: 100%; margin-top: 18px;
  background: var(--lantern); color: #221608; font-weight: 600;
  transition: filter .12s ease, transform .05s ease;
}
button:hover { filter: brightness(1.07); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--bone); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
button.ghost {
  background: transparent; color: var(--mist);
  border-color: rgba(143,168,178,.3);
  font-weight: 400;
}
button.ghost:hover { color: var(--bone); border-color: var(--mist); }

.tabs {
  display: flex; gap: 0; margin-bottom: 14px;
  padding: 3px; border-radius: 10px;
  background: rgba(11, 22, 32, .65);
  border: 1px solid rgba(143, 168, 178, .15);
}
.tabs button {
  margin-top: 0; flex: 1; padding: 10px 8px;
  background: transparent; color: var(--mist);
  border: 1px solid transparent; font-weight: 500;
  border-radius: 8px; font-size: .88rem;
}
.tabs button.active {
  color: var(--bone); border-color: rgba(224, 164, 88, .35);
  background: rgba(224, 164, 88, .12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.auth-form label:first-of-type { margin-top: 4px; }

/* ---- menu ---- */
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.menu-list button {
  margin-top: 0; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px;
  border-radius: 10px;
}
.menu-list button.menu-primary {
  background: linear-gradient(180deg, rgba(224, 164, 88, .95), rgba(196, 140, 70, .92));
  border-color: rgba(255, 220, 160, .25);
  font-size: 1.02rem;
  box-shadow: 0 4px 16px rgba(224, 164, 88, .2);
}
.menu-list button.menu-primary small { color: rgba(34, 22, 8, .65); }
.menu-list button { margin-top: 0; }
.menu-list button small { color: rgba(34, 22, 8, .6); font-weight: 400; font-size: .72rem; }
.menu-list button.ghost small { color: var(--mist); }
.menu-list button.ghost {
  background: rgba(11, 22, 32, .45);
  border-color: rgba(143, 168, 178, .2);
}
.news {
  margin-top: 20px; border-top: 1px solid rgba(143, 168, 178, .15);
  padding-top: 14px; max-height: 28vh; overflow-y: auto;
}
.news h2 {
  font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--lantern); font-weight: 600; margin-bottom: 10px;
}
.news article {
  margin-bottom: 12px; padding: 10px 12px;
  background: rgba(11, 22, 32, .4);
  border-radius: 8px;
  border: 1px solid rgba(143, 168, 178, .1);
}
.news article h3 { font-family: var(--display); font-weight: 400; font-size: .95rem; margin-bottom: 4px; }
.news article p { color: var(--mist); font-size: .8rem; line-height: 1.4; }

/* ---- character cards ---- */
.char-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.char-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 8px;
  background: var(--abyss); border: 1px solid rgba(143,168,178,.2);
  cursor: pointer; transition: border-color .12s;
}
.char-card:hover, .char-card:focus-visible { border-color: var(--lantern); outline: none; }
.char-dot { width: 30px; height: 30px; border-radius: 50%; flex: none; border: 2px solid rgba(232,226,212,.4); }
.char-card .meta { flex: 1; }
.char-card .meta .name { font-family: var(--display); font-size: 1.05rem; }
.char-card .meta .info { font-size: .76rem; color: var(--mist); font-family: var(--mono); }
.swatches { display: flex; gap: 10px; margin-top: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; margin: 0; }
.swatch.selected { border-color: var(--bone); box-shadow: 0 0 0 2px var(--lantern); }

/* ---- game ---- */
#game-root { position: fixed; inset: 0; z-index: 2; overscroll-behavior: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 1; }
.hud-version {
  position: absolute; left: calc(12px + env(safe-area-inset-left));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 4; pointer-events: none;
}
.joy-zone {
  position: absolute; left: 0; top: 0; bottom: 0; width: 46%;
  z-index: 2; touch-action: none;
}
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
  pointer-events: none;
}
.hud-top .loc { font-family: var(--mono); font-size: .75rem; color: var(--mist); background: rgba(11,22,32,.6); padding: 6px 10px; border-radius: 6px; }
.hud-top button { pointer-events: auto; width: auto; margin: 0; padding: 8px 14px; font-size: .85rem; }
.joystick {
  position: absolute; border-radius: 50%;
  border: 1.5px solid rgba(232,226,212,.35);
  background: rgba(28,43,54,.35); backdrop-filter: blur(2px);
  pointer-events: none;
}
.joystick .nub { position: absolute; border-radius: 50%; background: rgba(224,164,88,.85); }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 50;
  background: var(--fogbank); color: var(--bone);
  border: 1px solid rgba(224,164,88,.5); border-radius: 8px;
  padding: 10px 18px; font-size: .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ===================== gameplay HUD (phase 3 slice) ===================== */
.hud-top { align-items: flex-start; gap: 10px; }
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.hud-right { align-items: flex-end; }
.hud-right .hud-leave { pointer-events: auto; }

.vitals { display: flex; align-items: center; gap: 8px; background: rgba(11,22,32,.62); border: 1px solid rgba(143,168,178,.18); border-radius: 10px; padding: 6px 10px; }
.lvl-badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--lantern); color: #2a1c0a;
  font-family: var(--mono); font-weight: 700; font-size: .8rem;
  box-shadow: 0 0 0 2px rgba(224,164,88,.3);
}
.bars { display: flex; flex-direction: column; gap: 3px; width: 130px; }
.bar-row { display: flex; align-items: center; gap: 4px; }
.bar-row.thin .bar { height: 5px; }
.bar-row.warn .bar { box-shadow: 0 0 6px rgba(224,106,85,.55); }
.bar-ico { font-size: .62rem; width: 14px; text-align: center; opacity: .85; }
.bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(232,226,212,.12); overflow: hidden; }
.bar.thin { height: 5px; }
.bar-fill { height: 100%; width: 100%; border-radius: inherit; transition: width .25s ease; }
.bar-fill.hp { background: linear-gradient(90deg, #5d9a63, #6fae74); }
.bar-fill.hunger { background: linear-gradient(90deg, #a06820, #e0a458); }
.bar-fill.thirst { background: linear-gradient(90deg, #2a6a8a, #4a9ec4); }
.bar-fill.xp { background: linear-gradient(90deg, #6b4fa8, #9b7fd4); }
.sp-badge {
  min-width: 18px; height: 18px; border-radius: 999px; padding: 0 5px;
  background: #6fae74; color: #1a2a1c; font-family: var(--mono); font-size: .65rem;
  font-weight: 700; display: grid; place-items: center;
}
.sp-badge[hidden] { display: none !important; }
.hud-right .hud-stats { pointer-events: auto; }

.quest-card {
  max-width: 230px; background: rgba(11,22,32,.62);
  border: 1px solid rgba(143,168,178,.18); border-left: 3px solid var(--lantern);
  border-radius: 8px; padding: 8px 10px; pointer-events: none;
}
.quest-card.done { border-left-color: #6fae74; }
.q-title { font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mist); margin-bottom: 3px; }
.q-label { font-size: .8rem; color: var(--bone); line-height: 1.35; }
.q-prog { font-family: var(--mono); font-size: .72rem; color: var(--lantern); margin-top: 3px; }
.q-hint { font-size: .68rem; color: var(--mist); font-style: italic; margin-top: 2px; line-height: 1.3; }

.hud-br {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  z-index: 4; pointer-events: auto;
}
.action-btn {
  width: 76px; height: 76px; border-radius: 50%;
  border: 2px solid rgba(224,164,88,.55);
  background: radial-gradient(circle at 35% 30%, rgba(224,164,88,.32), rgba(11,22,32,.85));
  color: var(--bone); font-size: .8rem; font-weight: 600;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
  touch-action: manipulation;
  position: relative; overflow: hidden;
  --cd: 0;
}
.action-btn::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(rgba(11,22,32,.75) calc(var(--cd) * 360deg), transparent 0);
  pointer-events: none;
}
.action-btn:active { transform: scale(.94); }
.action-btn.ready {
  border-color: var(--lantern);
  box-shadow: 0 0 18px rgba(224,164,88,.55);
  animation: action-pulse 1.6s ease-in-out infinite;
}
.action-btn.ready.gather {
  border-color: #5a9e6f;
  animation-name: action-pulse-gather;
}
.action-btn.ready.attack {
  border-color: var(--danger);
  animation-name: action-pulse-attack;
}
@keyframes action-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(224,164,88,.4); }
  50% { box-shadow: 0 0 22px rgba(224,164,88,.7); }
}
@keyframes action-pulse-gather {
  0%, 100% { box-shadow: 0 0 12px rgba(90,158,111,.35); }
  50% { box-shadow: 0 0 22px rgba(90,158,111,.65); }
}
@keyframes action-pulse-attack {
  0%, 100% { box-shadow: 0 0 12px rgba(196,105,79,.35); }
  50% { box-shadow: 0 0 22px rgba(196,105,79,.65); }
}
@media (prefers-reduced-motion: reduce) {
  .action-btn.ready { animation: none; }
}
.slot-lbl.slot-empty-icon { opacity: 0.35; filter: grayscale(1); }
@media (max-width: 640px) {
  .equip-col .paper-doll {
    display: flex; flex-wrap: nowrap; gap: 5px;
    overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .equip-col .equip-slot {
    flex: 0 0 auto; width: 38px; height: 38px; min-height: 38px;
    aspect-ratio: 1;
  }
  .equip-col .slot-lbl { font-size: 0.75rem; }
  .inv-panel { padding: 12px; }
  .craft-column {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 32vh; overflow-y: auto;
  }
}
.bag-btn {
  width: 54px; height: 54px; border-radius: 14px;
  border: 2px solid rgba(224,164,88,.35);
  background: linear-gradient(180deg, rgba(20,36,48,.92), rgba(11,22,32,.88));
  cursor: pointer; touch-action: manipulation;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.bag-btn:active { transform: scale(.94); }
.bag-ico { font-size: 1.15rem; line-height: 1; }
.bag-lbl {
  font-family: var(--mono); font-size: .52rem; letter-spacing: .08em;
  color: var(--lantern); text-transform: uppercase;
}
.hud-loc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.sh-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(224,164,88,.12); border: 1px solid rgba(224,164,88,.35);
  border-radius: 999px; padding: 3px 10px;
  font-family: var(--mono); font-size: .72rem; color: var(--lantern);
}
.sh-label { opacity: .75; font-weight: 600; }
.sh-val { font-weight: 700; }

.hotbar {
  position: absolute; left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 4; pointer-events: auto;
}
.hot-slot {
  width: 48px; height: 48px; border-radius: 10px;
  border: 2px solid rgba(143,168,178,.25); background: rgba(11,22,32,.78);
  font-size: 1.25rem; cursor: pointer; touch-action: manipulation;
  display: grid; place-items: center; color: var(--mist);
}
.hot-slot.active { border-color: var(--lantern); box-shadow: 0 0 10px rgba(224,164,88,.35); }
.hot-slot.empty { font-size: .75rem; font-family: var(--mono); opacity: .5; }

.use-btn {
  width: 50px; height: 36px; border-radius: 10px;
  border: 1px solid rgba(111,174,116,.45); background: rgba(111,174,116,.15);
  color: var(--bone); font-size: .75rem; cursor: pointer;
}
.use-btn[hidden] { display: none !important; }

.stats-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 360px); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(15,30,40,.97), rgba(11,22,32,.97));
  border: 1px solid rgba(143,168,178,.25); border-radius: 14px;
  padding: 16px 18px; z-index: 5; box-shadow: 0 18px 60px rgba(0,0,0,.6);
}
.stats-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 4px;
}
.stats-head-text { flex: 1; min-width: 0; }
.stats-name {
  font-family: var(--display); font-size: 1.2rem; color: var(--bone);
  line-height: 1.2; word-break: break-word;
}
.stats-sub {
  font-family: var(--mono); font-size: .72rem; color: var(--mist);
  margin-top: 4px; letter-spacing: .04em;
}
.stats-close { width: auto; margin: 0; padding: 4px 10px; flex-shrink: 0; }
.stats-sp {
  font-family: var(--mono); font-size: .75rem; color: var(--mist);
  margin: 0 0 14px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(143,168,178,.14);
}
.stats-sp.has-points { color: var(--lantern); }
.stats-vitals, .stats-attrs { margin-bottom: 14px; }
.stats-vitals .col-h, .stats-attrs .col-h { margin-bottom: 10px; }
.stats-vital-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.stats-vital-row.warn .stats-bar { box-shadow: 0 0 6px rgba(224,106,85,.45); }
.stats-vital-ico { width: 18px; text-align: center; font-size: .75rem; opacity: .9; }
.stats-vital-meta { flex: 1; min-width: 0; }
.stats-vital-label {
  display: block; font-size: .68rem; color: var(--mist);
  margin-bottom: 3px; font-family: var(--mono); letter-spacing: .06em;
  text-transform: uppercase;
}
.stats-bar { height: 8px; border-radius: 4px; background: rgba(232,226,212,.1); overflow: hidden; }
.stats-vital-val {
  font-family: var(--mono); font-size: .68rem; color: var(--lantern);
  min-width: 3.2rem; text-align: right; flex-shrink: 0;
}
.stats-list { display: flex; flex-direction: column; gap: 6px; }
.stat-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(232,226,212,.05); border: 1px solid rgba(143,168,178,.12);
  border-radius: 8px; padding: 8px 10px;
}
.stat-name {
  flex: 1; font-size: .84rem; color: var(--bone); cursor: help;
  border-bottom: 1px dotted rgba(143,168,178,.35);
}
.stat-val { font-family: var(--mono); color: var(--lantern); min-width: 1.5rem; text-align: center; }
.stat-plus {
  width: 28px; height: 28px; border-radius: 6px; margin: 0; padding: 0;
  border: 1px solid rgba(224,164,88,.5); background: rgba(224,164,88,.18);
  color: var(--bone); cursor: pointer; font-size: 1rem; flex-shrink: 0;
}
.stat-plus:disabled { opacity: .3; cursor: default; }

.inv-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(96vw, 380px); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(15,30,40,.97), rgba(11,22,32,.97));
  border: 1px solid rgba(143,168,178,.25); border-radius: 14px;
  padding: 16px; z-index: 4; box-shadow: 0 18px 60px rgba(0,0,0,.6);
}
.inv-head-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.inv-sh { font-family: var(--mono); font-size: .75rem; color: var(--lantern); }
.inv-body { display: flex; flex-direction: column; gap: 12px; }
@media (orientation: landscape) and (min-height: 400px) and (min-width: 640px) {
  .inv-panel { width: min(96vw, 860px); max-height: 88vh; }
  .inv-body {
    display: grid;
    grid-template-columns: 140px 1fr minmax(180px, 220px);
    gap: 14px; align-items: start;
  }
}
.equip-col .paper-doll {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.slot-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}
.slot-cell {
  aspect-ratio: 1; min-height: 44px;
  background: rgba(232,226,212,.05); border: 1px solid rgba(143,168,178,.18);
  border-radius: 8px; padding: 2px; position: relative; cursor: pointer;
  display: grid; place-items: center; touch-action: manipulation;
}
.slot-cell.empty { opacity: .45; }
.slot-cell.picked, .equip-slot.picked, .inv-hslot.picked {
  border-color: var(--lantern);
  box-shadow: 0 0 8px rgba(224,164,88,.4);
}
.slot-ico { font-size: 1.2rem; line-height: 1; }
.slot-qty {
  position: absolute; bottom: 2px; right: 4px;
  font-family: var(--mono); font-size: .6rem; color: var(--lantern);
}
.slot-lbl { font-size: .85rem; opacity: .7; }
.inv-hotbar { display: flex; gap: 6px; margin-top: 0; margin-bottom: 8px; }
.inv-hslot { width: 44px; height: 44px; }
.col-h { font-family: var(--mono); font-size: .65rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mist); margin: 0 0 8px; }
.inv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.inv-head h2 { font-family: var(--display); font-size: 1.05rem; color: var(--bone); margin: 0; }
.inv-close { width: auto; margin: 0; padding: 4px 10px; }
.inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.inv-slot {
  background: rgba(232,226,212,.06); border: 1px solid rgba(143,168,178,.16);
  border-radius: 10px; padding: 8px 4px; text-align: center; position: relative;
}
.inv-ico { font-size: 1.4rem; display: block; }
.inv-qty {
  position: absolute; top: 4px; right: 6px;
  font-family: var(--mono); font-size: .68rem; color: var(--lantern);
}
.inv-name { font-size: .6rem; color: var(--mist); display: block; margin-top: 2px; }
.inv-empty { grid-column: 1 / -1; color: var(--mist); font-size: .8rem; font-style: italic; }
.craft-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(232,226,212,.05); border: 1px solid rgba(143,168,178,.14);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.craft-row .inv-ico { font-size: 1.3rem; }
.craft-meta { flex: 1; }
.craft-name { font-size: .85rem; color: var(--bone); }
.craft-needs { font-size: .7rem; color: var(--mist); }
.craft-btn {
  width: auto; margin: 0; padding: 7px 14px; font-size: .78rem;
  border-radius: 8px; border: 1px solid rgba(224,164,88,.5);
  background: rgba(224,164,88,.18); color: var(--bone); cursor: pointer;
}
.craft-btn:disabled { opacity: .35; cursor: default; }
.inv-assign {
  width: auto; margin: 4px auto 0; padding: 2px 8px; font-size: .58rem;
  border-radius: 6px; border: 1px solid rgba(224,164,88,.4);
  background: rgba(224,164,88,.12); color: var(--bone); cursor: pointer; display: block;
}

/* --- inventory polish: DnD ghost, tooltips, rarity, animations --- */
.inv-panel.inv-open {
  animation: inv-panel-in .22s ease-out;
}
@keyframes inv-panel-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .inv-panel.inv-open { animation: none; }
  .slot-cell, .equip-slot, .inv-hslot, .inv-ghost { transition: none !important; }
  .drop-valid { animation: none !important; }
}

.slot-grid { contain: layout style; }
.grid-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid-toolbar .col-h { margin: 0; }
.inv-sort-btn { width: auto; margin: 0; padding: 4px 10px; font-size: .72rem; }

.slot-cell:hover:not(.empty), .equip-slot:hover:not(.empty), .inv-hslot:hover:not(.empty) {
  transform: scale(1.04);
  border-color: rgba(224,164,88,.45);
  transition: transform .12s ease, border-color .12s ease;
}
.slot-cell.kb-focus {
  outline: 2px solid var(--lantern);
  outline-offset: 2px;
}

.slot-cell.rarity-uncommon, .equip-slot.rarity-uncommon { border-color: #5a9e6f; }
.slot-cell.rarity-rare, .equip-slot.rarity-rare { border-color: #4a7eb8; }
.slot-cell.rarity-epic, .equip-slot.rarity-epic { border-color: #9b6bcc; }
.slot-cell.rarity-legendary, .equip-slot.rarity-legendary {
  border-color: #c9a227;
  box-shadow: 0 0 6px rgba(201,162,39,.35);
}
.tip-name.rarity-uncommon { color: #5a9e6f; }
.tip-name.rarity-rare { color: #6aa3e8; }
.tip-name.rarity-epic { color: #b88ee8; }
.tip-name.rarity-legendary { color: #e0c050; }

.slot-cell.drag-source { opacity: .45; }
.slot-cell.drop-valid, .equip-slot.drop-valid, .inv-hslot.drop-valid {
  border-color: #5a9e6f;
  box-shadow: 0 0 0 2px rgba(90,158,111,.35);
  animation: drop-pulse 1s ease-in-out infinite;
}
.slot-cell.drop-invalid, .equip-slot.drop-invalid, .inv-hslot.drop-invalid {
  border-color: #c4694f;
}
@keyframes drop-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(90,158,111,.25); }
  50% { box-shadow: 0 0 0 3px rgba(90,158,111,.5); }
}
@keyframes slot-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.slot-cell.slot-shake, .equip-slot.slot-shake { animation: slot-shake .35s ease; }

.slot-cell.long-press-pending::after {
  content: "";
  position: absolute; inset: 3px;
  border: 2px solid var(--lantern);
  border-radius: 6px;
  border-top-color: transparent;
  animation: long-press-spin .32s linear infinite;
  pointer-events: none;
}
@keyframes long-press-spin { to { transform: rotate(360deg); } }

.inv-panel.inv-dragging { overflow: hidden; touch-action: none; }
.inv-dragging .slot-grid { touch-action: none; }
.inv-dragging { touch-action: none; user-select: none; }

.inv-ghost {
  position: fixed; left: 0; top: 0; z-index: 10002;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: rgba(15,30,40,.92);
  border: 2px solid var(--lantern);
  border-radius: 10px;
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.inv-ghost .slot-qty { position: absolute; bottom: 2px; right: 4px; }

.item-tooltip {
  position: fixed; z-index: 10000;
  max-width: 240px; padding: 10px 12px;
  background: rgba(11,22,32,.96);
  border: 1px solid rgba(143,168,178,.28);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  pointer-events: none;
}
.item-detail {
  background: rgba(232,226,212,.04);
  border: 1px solid rgba(143,168,178,.18);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.item-detail-popover {
  position: fixed; z-index: 10001;
  max-width: 260px; margin: 0;
  background: rgba(11,22,32,.97);
  border: 1px solid rgba(143,168,178,.28);
  box-shadow: 0 12px 32px rgba(0,0,0,.55);
  pointer-events: auto;
}
.tip-head { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.tip-ico { font-size: 1.4rem; line-height: 1; }
.tip-title-wrap { display: flex; flex-direction: column; gap: 2px; }
.tip-name { font-size: .9rem; font-weight: 600; color: var(--bone); }
.tip-rarity {
  font-family: var(--mono); font-size: .58rem;
  text-transform: uppercase; letter-spacing: .08em; color: var(--mist);
}
.tip-desc { font-size: .78rem; color: var(--mist); margin: 0 0 6px; line-height: 1.35; }
.tip-stats { margin: 0; padding: 0 0 0 1rem; font-size: .74rem; color: var(--bone); }
.tip-stats li { margin: 2px 0; }
.tip-qty, .tip-sh { font-size: .72rem; color: var(--mist); margin: 4px 0 0; }
.tip-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tip-btn {
  width: auto; margin: 0; padding: 5px 10px; font-size: .72rem;
  border-radius: 6px; border: 1px solid rgba(224,164,88,.45);
  background: rgba(224,164,88,.15); color: var(--bone); cursor: pointer;
}

.craft-row.selected { border-color: rgba(224,164,88,.45); background: rgba(224,164,88,.08); }
.slot-cell.mat-highlight {
  box-shadow: 0 0 0 2px rgba(224,164,88,.5);
  border-color: var(--lantern);
}

.slot-dur {
  position: absolute; left: 3px; right: 3px; bottom: 2px;
  height: 3px; border-radius: 2px;
  background: rgba(0,0,0,.35); overflow: hidden;
}
.slot-dur > span {
  display: block; height: 100%; border-radius: 2px;
  background: var(--kelp);
}
.slot-dur.low > span { background: var(--danger); }
.tip-close {
  position: absolute; top: 6px; right: 8px;
  width: auto; margin: 0; padding: 2px 7px; font-size: .7rem;
  border: 1px solid rgba(143,168,178,.3); border-radius: 4px;
  background: transparent; color: var(--mist); cursor: pointer;
}
.item-detail-popover { position: fixed; }

.note-host {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 4px;
  pointer-events: none; z-index: 3;
}
.note {
  background: rgba(11,22,32,.78); border: 1px solid rgba(224,164,88,.3);
  color: var(--bone); font-family: var(--mono); font-size: .75rem;
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  transition: opacity .6s ease, transform .6s ease;
}
.note.fade { opacity: 0; transform: translateY(-10px); }

.death-screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 14, 20, .82); backdrop-filter: blur(3px);
  pointer-events: auto;
}
.death-screen[hidden] { display: none !important; }
.death-card {
  width: min(92vw, 380px); text-align: center;
  background: linear-gradient(180deg, rgba(15,30,40,.98), rgba(11,22,32,.98));
  border: 1px solid rgba(196,105,79,.45); border-radius: 16px;
  padding: 28px 24px; box-shadow: 0 24px 80px rgba(0,0,0,.65);
}
.death-card h2 {
  font-family: var(--display); font-size: 1.6rem; color: var(--bone);
  margin: 0 0 12px;
}
.death-msg { color: var(--mist); font-size: .92rem; margin: 0 0 8px; line-height: 1.45; }
.death-hint {
  font-family: var(--mono); font-size: .72rem; color: var(--lantern);
  margin: 0 0 20px; line-height: 1.4;
}
.death-respawn {
  width: 100%; margin: 0 0 10px; padding: 14px;
  border-radius: 10px; border: 1px solid rgba(224,164,88,.55);
  background: rgba(224,164,88,.22); color: var(--bone);
  font-size: .95rem; font-weight: 600; cursor: pointer;
}
.death-menu { width: 100%; margin: 0; }
