:root {
  color-scheme: dark;
  --bg: #14130f;
  --panel: rgba(26, 24, 20, 0.96);
  --border: #302c25;
  --text: #cbc4b6;
  --dim: #837c6e;
  --accent: #a9976f;
  --danger: #a76a5f;
  --ok: #849469;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  touch-action: pan-x pan-y;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

#app { height: 100vh; position: relative; touch-action: pan-x pan-y; }

/* Native one-finger scrolling stays available inside UI surfaces. Pinch is
   reserved for the map, so these regions deliberately expose only one axis. */
.login-wrap,
.floating,
#side-panel,
.context-menu,
#chat-list,
.market-offers {
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#primary-nav,
.filter-row {
  touch-action: pan-x;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

h1 { font-size: 18px; color: var(--accent); margin: 8px 0; }
h2 { font-size: 14px; color: var(--accent); margin: 0 0 8px; }
h3 { font-size: 12px; color: var(--dim); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.06em; }

button {
  background: #2b2620;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  margin: 2px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.wide { display: block; width: 100%; text-align: left; }
button {
  position: relative;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 100ms ease;
}
button:active, button.pressed { transform: translateY(1px) scale(0.98); background: #3a3127; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .58; }

input {
  background: #14110d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font: inherit;
  touch-action: manipulation;
}

ul { margin: 4px 0; padding-left: 18px; }
li { margin: 1px 0; }
.muted { color: var(--dim); }
.error { color: var(--danger); }
.hidden { display: none !important; }

/* --- Login --- */

.login-wrap {
  width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 18%, rgba(129, 105, 66, .13), transparent 34%),
    linear-gradient(rgba(10,9,7,.3), rgba(10,9,7,.78));
}
.login-brand { display: flex; align-items: center; gap: 11px; color: var(--accent); }
.login-brand > span { font-size: 34px; filter: sepia(.25); }
.login-brand h1 { margin: 0; font-size: 20px; letter-spacing: .03em; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  width: min(390px, 100%);
  min-width: 0;
  box-shadow: 0 24px 70px rgba(0,0,0,.48), 0 0 0 1px rgba(255,255,255,.02) inset;
  animation: login-in 500ms cubic-bezier(.2,.8,.2,1) both;
}
.login-card form { display: grid; gap: 6px; }
.login-card label { margin-top: 4px; color: #a89e8e; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.login-card input { display: block; width: 100%; min-height: 46px; margin: 0 0 5px; padding: 10px 12px; }
.login-card .auth-primary { width: 100%; min-height: 46px; margin: 9px 0 0; color: #17130e; border-color: #b29b70; background: #a9976f; font-weight: 800; }
.login-card .auth-primary:hover { color: #111; background: #c1ad84; }
.auth-message { margin-top: 12px; padding: 9px 10px; border-left: 2px solid currentColor; background: rgba(255,255,255,.025); font-size: 11px; }
.auth-message.success { color: #a9bf82; }
.auth-switch { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.auth-switch button { width: 100%; min-height: 40px; margin: 0; border-color: transparent; background: transparent; color: var(--dim); }

/* --- Map --- */

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(ellipse at center, #1b1712 0%, var(--bg) 75%);
  transform-origin: 50% 50%;
  transition: transform 220ms cubic-bezier(.2,.75,.25,1), filter 260ms ease;
  touch-action: none;
}
#map g.hex { cursor: pointer; }
#map g.hex polygon { transition: filter 0.1s; }
#map g.hex:hover polygon { filter: brightness(1.25); }
#map text { pointer-events: none; user-select: none; }

/* --- Local tile map --- */

#local-wrap {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  background: radial-gradient(ellipse at center, #1b1712 0%, var(--bg) 75%);
  touch-action: none;
}
#local-svg {
  flex-shrink: 0;
  margin: 56px 18px 18px;
  cursor: crosshair;
  transition: width 220ms cubic-bezier(.2,.75,.25,1), height 220ms cubic-bezier(.2,.75,.25,1), filter 260ms ease;
  touch-action: none;
}
#local-svg .entity { cursor: pointer; }
#local-svg .entity:hover text { filter: brightness(1.4); }
#local-svg text { user-select: none; pointer-events: none; }
#local-svg .entity text { pointer-events: auto; }

.topbar button { pointer-events: auto; }

/* --- Overlays --- */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(to bottom, rgba(22, 19, 15, 0.92), rgba(22, 19, 15, 0));
  pointer-events: none;
  z-index: 5;
}
.topbar h1 { margin: 0; }
.topbar .muted { font-size: 13px; }
.connection-live { color: var(--ok); font-size: 11px; animation: live-pulse 2.2s ease-in-out infinite; }
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding: 2px;
  pointer-events: auto;
  border: 1px solid rgba(74, 64, 51, .72);
  border-radius: 999px;
  background: rgba(24, 20, 16, .8);
}
.zoom-controls button { width: 27px; height: 24px; padding: 0; margin: 0; border: 0; border-radius: 999px; font-size: 17px; }
#map-level { min-width: 42px; color: var(--accent); font-size: 10px; text-align: center; text-transform: uppercase; letter-spacing: .06em; }
#zoom-label { min-width: 34px; color: var(--dim); font-size: 10px; text-align: center; }
#zoom-hint {
  position: absolute;
  top: 45px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  color: rgba(216, 207, 192, .42);
  font-size: 9px;
  letter-spacing: .04em;
  pointer-events: none;
}

.floating {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  z-index: 10;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

#hud {
  left: 12px;
  bottom: 12px;
  width: 258px;
}
#hud .bars { font-size: 13px; }
#hud .bars b { color: var(--text); }
#hud .task-current { color: var(--accent); }
#hud .hud-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-top: 8px; }
#hud .hud-buttons button { min-width: 0; margin: 0; padding: 5px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#side-panel {
  right: 12px;
  top: 52px;
  width: 390px;
}

.panel-close { float: right; margin: -4px -4px 0 0; }

.context-menu {
  position: fixed;
  z-index: 45;
  width: min(270px, calc(100vw - 20px));
  padding: 9px;
  border: 1px solid #66543c;
  border-radius: 7px;
  background: rgba(25, 21, 17, .97);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .62), 0 0 0 1px rgba(169, 151, 111, .08) inset;
  animation: context-in 160ms cubic-bezier(.2,.8,.2,1) both;
}
.context-close { float: right; width: 22px; height: 22px; margin: -3px -3px 0 4px; padding: 0; border: 0; color: var(--dim); }
.context-title { color: #cabfa0; font-weight: 700; }
.context-meta { margin: 3px 0 7px; color: var(--dim); font-size: 10px; line-height: 1.4; }
.context-note { margin: 6px 0; padding: 5px 6px; color: #b8dc78; border-left: 2px solid var(--ok); background: rgba(123, 160, 91, .08); font-size: 10px; }
.context-actions { display: grid; gap: 3px; }
.context-actions button { display: flex; justify-content: space-between; align-items: center; width: 100%; margin: 0; text-align: left; }
.context-actions button small { color: var(--dim); font-size: 9px; }

.death-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 38%, rgba(97, 39, 32, .28), rgba(10, 8, 7, .96) 58%), #0b0908;
  backdrop-filter: blur(7px) grayscale(.7);
}
.death-card {
  width: min(470px, 100%);
  padding: 28px;
  text-align: center;
  border: 1px solid rgba(192, 86, 76, .55);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(43, 28, 24, .96), rgba(19, 16, 14, .98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .75);
  animation: death-screen-in 700ms cubic-bezier(.16,.8,.25,1) both;
}
.death-skull { font-size: 58px; filter: grayscale(.35) drop-shadow(0 8px 13px rgba(0, 0, 0, .65)); animation: death-skull 700ms ease-out both; }
.death-kicker { margin-top: 8px; color: var(--danger); font-size: 9px; letter-spacing: .24em; }
.death-card h2 { margin: 7px 0 4px; color: #e5d8c6; font-family: Georgia, serif; font-size: 27px; font-weight: 400; }
.death-card p { color: #b4a394; }
#death-log { margin: 18px 0; padding: 8px 10px; max-height: 150px; overflow: hidden; text-align: left; background: rgba(11, 9, 8, .48); border-radius: 5px; font-size: 10px; }
#death-log div { padding: 3px 0; border-bottom: 1px dotted rgba(80, 66, 55, .45); }
#death-log span { display: inline-block; min-width: 56px; color: var(--dim); }
.death-card > button { min-width: 220px; padding: 9px 14px; border-color: #8a6845; color: #cabfa0; }
.is-dead .entity, .is-dead #combat-links *, .is-dead .connection-live, .is-dead .statbar-fill, .is-dead .action-ind, .is-dead .mine-ring, .is-dead .other-player-ring {
  animation: none !important;
  transition: none !important;
}

#feed-list { font-size: 13px; }
#feed-list div { padding: 1px 0; border-bottom: 1px dotted #2a251e; }
#feed-list .tick { color: var(--dim); margin-right: 6px; }

.world-intro { color: #b9ab98; font-size: 12px; line-height: 1.55; }
.goal-list { display: grid; gap: 4px; margin: 10px 0; }
.goal {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 5px;
  padding: 6px;
  border: 1px solid #332c24;
  border-radius: 5px;
  background: rgba(16, 13, 10, .42);
}
.goal > span { color: var(--dim); font-size: 15px; }
.goal b { display: block; font-size: 12px; }
.goal small { display: block; color: var(--dim); font-size: 10px; line-height: 1.35; margin-top: 2px; }
.goal.done { border-color: rgba(123, 160, 91, .35); opacity: .72; }
.goal.done > span, .goal.done b { color: var(--ok); }
.next-step { margin-top: 9px; padding: 8px; border-left: 2px solid var(--accent); background: rgba(169, 151, 111, .08); font-size: 11px; }
.next-step.complete { border-color: var(--ok); color: #b8dc78; }
.ownership { margin: 8px 0; padding: 6px; color: #b8dc78; background: rgba(123, 160, 91, .09); border-left: 2px solid var(--ok); font-size: 10px; }
.gift-list { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.gift-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 10px; }

/* --- Grid inventory and crafting --- */

.inventory-help { margin: -3px 0 8px; color: var(--dim); font-size: 9px; }
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid #40362c;
  border-radius: 6px;
  background: #13100d;
}
.inventory-slot {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #342d25;
  border-radius: 3px;
  background: linear-gradient(135deg, rgba(50, 43, 35, .45), rgba(21, 18, 15, .7));
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.inventory-slot::after { content: ""; position: absolute; inset: 2px; pointer-events: none; border: 1px solid rgba(255,255,255,.018); }
.inventory-slot.selected { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(169, 151, 111, .22) inset; }
.inventory-slot.drop-target { border-color: #b8dc78; background: rgba(123, 160, 91, .18); transform: scale(.97); }
.slot-number { position: absolute; top: 3px; left: 4px; color: rgba(141, 130, 113, .23); font-size: 8px; }
.inventory-item {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 4px;
  cursor: grab;
  user-select: none;
}
.inventory-item:active { cursor: grabbing; }
.inventory-item.dragging { opacity: .35; filter: grayscale(.7); }
.inventory-emoji { align-self: end; font-size: 25px; filter: drop-shadow(0 4px 3px rgba(0,0,0,.42)); }
.inventory-quality { position: absolute; top: 2px; right: 3px; color: #8fb1bd; font-size: 7px; }
.inventory-name { width: 100%; overflow: hidden; color: #b9ad9c; font-size: 8px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.item-inspector {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 6px 0 3px;
  padding: 6px 7px;
  border: 1px solid #3b3229;
  border-radius: 5px;
  background: rgba(19, 16, 13, .66);
}
.item-inspector.empty { justify-content: center; color: var(--dim); font-size: 9px; }
.item-inspector-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.item-inspector-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-inspector-name span { color: var(--dim); font-size: 8px; white-space: nowrap; }
.item-inspector button { padding: 3px 6px; font-size: 8px; }
.inventory-section-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 7px; }
.inventory-section-head h3 { margin: 0 0 4px; }
.inventory-section-head span { color: var(--dim); font-size: 8px; }
.recipe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.recipe-card { display: grid; grid-template-columns: 25px 1fr; gap: 4px; align-items: center; min-width: 0; margin: 0; padding: 5px; text-align: left; }
.recipe-card span:last-child { min-width: 0; }
.recipe-card b, .recipe-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-card b { font-size: 9px; }
.recipe-card small { color: var(--dim); font-size: 7px; }
.recipe-emoji { font-size: 19px; }
.queue-details, .skills-details { margin-top: 7px; color: var(--dim); font-size: 9px; }
.queue-details summary, .skills-details summary { cursor: pointer; color: #aa9c89; }
.queue-details > div { margin: 4px 0; padding: 4px; background: rgba(17,14,12,.55); }
.skill-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.skill-chips span { padding: 2px 4px; border: 1px solid #3a3229; border-radius: 999px; }

.chat-help { color: var(--dim); font-size: 10px; line-height: 1.4; }
#chat-list {
  display: grid;
  gap: 5px;
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 3px;
}
.chat-entry { padding: 6px 7px; border-radius: 5px; background: rgba(18, 15, 12, .72); border-left: 2px solid #4c7280; }
.chat-entry.mine { border-left-color: var(--accent); background: rgba(169, 151, 111, .07); }
.chat-meta { display: flex; justify-content: space-between; gap: 8px; color: #8fc9df; font-size: 10px; }
.chat-entry.mine .chat-meta { color: #cabfa0; }
.chat-meta span { color: var(--dim); font-size: 9px; }
.chat-text { margin: 3px 0; overflow-wrap: anywhere; }
.chat-coord { padding: 1px 5px; margin: 0; color: var(--dim); font-size: 9px; }
#chat-form { display: grid; grid-template-columns: 1fr auto; gap: 4px; margin-top: 8px; }
#chat-form input { min-width: 0; width: 100%; }

/* --- Motion and action feedback --- */

#map g.hex { animation: hex-in 360ms ease-out both; }
#map g.own-hex polygon { animation: own-hex-pulse 2.2s ease-in-out infinite; }
#map.view-enter, #local-wrap.view-enter { animation: view-enter 420ms ease-out both; }

#local-svg .entity {
  transition: transform 540ms cubic-bezier(.2,.75,.25,1), opacity 360ms ease, filter 240ms ease;
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}
#local-svg .entity.pop-in { animation: entity-in 420ms cubic-bezier(.2,.8,.2,1) both; }
#local-svg .entity.fade-out { pointer-events: none; opacity: 0; filter: grayscale(1) blur(2px); }
#local-svg .entity.effect-hit > text { animation: entity-hit 460ms ease-out both; }
#local-svg .entity.effect-success > text { animation: entity-success 640ms ease-out both; }
#local-svg .entity.effect-death > text { animation: entity-death 700ms ease-in both; }

.building-rect {
  fill: rgba(35, 29, 22, 0.62);
  stroke: #8a7454;
  stroke-width: 1;
}
#placement-preview rect {
  fill: rgba(169, 151, 111, .16);
  stroke: #cabfa0;
  stroke-width: 1.4;
  stroke-dasharray: 3 2;
  animation: placement-pulse 850ms ease-in-out infinite;
}
#placement-preview text {
  fill: #f7df9b;
  font-size: 8px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #1b1510;
  stroke-width: 2px;
}
#placement-preview.invalid rect { fill: rgba(192, 86, 76, .2); stroke: #c98a80; }
#placement-preview.invalid text { fill: #ff9188; }
#placement-preview.active-build rect { fill: rgba(123, 160, 91, .13); stroke: #b8dc78; }
#placement-preview.active-build text { fill: #d7efaa; }
.mine-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-dasharray: 3 2;
  opacity: 0.75;
  animation: ring-spin 5s linear infinite;
  transform-origin: 8px 8px;
}
.other-player-ring {
  fill: rgba(99, 164, 190, 0.08);
  stroke: #63a4be;
  stroke-width: 1.2;
  stroke-dasharray: 2 1.5;
  animation: other-player-pulse 1.8s ease-in-out infinite;
}

.npc-ring {
  fill: rgba(220, 180, 86, 0.1);
  stroke: #dcb456;
  stroke-width: 1.2;
  stroke-dasharray: 2 1.5;
}
.player-name {
  font-size: 6px;
  font-weight: 700;
  letter-spacing: -0.15px;
  paint-order: stroke;
  stroke: rgba(20, 16, 12, 0.96);
  stroke-width: 2px;
  stroke-linejoin: round;
  pointer-events: none !important;
}
.player-name.my-name { fill: #cabfa0; }
.player-name.other-name { fill: #8fc9df; }
.player-name.npc-name { fill: #e3be69; }

.squad-bar {
  position: fixed;
  top: 48px;
  left: 50%;
  z-index: 20;
  display: flex;
  gap: 6px;
  max-width: min(70vw, 820px);
  transform: translateX(-50%);
  overflow-x: auto;
  padding: 4px;
}

.squad-member {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 6px;
  min-width: 112px;
  padding: 5px 8px;
  border-color: #4b4539;
  background: rgba(24, 21, 17, 0.9);
  text-align: left;
}

.squad-member > span { grid-row: 1 / 3; align-self: center; font-size: 18px; }
.squad-member b { font-size: 11px; white-space: nowrap; }
.squad-member small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.squad-member.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(218, 180, 80, 0.3); }
.squad-member.captive { border-color: #9d7253; filter: saturate(0.72); }

.market-board { display: grid; gap: 8px; margin: 9px 0; min-width: min(420px, 78vw); }
.market-summary { display: flex; justify-content: space-between; gap: 12px; }
.market-summary span, .market-offer small, .market-listing > span { color: var(--muted); font-size: 10px; }
.market-tools { display: grid; gap: 6px; }
.market-tools .search-field { width: 100%; }
.market-offers { display: grid; gap: 5px; max-height: 260px; overflow-y: auto; }
.market-offer { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; padding: 7px; border: 1px solid #403a31; background: rgba(0,0,0,.18); }
.market-offer > div { display: flex; flex-direction: column; }
.market-offer button { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.market-offer.mine { border-color: #8b7440; }
.market-listing { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 7px; border-top: 1px solid #403a31; }
.market-listing > b, .market-listing > span { grid-column: 1 / -1; }
.market-listing label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.market-listing button { grid-column: 1 / -1; }
.market-listing select, .market-listing input { min-width: 0; width: 100%; }

.tile-stack {
  display: grid;
  gap: 5px;
  margin: 9px 0;
  padding: 7px;
  border: 1px solid #4a4236;
  background: rgba(0, 0, 0, 0.18);
}

.tile-stack-head { display: flex; justify-content: space-between; gap: 12px; }
.tile-stack-head span { color: var(--muted); font-size: 10px; }
.tile-stack-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
.tile-stack-row.active { outline: 1px solid rgba(218, 180, 80, 0.55); border-radius: 3px; }
.tile-stack-entity { display: grid; grid-template-columns: auto 1fr; gap: 0 6px; text-align: left; }
.tile-stack-entity > span { grid-row: 1 / 3; align-self: center; font-size: 18px; }
.tile-stack-entity b, .tile-stack-entity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-stack-entity small { color: var(--muted); font-size: 9px; }
.sel-ring {
  fill: rgba(169, 151, 111, 0.12);
  stroke: #cabfa0;
  stroke-width: 1.2;
  animation: selection-pulse 1.15s ease-in-out infinite;
}
.hpbar-bg { fill: rgba(13, 10, 8, 0.9); }
.hpbar-fill { transition: width 340ms ease, fill 340ms ease; }
.action-ind {
  paint-order: stroke;
  stroke: #19140f;
  stroke-width: 2.5px;
  animation: action-bob 900ms ease-in-out infinite;
}
.work-progress { fill: var(--accent); transition: width 420ms linear; }
.work-progress.indeterminate { animation: work-pulse 900ms ease-in-out infinite; }

#combat-links line {
  stroke: #d8a94e;
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  animation: combat-dash 500ms linear infinite;
}
#combat-link-icon {
  font-size: 11px;
  paint-order: stroke;
  stroke: #241b12;
  stroke-width: 2px;
  animation: sword-clash 620ms ease-in-out infinite alternate;
}
.combat-attacker > text { animation: attacker-lunge 620ms ease-in-out infinite alternate; transform-origin: center; }
.combat-target > text { filter: drop-shadow(0 0 3px rgba(192, 86, 76, .8)); }

#fx .fx {
  font-size: 11px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #18120e;
  stroke-width: 3px;
  animation: float-effect 1.45s cubic-bezier(.15,.75,.25,1) both;
}
#fx .fx-hit, #fx .fx-death, #fx .fx-fail { fill: #c98a80; }
#fx .fx-miss { fill: #c4b8a7; font-style: italic; }
#fx .fx-gain, #fx .fx-complete { fill: #b8dc78; }
#fx .fx-drop { fill: #d7b773; }
#fx .fx-start { fill: #cabfa0; }

.floating { animation: panel-in 220ms ease-out both; }
#hud-title .muted { display: block; margin-top: 2px; font-size: 11px; font-weight: normal; }

.statbar {
  display: grid;
  grid-template-columns: 22px 1fr 36px;
  gap: 5px;
  align-items: center;
  margin: 4px 0;
}
.statbar-track {
  height: 7px;
  overflow: hidden;
  background: #12100d;
  border: 1px solid #40372c;
  border-radius: 999px;
}
.statbar-fill {
  width: 0;
  height: 100%;
  background: var(--ok);
  border-radius: inherit;
  transition: width 480ms ease, background 240ms ease;
}
.statbar.hunger .statbar-fill { background: #c49b51; }
.statbar.energy .statbar-fill { background: #6f94a8; }
.statbar-fill.danger-fill { background: var(--danger) !important; animation: danger-pulse 800ms ease-in-out infinite; }
.statbar-num { color: var(--dim); font-size: 11px; text-align: right; }

#hud-task {
  min-height: 22px;
  margin-top: 8px;
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(18, 15, 12, 0.55);
}
#hud-task.task-changed { animation: task-changed 680ms ease-out; }
.task-progress {
  height: 4px;
  margin: 4px 0 2px;
  overflow: hidden;
  border-radius: 999px;
  background: #14110e;
}
#task-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b7136, var(--accent), #cabfa0);
  transition: width 420ms linear;
}
.task-progress.indeterminate #task-progress-fill { animation: indeterminate 1.15s ease-in-out infinite; }

#combat-panel {
  right: 12px;
  bottom: 12px;
  width: 370px;
  border-color: rgba(192, 86, 76, 0.72);
  background: linear-gradient(145deg, rgba(50, 29, 24, .97), rgba(28, 24, 20, .97));
}
#combat-panel.combat-impact { animation: combat-panel-hit 400ms ease-out; }
.combat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.combatant { min-width: 0; }
.combatant > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.combat-hp-text { color: var(--dim); font-size: 10px; }
.combat-swords { text-align: center; font-size: 20px; animation: combat-swords 700ms ease-in-out infinite alternate; }
.hpfill { background: var(--danger); }
#combat-log {
  margin: 9px 0;
  padding: 6px;
  max-height: 104px;
  overflow: hidden;
  color: #bea994;
  font-size: 11px;
  background: rgba(14, 11, 9, .52);
  border-radius: 4px;
}
#combat-log > div { animation: log-entry 300ms ease-out both; }
#combat-log .tick, .tick { color: var(--dim); margin-right: 6px; }

.hex-toast, .action-toast {
  position: absolute;
  left: 50%;
  z-index: 30;
  pointer-events: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(24, 20, 16, .95);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .55);
  opacity: 0;
}
.hex-toast {
  top: 22%;
  padding: 12px 22px;
  color: #cabfa0;
  font-size: 16px;
}
.hex-toast.show { animation: hex-toast 2.15s ease-in-out both; }
.action-toast {
  bottom: 18px;
  padding: 7px 14px;
  color: var(--text);
  font-size: 12px;
}
.action-toast.show { animation: action-toast 1.55s ease-out both; }
#local-wrap.hex-arrival::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle, transparent 30%, rgba(169, 151, 111, .14));
  animation: arrival-flash 1.05s ease-out both;
}

.zoom-transition {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle, rgba(169, 151, 111, .07), rgba(10, 8, 7, .88));
}
.zoom-rings, .zoom-rings::before, .zoom-rings::after {
  position: absolute;
  width: 32vmin;
  aspect-ratio: 1;
  border: 1px solid rgba(241, 215, 134, .22);
  border-radius: 50%;
  content: "";
}
.zoom-rings::before { inset: -28%; width: 156%; }
.zoom-rings::after { inset: -58%; width: 216%; }
.zoom-transition-card { position: relative; display: grid; place-items: center; gap: 3px; color: #cabfa0; text-align: center; text-shadow: 0 3px 12px #000; }
.zoom-transition-card span { font-size: 44px; }
.zoom-transition-card b { font-family: Georgia, serif; font-size: 22px; font-weight: 400; }
.zoom-transition-card small { color: #a99b88; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }
.zoom-transition.zoom-in { animation: zoom-curtain-in 740ms ease-in-out both; }
.zoom-transition.zoom-out { animation: zoom-curtain-out 740ms ease-in-out both; }
.zoom-transition.zoom-in .zoom-rings { animation: rings-in 740ms ease-in both; }
.zoom-transition.zoom-out .zoom-rings { animation: rings-out 740ms ease-out both; }

@keyframes login-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(5px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes view-enter { from { opacity: .35; filter: blur(2px); } to { opacity: 1; filter: none; } }
@keyframes context-in { from { opacity: 0; transform: translateY(-3px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes hex-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes own-hex-pulse { 0%, 100% { stroke-opacity: .65; } 50% { stroke-opacity: 1; filter: brightness(1.18); } }
@keyframes entity-in { from { opacity: 0; filter: blur(3px) brightness(1.6); } to { opacity: 1; filter: none; } }
@keyframes entity-hit { 0%, 100% { transform: translateX(0); filter: none; } 22% { transform: translateX(-2px); filter: brightness(2) sepia(1) saturate(4); } 48% { transform: translateX(2px); } 70% { transform: translateX(-1px); } }
@keyframes entity-success { 0% { transform: scale(1); } 38% { transform: scale(1.35); filter: brightness(1.7); } 100% { transform: scale(1); filter: none; } }
@keyframes entity-death { to { opacity: .1; transform: rotate(55deg) scale(.55); filter: grayscale(1); } }
@keyframes placement-pulse { 50% { fill-opacity: .46; stroke-dashoffset: -5; } }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes other-player-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; filter: drop-shadow(0 0 2px #63a4be); } }
@keyframes selection-pulse { 0%, 100% { opacity: .48; } 50% { opacity: 1; } }
@keyframes action-bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-2px) rotate(4deg); } }
@keyframes work-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes combat-dash { to { stroke-dashoffset: -6; } }
@keyframes sword-clash { from { transform: scale(.88) rotate(-8deg); } to { transform: scale(1.12) rotate(8deg); } }
@keyframes attacker-lunge { from { transform: translate(0, 0) rotate(-2deg); } to { transform: translate(1px, -1px) rotate(4deg); filter: brightness(1.25); } }
@keyframes float-effect { 0% { opacity: 0; transform: translateY(3px) scale(.8); } 18% { opacity: 1; transform: translateY(-3px) scale(1.1); } 76% { opacity: 1; } 100% { opacity: 0; transform: translateY(-19px) scale(.92); } }
@keyframes danger-pulse { 50% { filter: brightness(1.45); } }
@keyframes live-pulse { 50% { opacity: .55; } }
@keyframes task-changed { 0% { background: rgba(169, 151, 111, .38); transform: translateX(-3px); } 100% { background: rgba(18, 15, 12, .55); transform: none; } }
@keyframes indeterminate { from { transform: translateX(-130%); } to { transform: translateX(360%); } }
@keyframes combat-panel-hit { 25% { transform: translateX(-3px); border-color: #c98a80; } 55% { transform: translateX(2px); } }
@keyframes combat-swords { from { transform: rotate(-7deg) scale(.92); } to { transform: rotate(7deg) scale(1.08); } }
@keyframes log-entry { from { opacity: 0; transform: translateX(4px); } to { opacity: 1; transform: none; } }
@keyframes death-screen-in { from { opacity: 0; transform: translateY(14px) scale(.96); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes death-skull { from { opacity: 0; transform: translateY(-18px) rotate(-12deg) scale(1.35); } to { opacity: 1; transform: none; } }
@keyframes zoom-curtain-in { 0% { opacity: 0; backdrop-filter: blur(0); } 38%, 65% { opacity: 1; backdrop-filter: blur(8px); } 100% { opacity: 0; backdrop-filter: blur(0); } }
@keyframes zoom-curtain-out { 0% { opacity: 0; backdrop-filter: blur(0); } 32%, 66% { opacity: 1; backdrop-filter: blur(7px); } 100% { opacity: 0; backdrop-filter: blur(0); } }
@keyframes rings-in { from { transform: scale(3.8); opacity: 0; } 45% { opacity: 1; } to { transform: scale(.18); opacity: 0; } }
@keyframes rings-out { from { transform: scale(.12); opacity: 0; } 45% { opacity: 1; } to { transform: scale(4.1); opacity: 0; } }
@keyframes hex-toast { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.94); } 15%, 70% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -10px) scale(1.02); } }
@keyframes action-toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 18%, 70% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -5px); } }
@keyframes arrival-flash { from { opacity: 1; } to { opacity: 0; } }

/* --- Responsive game shell --- */

:root {
  --nav-size: 58px;
  --dock-width: 410px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --muted: var(--dim);
}

html, body, #app { height: 100dvh; }
body { overscroll-behavior: none; }
#app { min-height: 100dvh; isolation: isolate; }
#game-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
#app.is-panning #game-viewport { cursor: grabbing; }
#local-wrap { overflow: hidden; touch-action: none; }
#local-svg { margin: 0; transform-origin: center; }
#app.is-panning #local-svg, #app.is-panning #map { transition: none !important; }

.topbar {
  top: calc(10px + var(--safe-top));
  right: calc(82px + var(--safe-right));
  left: calc(12px + var(--safe-left));
  min-height: 44px;
  gap: 10px;
  padding: 0;
  background: none;
}
.topbar .brand, .location-label, .session-meta {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid rgba(75, 65, 52, .72);
  border-radius: 999px;
  background: rgba(24, 20, 16, .84);
  box-shadow: 0 5px 20px rgba(0, 0, 0, .25);
  backdrop-filter: blur(10px);
}
.topbar .brand { color: var(--accent); pointer-events: auto; }
.location-label { min-width: 0; overflow: hidden; color: #bdb2a2; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { color: var(--dim); font-size: 10px; }
.zoom-controls { min-height: 40px; padding: 2px 4px; backdrop-filter: blur(10px); }
.zoom-controls button { width: 38px; height: 36px; }
#zoom-hint { top: calc(58px + var(--safe-top)); }

.floating, .dock-surface {
  border-color: rgba(87, 74, 58, .85);
  background: linear-gradient(155deg, rgba(34, 29, 23, .97), rgba(22, 19, 15, .98));
  box-shadow: 0 18px 52px rgba(0, 0, 0, .58), 0 0 0 1px rgba(255,255,255,.018) inset;
  backdrop-filter: blur(14px);
}

#hud {
  left: calc(14px + var(--safe-left));
  bottom: calc(14px + var(--safe-bottom));
  width: 302px;
  max-height: none;
  overflow: visible;
  padding: 12px;
}
.status-heading { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: start; }
.status-heading h2 { margin: 0; }
.status-heading .icon-button { width: 44px; height: 44px; margin: -5px -5px 0 0; padding: 0; }
.status-vitals { margin-top: 8px; }

#primary-nav {
  position: fixed;
  z-index: 42;
  top: 50%;
  right: calc(12px + var(--safe-right));
  display: grid;
  gap: 5px;
  width: var(--nav-size);
  padding: 5px;
  transform: translateY(-50%);
  border: 1px solid rgba(75, 65, 52, .78);
  border-radius: 13px;
  background: rgba(22, 19, 15, .9);
  box-shadow: 0 12px 38px rgba(0,0,0,.46);
  backdrop-filter: blur(13px);
}
#primary-nav button {
  display: grid;
  place-items: center;
  gap: 1px;
  width: 46px;
  min-height: 46px;
  margin: 0;
  padding: 3px;
  border-color: transparent;
}
#primary-nav button > span { font-size: 18px; line-height: 1; }
#primary-nav button > small { max-width: 42px; overflow: hidden; color: var(--dim); font-size: 7px; text-overflow: ellipsis; }
#primary-nav button.active, #primary-nav button.tool-active { color: #cabfa0; border-color: #8b713c; background: rgba(169, 151, 111, .13); }

#side-panel, .context-menu {
  position: fixed;
  z-index: 40;
  top: calc(64px + var(--safe-top));
  right: calc(82px + var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  width: min(var(--dock-width), calc(100vw - 112px));
  max-height: none;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
}
.context-menu { animation: panel-in 180ms ease-out both; }
.panel-heading { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px; align-items: start; margin-bottom: 12px; }
.panel-heading > div { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; min-width: 0; }
.panel-heading .panel-kicker { grid-row: 1 / 3; font-size: 25px; }
.panel-heading h2 { margin: 0; color: #cabfa0; font-size: 16px; }
.panel-heading small { overflow: hidden; color: var(--dim); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.panel-close { float: none; width: 44px; height: 44px; margin: -6px -6px 0 0; padding: 0; }
.context-close { width: 44px; height: 44px; margin: -7px -7px 2px 6px; }
.context-title { padding-top: 6px; font-size: 15px; }
.context-meta { font-size: 11px; }
.context-actions button, .inspector-actions button { min-height: 44px; }
.context-menu .market-board { min-width: 0; }
.blueprint-cost { padding: 8px; color: var(--dim); font-size: 10px; border: 1px solid #40372d; border-radius: 6px; }
button.primary { border-color: #8b713c; color: #cabfa0; background: rgba(169, 151, 111,.12); }

.catalog-tools { position: sticky; top: -14px; z-index: 2; margin: 0 -2px 10px; padding: 10px 2px 6px; background: linear-gradient(var(--panel) 80%, transparent); }
.search-field { display: grid; grid-template-columns: 28px 1fr; align-items: center; min-height: 44px; border: 1px solid #493e31; border-radius: 8px; background: #15120f; }
.search-field > span { color: var(--dim); text-align: center; font-size: 18px; }
.search-field input { width: 100%; height: 42px; padding-left: 0; border: 0; background: transparent; outline: 0; }
.filter-row { display: flex; gap: 5px; margin-top: 7px; overflow-x: auto; scrollbar-width: none; }
.filter-chip { min-height: 34px; margin: 0; padding: 5px 10px; border-radius: 999px; color: var(--dim); font-size: 10px; white-space: nowrap; }
.filter-chip.active { color: #cabfa0; border-color: #8b713c; background: rgba(169, 151, 111,.12); }
.catalog-list { display: grid; gap: 6px; }
.catalog-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 7px 9px;
  text-align: left;
}
.catalog-card span:nth-child(2) { min-width: 0; }
.catalog-card b, .catalog-card small, .catalog-card em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-card b { font-size: 11px; }
.catalog-card small { color: #b8ab98; font-size: 9px; }
.catalog-card em { color: var(--dim); font-size: 8px; font-style: normal; }
.catalog-card .availability { color: var(--accent); font-size: 9px; }
.catalog-card.selected { border-color: var(--accent); background: rgba(169, 151, 111,.1); }
.page-controls { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; color: var(--dim); }
.page-controls button { width: 44px; height: 40px; }
.empty-state { padding: 20px 12px; color: var(--dim); text-align: center; border: 1px dashed #44392d; border-radius: 8px; }
.active-blueprint { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; padding: 8px; border: 1px solid #796438; border-radius: 8px; background: rgba(169, 151, 111,.08); }
.active-blueprint > span { font-size: 24px; }
.active-blueprint small { display: block; color: var(--dim); font-size: 9px; }
.active-blueprint button { min-height: 40px; }

.inventory-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.inventory-slot { min-height: 58px; }
.item-inspector { display: grid; align-items: stretch; margin-top: 10px; }
.item-inspector-name { display: grid; grid-template-columns: 38px 1fr; }
.item-inspector-name .item-icon { grid-row: 1; font-size: 26px; }
.item-inspector-name div { min-width: 0; }
.item-inspector-name b, .item-inspector-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-inspector-name small { color: var(--dim); font-size: 9px; }
.inspector-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }

.equipment-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 9px; }
.equipment-summary span { padding: 7px 4px; color: #cdbd9f; text-align: center; border: 1px solid #40372d; border-radius: 6px; background: rgba(0,0,0,.15); font-size: 9px; }
.equipment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.equipment-slot { display: grid; grid-template-columns: 34px minmax(0,1fr) 38px; gap: 7px; align-items: center; min-height: 54px; padding: 6px; border: 1px solid #40372d; border-radius: 7px; background: rgba(0,0,0,.16); }
.equipment-slot .slot-icon { font-size: 22px; text-align: center; }
.equipment-slot small, .equipment-slot b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equipment-slot small { color: var(--dim); font-size: 8px; }
.equipment-slot b { font-size: 10px; }
.equipment-slot button { width: 38px; height: 38px; margin: 0; padding: 0; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.style-button { min-height: 44px; margin: 0; text-transform: capitalize; }
.style-button.active { color: #cabfa0; border-color: var(--accent); background: rgba(169, 151, 111,.11); }
.pack-equipment-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.pack-equipment { display: grid; grid-template-columns: 32px 1fr; gap: 0 6px; min-height: 48px; margin: 0; text-align: left; }
.pack-equipment > span { grid-row: 1 / 3; align-self: center; font-size: 20px; }
.pack-equipment b, .pack-equipment small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-equipment small { color: var(--dim); font-size: 8px; }

#combat-panel {
  top: auto;
  right: auto;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  width: min(480px, calc(100vw - 360px));
  padding: 9px;
  transform: translateX(-50%);
  border-color: rgba(143, 83, 63, .72);
  animation: none;
}
.combat-row { grid-template-columns: minmax(0,1fr) 24px minmax(0,1fr) 44px; gap: 7px; }
.combat-state { color: var(--danger); text-align: center; }
.combat-break { width: 44px; height: 40px; margin: 0; padding: 0; }
#combat-panel details { margin-top: 5px; color: var(--dim); font-size: 9px; }
#combat-log { max-height: 76px; margin: 5px 0 0; }
#combat-links line { animation: none; opacity: .42; stroke-dasharray: none; }
#combat-link-icon, .combat-attacker > text, .combat-state { animation: none !important; }
#combat-panel.combat-impact { animation: none !important; }
#local-svg .entity.effect-hit > text { animation: none !important; filter: brightness(1.55) saturate(1.25); }

.squad-bar { top: calc(58px + var(--safe-top)); max-width: min(55vw, 720px); }

@media (max-width: 760px) {
  :root { --nav-height: 68px; }
  input, select, textarea { font-size: 16px; }
  .login-wrap { justify-content: flex-start; gap: 16px; overflow-y: auto; padding-top: max(34px, var(--safe-top)); }
  .login-card { padding: 22px 18px; }
  .topbar {
    top: var(--safe-top);
    right: calc(6px + var(--safe-right));
    left: calc(6px + var(--safe-left));
    gap: 5px;
    min-height: 50px;
  }
  .topbar .brand, .session-meta { display: none; }
  .location-label { flex: 1; min-width: 0; height: 42px; padding: 0 9px; font-size: 10px; }
  .zoom-controls { flex: 0 0 auto; height: 42px; margin: 0; }
  .zoom-controls button { width: 36px; height: 36px; }
  #zoom-label { display: none; }
  #zoom-hint { display: none; }

  #hud {
    top: calc(54px + var(--safe-top));
    right: calc(6px + var(--safe-right));
    bottom: auto;
    left: calc(6px + var(--safe-left));
    width: auto;
    padding: 7px 8px;
    border-radius: 10px;
  }
  .status-heading { grid-template-columns: minmax(0,1fr) 40px; }
  .status-heading .icon-button { width: 40px; height: 40px; }
  #hud-title { font-size: 11px; }
  #hud-title .muted { display: inline; margin-left: 5px; font-size: 8px; }
  .status-vitals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 4px; }
  .statbar { grid-template-columns: 17px 1fr 24px; gap: 2px; margin: 1px 0; }
  .statbar-num { font-size: 8px; }
  #hud-task { min-height: 18px; margin-top: 4px; padding: 2px 4px; overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  .task-progress { margin-bottom: 0; }
  .squad-bar { top: calc(157px + var(--safe-top)); max-width: calc(100vw - 12px); gap: 3px; padding: 2px; }
  .squad-member { min-width: 96px; padding: 3px 6px; }

  #primary-nav {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    gap: 2px;
    width: auto;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding: 5px max(6px, var(--safe-right)) var(--safe-bottom) max(6px, var(--safe-left));
    transform: none;
    overflow-x: auto;
    border-width: 1px 0 0;
    border-radius: 0;
    scrollbar-width: none;
  }
  #primary-nav button { flex: 1 0 54px; width: auto; min-height: 52px; }
  #primary-nav button > span { font-size: 19px; }
  #primary-nav button > small { font-size: 8px; }

  #side-panel, .context-menu {
    top: auto;
    right: max(6px, var(--safe-right));
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 6px);
    left: max(6px, var(--safe-left));
    width: auto;
    max-height: min(72dvh, calc(100dvh - var(--nav-height) - var(--safe-top) - 72px));
    padding: 12px;
    border-radius: 14px 14px 9px 9px;
  }
  .panel-heading { position: sticky; top: -12px; z-index: 4; margin: -12px -4px 9px; padding: 10px 4px 7px; background: rgba(31,26,21,.98); }
  .catalog-tools { top: 51px; }
  .context-menu { max-height: 58dvh; }
  .context-actions button, .inspector-actions button, #side-panel > button { min-height: 44px; }
  .inventory-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .inventory-slot { min-height: 60px; }
  .equipment-grid, .pack-equipment-list { grid-template-columns: 1fr; }
  .catalog-card { min-height: 62px; }
  .market-offer { grid-template-columns: 1fr; }
  .market-offer button { grid-column: 1; grid-row: auto; min-height: 44px; }

  #combat-panel {
    right: 6px;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 6px);
    left: 6px;
    width: auto;
    transform: none;
  }
  #combat-panel details { display: none; }
  .combat-row { grid-template-columns: minmax(0,1fr) 18px minmax(0,1fr) 40px; }
  .combat-break { width: 40px; }
  .hex-toast { top: 38%; max-width: calc(100vw - 24px); font-size: 13px; text-align: center; }
  .action-toast { bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px); }
}

@media (max-width: 390px) {
  .squad-bar { display: none; }
  .session-meta { display: none; }
  .equipment-summary { grid-template-columns: 1fr 1fr; }
}

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