:root {
  --bg: #0b100c;
  --panel: #121a14;
  --ink: #d7e0d4;
  --muted: #8a9a88;
  --accent: #6f9e4a;
  --danger: #b33a2e;
  --line: #243026;
  --font-display: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 50% 20%, #182218 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--font-display);
  overflow: hidden;
}

body.boot-open {
  overflow: auto;
  height: auto;
  min-height: 100%;
  min-height: 100dvh;
}

.hidden { display: none !important; }

#boot {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.boot-panel {
  width: min(440px, 100%);
  background: linear-gradient(180deg, #172117, var(--panel));
  border: 1px solid var(--line);
  padding: 28px 24px 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  flex: 0 0 auto;
}

.boot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.boot-heading {
  min-width: 0;
  flex: 1;
}

.boot-heading h1 {
  margin: 0 0 4px;
}

.boot-heading .tag {
  margin: 0;
}

.boot-fs-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  margin-top: 2px;
  background: #1a281c;
  border: 1px solid #4a6a48;
  border-radius: 8px;
  color: #e8f0e4;
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.boot-fs-btn:hover,
.boot-fs-btn:focus-visible {
  border-color: var(--accent);
  background: #243428;
}

.boot-desktop-hint {
  margin-top: 8px;
}

@media (max-width: 900px), (pointer: coarse) {
  #boot {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .boot-panel {
    padding: 14px 14px 14px;
    width: 100%;
  }
  .boot-panel h1,
  .boot-heading h1 {
    font-size: 1.35rem;
  }
  .tag {
    margin: 0 0 10px;
    font-size: 0.72rem;
  }
  .boot-heading .tag {
    margin: 0;
  }
  label {
    margin-bottom: 8px;
    font-size: 0.8rem;
  }
  input,
  select {
    margin-top: 4px;
    padding: 8px 10px;
  }
  .element-hint {
    display: none;
  }
  .boot-desktop-hint {
    display: none;
  }
  .classes {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 8px 0 10px;
  }
  .class-card {
    padding: 10px 6px;
    text-align: center;
    min-height: 44px;
  }
  .class-card strong {
    display: block;
    margin: 0;
    font-size: 0.82rem;
  }
  .class-card span {
    display: none;
  }
  #joinBtn {
    margin-top: 0;
    padding: 12px;
  }
}

.boot-panel h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.tag {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.85rem;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #0c130e;
  border: 1px solid var(--line);
  color: var(--ink);
}

.classes {
  display: grid;
  gap: 8px;
  margin: 16px 0 12px;
}

.class-card {
  text-align: left;
  padding: 12px;
  background: #0c130e;
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
}

.class-card.selected {
  border-color: var(--accent);
  background: #142016;
}

.class-card.locked {
  cursor: default;
  opacity: 0.45;
}

.class-card.locked.selected {
  opacity: 1;
}

select:disabled {
  opacity: 0.85;
  cursor: default;
}

.class-card strong { display: block; margin-bottom: 4px; }
.class-card span { color: var(--muted); font-size: 0.8rem; }

#joinBtn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: 0;
  color: #08100a;
  font-weight: 700;
  cursor: pointer;
}

#joinBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

#game {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  left: 12px;
  top: 14px;
  width: min(300px, calc(100vw - 96px));
  pointer-events: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-card {
  padding: 10px 12px 11px;
  border-radius: 10px;
  background: linear-gradient(
    165deg,
    rgba(18, 28, 20, 0.82) 0%,
    rgba(10, 16, 12, 0.72) 100%
  );
  border: 1px solid rgba(90, 120, 88, 0.35);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #e6eee4;
}

.hud-hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#hpbar {
  flex: 1;
  height: 8px;
  background: rgba(40, 16, 16, 0.85);
  border: 1px solid rgba(120, 40, 36, 0.55);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0;
}

#hpfill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9a2e26 0%, #d45542 55%, #e8a090 120%);
  box-shadow: 0 0 10px rgba(196, 75, 58, 0.35);
  transition: width 120ms ease-out;
}

.hud-hp-text {
  flex: 0 0 auto;
  min-width: 4.5ch;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #f0c8c0;
  text-align: right;
}

.hud-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.hud-name {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: #f2f7ef;
}

.hud-tags {
  font-size: 0.72rem;
  color: #9aab96;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.hud-tags .hud-flag {
  color: #e0b060;
}

.hud-tags .hud-flag.danger {
  color: #e07060;
}

.hud-survive {
  font-size: 0.78rem;
  font-weight: 600;
  color: #b8d49a;
  margin-bottom: 6px;
}

.hud-ammo {
  font-size: 0.8rem;
  color: #dce6d8;
  margin-bottom: 4px;
}

.hud-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 2px;
}

.hud-money {
  font-size: 0.74rem;
  line-height: 1.4;
  color: #b7d48a;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.hud-aside:empty,
.hud-event.hidden {
  display: none;
}

.hud-aside {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(90, 120, 88, 0.22);
  font-size: 0.72rem;
  color: #9ec4e8;
  line-height: 1.35;
}

.hud-job {
  color: #e0c878;
}

.hud-event {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
}

#carnageHud,
#elixirHud {
  color: #e8f0e4;
  background: rgba(30, 48, 70, 0.65);
  border: 1px solid rgba(100, 140, 180, 0.4);
}

#worldClock,
.hud-clock {
  margin: 0;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #a8bca4;
  text-align: left;
  white-space: nowrap;
  line-height: 1.4;
  text-shadow: none;
}

#worldClock.phase-Night {
  color: #9eb4d8;
}
#worldClock.phase-Dawn {
  color: #e8c090;
}
#worldClock.phase-Day {
  color: #c8dcc4;
}
#worldClock.phase-Dusk {
  color: #d4a078;
}

#rebootHud,
.hud-reboot {
  margin-top: 6px;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffe0e0;
  background: rgba(120, 20, 20, 0.75);
  border: 1px solid #c04040;
  border-radius: 6px;
  text-shadow: none;
}

#rebootHud.hidden {
  display: none;
}

#ragnarokHud,
.hud-ragnarok {
  margin-top: 6px;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffe8a0;
  background: rgba(80, 40, 0, 0.8);
  border: 1px solid #c08020;
  border-radius: 6px;
  text-shadow: none;
}

#ragnarokHud.hidden {
  display: none;
}

.trivia-panel {
  max-width: 420px;
}

.trivia-q {
  font-size: 1.05rem;
  margin: 0.5rem 0 0.75rem;
  color: #f0f0e8;
}

#triviaAnswers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

#triviaAnswers button {
  flex: 1 1 auto;
  min-width: 6rem;
}

#timeOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: transparent;
  transition: background 1.2s ease, opacity 1.2s ease;
  opacity: 0;
}

#timeOverlay.phase-Night {
  background: rgba(8, 12, 28, 0.42);
  opacity: 1;
}
#timeOverlay.phase-Dawn {
  background: rgba(180, 110, 40, 0.12);
  opacity: 1;
}
#timeOverlay.phase-Day {
  background: transparent;
  opacity: 0;
}
#timeOverlay.phase-Dusk {
  background: rgba(120, 60, 20, 0.18);
  opacity: 1;
}

#canvas.phase-Night {
  filter: brightness(0.55) contrast(1.05) saturate(0.85);
}
#canvas.phase-Dawn {
  filter: brightness(0.82) sepia(0.18) saturate(1.05);
}
#canvas.phase-Day {
  filter: none;
}
#canvas.phase-Dusk {
  filter: brightness(0.78) sepia(0.22) hue-rotate(-8deg);
}

/* Indoor + power On (or Day): full brightness regardless of outdoor phase */
#canvas.lit-indoor,
#canvas.lit-indoor.phase-Night,
#canvas.lit-indoor.phase-Dawn,
#canvas.lit-indoor.phase-Dusk,
#canvas.lit-indoor.phase-Day {
  filter: none;
}
#timeOverlay.lit-indoor {
  background: transparent;
  opacity: 0;
}

/* Indoor blackout ? power Off at Night/Dusk/Dawn */
#canvas.lit-blackout {
  filter: brightness(0.22) contrast(1.1) saturate(0.6);
}
#timeOverlay.lit-blackout {
  background: rgba(0, 0, 0, 0.72);
  opacity: 1;
}
#worldClock.lit-blackout {
  color: #c07070;
}
#worldClock.lit-indoor {
  color: #e8f0e4;
}
#worldClock.lit-nvg {
  color: #7dff9a;
}
#worldClock.lit-lantern {
  color: #ffd078;
}
#worldClock.lit-thermal {
  color: #ff8a4a;
}

#menuBtn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 12;
  min-width: 72px;
  min-height: 44px;
  height: 44px;
  padding: 0 16px;
  background: #1a281c;
  border: 1px solid #4a6a48;
  color: #e8f0e4;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

#menuBtn:hover,
#menuBtn:focus-visible {
  border-color: var(--accent);
  background: #243428;
}

#fullscreenBtn {
  position: absolute;
  top: 12px;
  right: 96px;
  z-index: 12;
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 10px;
  background: #1a281c;
  border: 1px solid #4a6a48;
  color: #e8f0e4;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

#fullscreenBtn:hover,
#fullscreenBtn:focus-visible {
  border-color: var(--accent);
  background: #243428;
}

#mobileRail {
  display: contents;
}

.mobile-rail-row {
  display: contents;
}

#gameMenu {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

#gameMenu:not(.hidden) {
  display: grid;
}

.game-menu-panel {
  width: min(440px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: linear-gradient(180deg, #1a2218, #101610);
  border: 1px solid #3a5038;
  border-radius: 12px 12px 8px 8px;
  padding: 16px;
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.game-menu-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.game-menu-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

#gameMenuClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.game-menu-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.game-menu-search-wrap {
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 8px;
  padding: 0 0 6px;
  background: linear-gradient(180deg, #1a2218 65%, rgba(26, 34, 24, 0.92));
}

#gameMenuSearch {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #3a5038;
  background: rgba(8, 12, 9, 0.85);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

#gameMenuSearch::placeholder {
  color: #7a8a78;
}

#gameMenuSearch:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(111, 158, 74, 0.25);
}

.game-menu-search-empty {
  margin: 0 0 10px;
  color: #9aaa96;
  font-size: 0.85rem;
}

.game-menu-section {
  margin-bottom: 14px;
}

.game-menu-section.game-menu-search-miss {
  display: none;
}

.game-menu-grid button.game-menu-search-miss {
  display: none;
}

.game-menu-section h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aaa96;
}

.game-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-menu-grid button {
  min-height: 48px;
  padding: 12px 10px;
  background: #152018;
  border: 1px solid #3a5040;
  color: #e8f0e4;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 8px;
}

.game-menu-grid button:hover,
.game-menu-grid button:focus-visible {
  border-color: var(--accent);
  background: #1c2a20;
}

#gameMenuAdminSection.hidden {
  display: none;
}

#gameMenuAdminBtn {
  border-color: #704040;
  background: #2a1818;
}

#touchPad {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  pointer-events: none;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.45));
}

.touch-dpad {
  --dpad: 120px;
  --arm: 44px;
  position: relative;
  width: var(--dpad);
  height: var(--dpad);
  pointer-events: auto;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.55));
}

.touch-dir-center {
  display: none;
}

.touch-dir,
.touch-act {
  min-width: 52px;
  min-height: 52px;
  border-radius: 10px;
  border: 1px solid rgba(90, 120, 90, 0.85);
  background: rgba(18, 28, 20, 0.82);
  color: #e8f0e4;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* PS4-style: wide outer edge, tip pointed inward, arms fill the center */
.touch-dir {
  position: absolute;
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #1c2a1e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.touch-dir span {
  font-size: 0.72rem;
  line-height: 1;
  pointer-events: none;
  opacity: 0.92;
  text-shadow: 0 1px 1px #000;
}

/* Up — tip points down into center */
.touch-dir[data-dir="1"] {
  top: 0;
  left: 50%;
  width: var(--arm);
  height: calc(50% + 2px);
  transform: translateX(-50%);
  clip-path: polygon(0% 0%, 100% 0%, 100% 52%, 50% 100%, 0% 52%);
}
.touch-dir[data-dir="1"] span {
  transform: translateY(-6px);
}

/* Down — tip points up into center */
.touch-dir[data-dir="2"] {
  bottom: 0;
  left: 50%;
  width: var(--arm);
  height: calc(50% + 2px);
  transform: translateX(-50%);
  clip-path: polygon(50% 0%, 100% 48%, 100% 100%, 0% 100%, 0% 48%);
}
.touch-dir[data-dir="2"] span {
  transform: translateY(6px);
}

/* Left — tip points right into center */
.touch-dir[data-dir="8"] {
  left: 0;
  top: 50%;
  width: calc(50% + 2px);
  height: var(--arm);
  transform: translateY(-50%);
  clip-path: polygon(0% 0%, 52% 0%, 100% 50%, 52% 100%, 0% 100%);
}
.touch-dir[data-dir="8"] span {
  transform: translateX(-6px);
}

/* Right — tip points left into center */
.touch-dir[data-dir="4"] {
  right: 0;
  top: 50%;
  width: calc(50% + 2px);
  height: var(--arm);
  transform: translateY(-50%);
  clip-path: polygon(48% 0%, 100% 0%, 100% 100%, 48% 100%, 0% 50%);
}
.touch-dir[data-dir="4"] span {
  transform: translateX(6px);
}

.touch-dir:active,
.touch-act:active {
  background: rgba(60, 100, 60, 0.95);
  border-color: var(--accent);
}

.touch-dir:active {
  background: #3a6a3c;
}

.touch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  pointer-events: auto;
  width: min(168px, 42vw);
}

#controlsLegend {
  position: absolute;
  right: 12px;
  bottom: 72px;
  width: min(220px, 48vw);
  padding: 10px 12px;
  background: rgba(10, 16, 12, 0.72);
  border: 1px solid rgba(60, 80, 64, 0.85);
  color: var(--ink);
  font-size: 0.72rem;
  line-height: 1.35;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 1px 2px #000;
}

#controlsLegend header {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b8c8b4;
}

#controlsLegend dl {
  margin: 0;
  display: grid;
  gap: 3px;
}

#controlsLegend dl > div {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  align-items: baseline;
}

#controlsLegend dt {
  margin: 0;
  font-weight: 700;
  color: #dce8d8;
  white-space: nowrap;
}

#controlsLegend dd {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 900px), (pointer: coarse) {
  #controlsLegend {
    display: none;
  }
  #touchPad {
    display: flex;
  }
  #hud {
    top: 0;
    left: 0;
    right: auto;
    width: auto;
    max-width: calc(100vw - 120px);
    padding: max(2px, env(safe-area-inset-top)) 8px 0 max(6px, env(safe-area-inset-left));
    gap: 2px;
  }
  .hud-card {
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.85);
  }
  .hud-hp-row {
    margin-bottom: 3px;
    gap: 6px;
  }
  #hpbar {
    height: 6px;
    max-width: 120px;
  }
  .hud-identity {
    margin-bottom: 2px;
  }
  .hud-name {
    font-size: 0.88rem;
  }
  .hud-tags,
  .hud-survive,
  .hud-ammo,
  .hud-money,
  .hud-clock {
    font-size: 0.68rem;
  }
  .hud-survive,
  .hud-ammo {
    margin-bottom: 2px;
  }
  .hud-aside {
    margin-top: 3px;
    padding-top: 3px;
    border-top-color: rgba(255, 255, 255, 0.12);
  }
  #fullscreenBtn {
    top: max(6px, env(safe-area-inset-top));
    right: calc(84px + env(safe-area-inset-right, 0px));
    min-width: 44px;
    min-height: 44px;
    height: 44px;
  }
  #menuBtn {
    top: max(6px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    min-height: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  .game-menu-panel {
    width: min(100%, calc(100vw - 16px));
    max-height: min(90vh, 720px);
    padding: 12px;
  }
  .game-menu-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .game-menu-grid button {
    min-height: 42px;
    padding: 8px 6px;
    font-size: 0.8rem;
    line-height: 1.2;
  }
  .game-menu-hint {
    display: none;
  }
  #whoModal .who-panel,
  .admin-panel {
    width: min(100%, calc(100vw - 16px));
  }
  .hotkey-slot {
    width: 44px;
    height: 46px;
  }
}

#npcModal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
  pointer-events: auto;
}

#npcModal.hidden {
  display: none;
}

.npc-panel {
  width: min(420px, calc(100% - 32px));
  max-height: min(70vh, 520px);
  overflow: auto;
  background: linear-gradient(180deg, #1a241c, #101610);
  border: 1px solid #3a4a3c;
  color: #e8f0e4;
  padding: 14px 16px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.npc-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.npc-panel h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#npcClose {
  border: none;
  background: transparent;
  color: #9aab9a;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.npc-line {
  margin: 0 0 12px;
  color: #c5d4c2;
  font-size: 0.92rem;
  min-height: 2.4em;
}

.npc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.npc-actions button,
.npc-shop button,
.npc-atm button {
  border: 1px solid #4a5c4a;
  background: #243028;
  color: #e8f0e4;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.npc-actions button:hover,
.npc-shop button:hover,
.npc-atm button:hover {
  background: #314236;
}

.npc-shop {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.npc-shop.hidden,
.npc-atm.hidden {
  display: none;
}

.npc-shop button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  text-align: left;
}

.upgrade-weapon {
  border: 1px solid #3a4a3a;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
}

.upgrade-weapon-title {
  font-size: 0.8rem;
  color: #a8b8a4;
  margin-bottom: 2px;
}

.upgrade-weapon button {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.npc-atm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.npc-atm label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: #9aab9a;
}

.npc-atm input {
  padding: 6px 8px;
  background: #0c120e;
  border: 1px solid #3a4a3c;
  color: #e8f0e4;
}

.npc-cash {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: #a8c878;
}

#invPanel {
  position: absolute;
  right: 16px;
  top: 16px;
  width: min(280px, calc(100% - 32px));
  max-height: min(60vh, 420px);
  overflow: auto;
  background: linear-gradient(180deg, #1a241c, #101610);
  border: 1px solid #3a4a3c;
  color: #e8f0e4;
  padding: 12px;
  z-index: 15;
}

#invPanel.hidden { display: none; }

#invPanel header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#invPanel header strong { flex: 1; }

#invClose {
  border: none;
  background: transparent;
  color: #9aab9a;
  font-size: 1.3rem;
  cursor: pointer;
}

.inv-hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: #8a9a88;
}

#invList {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#invList button {
  border: 1px solid #4a5c4a;
  background: #243028;
  color: #e8f0e4;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  font-size: 0.82rem;
}

#invList button.selected {
  border-color: #8cbe6a;
  background: #2e4634;
}

#invList button.equipped {
  border-color: #c9a86a;
  color: #f0e6c8;
}

#invMenu {
  position: fixed;
  z-index: 40;
  min-width: 160px;
  padding: 4px 0;
  background: #f4f4f4;
  color: #111;
  border: 1px solid #bbb;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

#invMenu.hidden { display: none; }

#invMenu button {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: #111;
  text-align: left;
  padding: 7px 14px;
  font-size: 0.88rem;
  cursor: pointer;
}

#invMenu button:hover,
#invMenu button:focus {
  background: #d8d8d8;
  outline: none;
}

#itemStatsModal {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

#itemStatsModal.hidden { display: none; }

.item-stats-panel {
  width: min(320px, calc(100% - 32px));
  background: linear-gradient(180deg, #121812, #0a0e0a);
  border: 1px solid #3a4a3c;
  color: #e8f0e4;
  padding: 14px 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.item-stats-panel header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.item-stats-panel h2 {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
}

#itemStatsClose {
  border: none;
  background: transparent;
  color: #9aab9a;
  font-size: 1.3rem;
  cursor: pointer;
}

#itemStatsLines {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
  line-height: 1.45;
}

#itemStatsLines li {
  padding: 3px 0;
  border-bottom: 1px solid rgba(90, 110, 90, 0.35);
}

#itemStatsLines li:last-child { border-bottom: none; }

#npcBankList {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

#npcBankList button {
  border: 1px solid #4a5c4a;
  background: #243028;
  color: #e8f0e4;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-size: 0.82rem;
}

#chatDock {
  position: absolute;
  left: 8px;
  bottom: 12px;
  width: min(420px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 6;
  pointer-events: none;
}

#chatlog {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  max-height: 160px;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.35;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

#chatlog div { margin-top: 2px; opacity: 0.92; flex-shrink: 0; }
#chatlog .chat-emote { opacity: 0.85; color: #c4b89a; }
#chatlog .chat-radio { color: #8fbf7a; }
#chatlog .chat-whisper { color: #3cb371; }

#chatform {
  width: 100%;
  pointer-events: auto;
}

.chat-input-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

#chatinput {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0;
  padding: 8px 10px;
  height: 40px;
  background: rgba(8, 12, 9, 0.85);
  border: 1px solid var(--line);
  color: var(--ink);
  flex: 1;
  min-width: 0;
  line-height: 1.2;
  resize: none;
  overflow: hidden;
  font: inherit;
}

#chatToggleBtn {
  display: none;
}

#skillsToggleBtn {
  display: none;
}

/* After base #chatDock — sit above d-pad / action buttons on mobile */
@media (max-width: 900px), (pointer: coarse) {
  #mobileRail {
    display: contents;
  }

  .mobile-rail-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    position: absolute;
    top: auto;
    bottom: calc(132px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    pointer-events: none;
  }

  .mobile-rail-row[data-rail="skills"] {
    left: max(0px, env(safe-area-inset-left));
    right: auto;
  }

  .mobile-rail-row[data-rail="chat"] {
    left: auto;
    right: max(0px, env(safe-area-inset-right));
    flex-direction: row-reverse;
  }

  #chatToggleBtn,
  #skillsToggleBtn {
    display: flex;
    pointer-events: auto;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 28px;
    min-height: 68px;
    height: 68px;
    padding: 8px 0;
    margin: 0;
    background: rgba(18, 30, 20, 0.92);
    border: 1px solid #4a6a48;
    border-radius: 0;
    color: #e8f0e4;
    font: inherit;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 2px 4px 14px rgba(0, 0, 0, 0.45);
    -webkit-tap-highlight-color: transparent;
  }

  #skillsToggleBtn {
    /* rotate(180deg) flips edges: CSS right = screen-left edge */
    transform: rotate(180deg);
    border-left: 1px solid #4a6a48;
    border-right: 0;
  }

  #chatToggleBtn {
    transform: none;
    border-right: 0;
    border-left: 1px solid #4a6a48;
  }

  #chatToggleBtn:hover,
  #chatToggleBtn:focus-visible,
  #skillsToggleBtn:hover,
  #skillsToggleBtn:focus-visible,
  #chatToggleBtn[aria-expanded="true"],
  #skillsToggleBtn[aria-expanded="true"] {
    border-color: var(--accent);
    background: rgba(36, 52, 40, 0.96);
    color: #c8e8a8;
  }

  #chatDock {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    width: min(280px, calc(100vw - 48px));
    max-width: none;
    z-index: 14;
    gap: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(8px);
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
  }

  /* No ambient feed — chat text only inside the open Chat panel */
  #chatDock:not(.chat-open) #chatlog,
  #chatDock:not(.chat-open) #chatform {
    display: none;
  }

  #chatDock.chat-open {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: min(280px, calc(100vw - 48px));
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    z-index: 14;
  }
  #chatDock.chat-open #chatlog {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    max-height: min(36vh, 260px);
    min-height: 0;
    overflow-y: auto;
    padding: 8px 10px;
    margin: 0;
    background: rgba(8, 12, 9, 0.92);
    border: 1px solid #4a6a48;
    border-bottom: 0;
    border-radius: 0;
    pointer-events: auto;
    text-shadow: 0 1px 2px #000;
    -webkit-overflow-scrolling: touch;
  }
  #chatDock.chat-open #chatform {
    display: block;
    width: 100%;
    height: 68px;
    pointer-events: auto;
  }
  #chatDock.chat-open #chatinput {
    display: block;
    width: 100%;
    height: 68px;
    margin: 0;
    padding: 18px 12px;
    border-radius: 0;
    border: 1px solid #4a6a48;
    background: rgba(8, 12, 9, 0.92);
    box-sizing: border-box;
    font-size: 16px;
  }

  /* Full-width compose bar pinned above the keyboard */
  body.chat-keyboard .mobile-rail-row[data-rail="chat"] {
    flex-direction: row-reverse;
    align-items: stretch;
    background: rgba(8, 12, 9, 0.96);
    border-top: 1px solid #4a6a48;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.55);
  }
  body.chat-keyboard #chatToggleBtn {
    height: auto;
    min-height: 48px;
    align-self: stretch;
  }
  body.chat-keyboard #chatDock.chat-open {
    flex: 1 1 auto;
    width: auto !important;
    max-width: none;
    transform: none;
  }
  body.chat-keyboard #chatDock.chat-open #chatlog {
    max-height: min(36vh, 260px);
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }
  body.chat-keyboard #chatDock.chat-open #chatform,
  body.chat-keyboard #chatDock.chat-open #chatinput {
    height: 48px;
    padding: 12px;
    border: 1px solid #4a6a48;
    border-left: 0;
    border-top: 0;
    border-bottom: 0;
    font-size: 16px;
  }
}

#miniMapModal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.minimap-panel {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #0a0a0a;
  border: 1px solid #800000;
  color: #eee;
  padding: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}

.minimap-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.minimap-panel h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}

#miniMapClose {
  background: transparent;
  border: 0;
  color: #ccc;
  font-size: 1.4rem;
  cursor: pointer;
}

#miniMapStage {
  position: relative;
  width: 500px;
  max-width: 100%;
  height: 500px;
  margin: 0 auto;
  background: #000;
  overflow: hidden;
}

#miniMapImg {
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
  display: block;
}

#miniMapMarkers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.minimap-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
}

.minimap-marker img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto;
}

.minimap-marker span {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 4px;
  background: #000;
  border: 1px solid #fff;
  font-size: 10px;
  color: #fff;
  white-space: nowrap;
}

.minimap-marker.zombie span { color: #44ff44; }
.minimap-marker.admin span { color: #ffcc66; }
.minimap-marker.self span { color: #7ec8ff; }

.minimap-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-top: 10px;
  font-size: 0.78rem;
  border: 1px solid #800000;
  padding: 8px;
  background: #000;
}

.leg-green { color: #008000; }
.leg-yellow { color: #ffff00; }
.leg-blue { color: #0000ff; }
.leg-red { color: #ff0000; }
.leg-pink { color: #ff80ff; }
.leg-gray { color: #808080; }

.minimap-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #aaa;
}

#houseModal {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
}

.house-panel {
  width: min(420px, calc(100vw - 24px));
  background: linear-gradient(180deg, #172117, #121a14);
  border: 1px solid #3a5038;
  padding: 16px;
  color: #d7e0d4;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}

.house-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.house-panel h2 { margin: 0; font-size: 1.15rem; }

#houseClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

#houseBody {
  margin: 0 0 12px;
  color: #8a9a88;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.house-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.house-actions button {
  padding: 8px 12px;
  background: #1c281c;
  border: 1px solid #3a5038;
  color: #d7e0d4;
  cursor: pointer;
}

.house-actions button:hover {
  border-color: #6f9e4a;
}

#guildModal {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
}

.guild-panel {
  width: min(460px, calc(100vw - 24px));
  max-height: min(80vh, 560px);
  overflow: auto;
  background: linear-gradient(180deg, #1a1f28, #12151c);
  border: 1px solid #3a4a60;
  padding: 16px;
  color: #d4dbe0;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}

.guild-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.guild-panel h2 { margin: 0; font-size: 1.15rem; }

#guildClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

#guildBody {
  margin: 0 0 12px;
  color: #8a9aaa;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  font-family: inherit;
}

.guild-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guild-actions button {
  background: #1a2230;
  border: 1px solid #3a4a60;
  color: #d4dbe0;
  cursor: pointer;
  padding: 6px 10px;
}

.guild-actions button:hover {
  border-color: #6a9ecf;
}

#adminModal {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

.admin-panel {
  width: min(960px, calc(100vw - 24px));
  max-height: min(90vh, 720px);
  overflow: auto;
  background: linear-gradient(180deg, #241818, #161010);
  border: 1px solid #603838;
  padding: 16px;
  color: #e8d4d4;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}

.admin-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.admin-panel h2 { margin: 0; font-size: 1.15rem; color: #f0a0a0; }

.admin-search-wrap {
  display: block;
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 10px 0 8px;
  padding: 0 0 6px;
  background: linear-gradient(180deg, #241818 65%, rgba(36, 24, 24, 0.92));
}

#adminSearch {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #603838;
  background: rgba(10, 8, 8, 0.85);
  color: #f0e4e4;
  font: inherit;
  font-size: 0.9rem;
}

#adminSearch::placeholder {
  color: #8a7070;
}

#adminSearch:focus {
  outline: none;
  border-color: #a06060;
  box-shadow: 0 0 0 2px rgba(160, 80, 80, 0.25);
}

.admin-search-empty {
  margin: 0 0 10px;
  color: #c09090;
  font-size: 0.85rem;
}

.admin-section.admin-search-miss {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-panel h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #e0b0b0;
  font-weight: 600;
}

#adminClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

.admin-hint {
  margin: 0 0 12px;
  color: #9a8080;
  font-size: 0.85rem;
}

.admin-subhint {
  margin: 0 0 10px;
  color: #8a7070;
  font-size: 0.8rem;
}

.admin-grid {
  column-count: 3;
  column-gap: 0;
  column-rule: 1px solid #403030;
  margin-bottom: 12px;
  border: 1px solid #403030;
  background: rgba(0, 0, 0, 0.12);
}

@media (max-width: 860px) {
  .admin-grid { column-count: 2; }
}

@media (max-width: 640px) {
  .admin-grid {
    column-count: 1;
    column-rule: none;
  }
}

.admin-section {
  break-inside: avoid;
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-bottom: 1px solid #403030;
  background: rgba(0, 0, 0, 0.22);
  padding: 12px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: #c0a8a8;
}

.admin-field input,
.admin-field select,
.admin-field textarea {
  background: #1a1212;
  border: 1px solid #503838;
  color: #f0e0e0;
  padding: 8px 10px;
  font: inherit;
}

.admin-field textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  min-height: 10rem;
  resize: vertical;
}

.admin-field.admin-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.admin-field.admin-checkbox input {
  width: auto;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions button {
  background: #2a1818;
  border: 1px solid #704040;
  color: #f0d4d4;
  cursor: pointer;
  padding: 8px 12px;
}

.admin-actions button:hover {
  border-color: #c06060;
}

#adminRespawnBtn,
#adminReviveBtn {
  width: 100%;
}

.admin-spawn-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-spawn-card {
  text-align: left;
  background: #1a1212;
  border: 1px solid #503838;
  color: #e8d4d4;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-spawn-card strong {
  font-size: 0.9rem;
}

.admin-spawn-card span {
  font-size: 0.75rem;
  color: #9a8080;
}

.admin-spawn-card[data-spawn="Civilian"].selected {
  border-color: #6f9e4a;
  background: rgba(40, 60, 30, 0.45);
}

.admin-spawn-card[data-spawn="Cop"].selected {
  border-color: #5a8ad4;
  background: rgba(30, 40, 70, 0.45);
}

.admin-spawn-card[data-spawn="Doctor"].selected {
  border-color: #c05050;
  background: rgba(70, 30, 30, 0.45);
}

#adminOnline {
  margin: 0;
  max-height: 140px;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #a89090;
  white-space: pre-wrap;
  font-family: inherit;
  background: rgba(0,0,0,.25);
  padding: 8px;
  border: 1px solid #403030;
}

#adminBanList,
.admin-ban-list {
  margin: 8px 0 0;
  max-height: 100px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #c0a0a0;
  white-space: pre-wrap;
  font-family: inherit;
  background: rgba(0,0,0,.25);
  padding: 8px;
  border: 1px solid #403030;
}

.chat-announce {
  color: #ff6b6b;
  font-weight: 600;
}

#chatlog .chat-admin {
  color: #c8e6c9;
}
#chatlog .chat-admin .chat-admin-tag {
  color: #4caf50;
  font-weight: 600;
}
#chatlog .chat-admin .chat-admin-msg {
  color: #ffeb3b;
}
#chatlog .chat-admin-check {
  color: #ffeb3b;
}

#bjModal {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

.bj-panel {
  width: min(480px, calc(100vw - 24px));
  background: linear-gradient(180deg, #142818, #0e1a12);
  border: 1px solid #2a6040;
  padding: 16px;
  color: #d8ecd8;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}

.bj-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.bj-panel h2 { margin: 0; font-size: 1.2rem; color: #9ee0b0; }

#bjClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

.bj-status {
  margin: 0 0 12px;
  color: #8aaa90;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.bj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bj-label {
  width: 52px;
  font-size: 0.8rem;
  color: #7a9a80;
}

.bj-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-height: 48px;
}

.bj-card {
  min-width: 40px;
  height: 52px;
  border-radius: 4px;
  background: #f5f5f0;
  color: #111;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid #333;
}

.bj-card.red { color: #b02020; }
.bj-card.hidden {
  background: #1a3a28;
  color: #8ab898;
  border-color: #2a6040;
}

.bj-total {
  font-size: 0.85rem;
  color: #b8d8c0;
  min-width: 2rem;
}

.bj-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.bj-controls label {
  font-size: 0.85rem;
  color: #8aaa90;
}

.bj-controls input {
  width: 64px;
  margin-left: 4px;
  background: #0a1610;
  border: 1px solid #2a6040;
  color: #d8ecd8;
  padding: 6px;
  font: inherit;
}

.bj-controls button {
  background: #1a3020;
  border: 1px solid #3a7050;
  color: #d8ecd8;
  padding: 8px 12px;
  cursor: pointer;
}

.bj-controls button:hover:not(:disabled) {
  border-color: #6f9e4a;
}

.bj-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

.bj-cash {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: #7a9a80;
}

#carnageHud {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,.55);
  border: 1px solid #800;
  font-size: 0.8rem;
  line-height: 1.35;
}
#carnageHud .red { color: #f66; }
#carnageHud .blue { color: #6af; }

#elixirHud {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,.55);
  border: 1px solid #a80;
  font-size: 0.8rem;
  line-height: 1.35;
}
#elixirHud .red { color: #f66; }
#elixirHud .blue { color: #6af; }
#elixirHud .hold { color: #fc6; font-weight: 600; }

#whoModal {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

#motdModal {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

#motdModal.hidden {
  display: none !important;
}

#adminPopupModal {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

#adminPopupModal.hidden {
  display: none !important;
}

.motd-panel {
  width: min(560px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  overflow: auto;
  background: #000;
  border: 1px solid #444;
  padding: 16px;
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.motd-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.motd-panel h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #ff0;
}

.motd-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #fff;
}

#adminMotdText {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  font: inherit;
  background: #111;
  color: #eee;
  border: 1px solid #444;
  padding: 6px 8px;
}

#adminPopupText {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  font: inherit;
  background: #111;
  color: #eee;
  border: 1px solid #444;
  padding: 6px 8px;
}

.admin-edit-item-only.hidden {
  display: none !important;
}

#hccnModal {
  position: absolute;
  inset: 0;
  z-index: 23;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

#hccnModal.hidden {
  display: none !important;
}

.hccn-panel {
  width: min(700px, calc(100vw - 24px));
  max-height: min(85vh, 560px);
  overflow: auto;
  background: #000;
  border: 1px solid #444;
  padding: 16px;
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  font-family: Consolas, "Courier New", monospace;
}

.hccn-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.hccn-panel h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  flex: 1;
}

#hccnClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

.hccn-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.hccn-toolbar button {
  background: #111;
  border: 1px solid #555;
  color: #fff;
  padding: 4px 10px;
  cursor: pointer;
}

.hccn-toolbar button:hover {
  color: #8b0000;
  border-color: #8b0000;
}

.hccn-body {
  font-size: 0.92rem;
  line-height: 1.45;
  min-height: 120px;
}

.hccn-post-link {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #fff;
  padding: 4px 0;
  cursor: pointer;
  font: inherit;
}

.hccn-post-link:hover {
  color: #8b0000;
}

.hccn-meta {
  color: #bbb;
  margin: 0 0 10px;
}

.hccn-message {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
}

.hccn-replies {
  margin-top: 12px;
  border-top: 1px solid #333;
  padding-top: 8px;
}

.hccn-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid #333;
  padding-top: 12px;
}

.hccn-compose.hidden {
  display: none !important;
}

.hccn-compose label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #ccc;
}

.hccn-compose input,
.hccn-compose textarea {
  background: #111;
  border: 1px solid #444;
  color: #fff;
  padding: 6px 8px;
  font: inherit;
  resize: vertical;
}

.hccn-compose-actions {
  display: flex;
  gap: 8px;
}

.hccn-compose-actions button {
  background: #1a1a1a;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
}

.who-panel {
  width: min(560px, calc(100vw - 24px));
  max-height: min(85vh, 640px);
  overflow: auto;
  background: linear-gradient(180deg, #1a1010, #100808);
  border: 1px solid #8b0000;
  padding: 16px;
  color: #f0f0f0;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}

.who-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.who-panel h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #fff;
}

#whoClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

.who-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.who-tab {
  flex: 1;
  background: #1a1010;
  border: 1px solid #603030;
  color: #d0b0b0;
  padding: 8px 10px;
  cursor: pointer;
}

.who-tab.selected {
  border-color: #c44;
  color: #fff;
  background: #2a1414;
}

.who-summary {
  margin: 0 0 10px;
  color: #b0a0a0;
  font-size: 0.85rem;
}

.profile-body {
  font-size: 0.85rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #402828;
  padding: 2px 0;
}

.profile-row span {
  color: #c0a8a8;
}

.profile-row strong {
  color: #fff;
  text-align: right;
}

.profile-desc {
  margin-top: 12px;
  color: #e8d8d8;
  white-space: pre-wrap;
}

#profileModal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

#profileModal.hidden {
  display: none;
}

#profileClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

#floorTileChartModal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

#floorTileChartModal.hidden {
  display: none;
}

.floor-tile-chart-panel {
  width: min(760px, calc(100vw - 24px));
  max-height: min(90vh, 720px);
}

.floor-tile-chart-panel img {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid #503838;
}

#floorTileChartClose {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
}

.who-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.who-row {
  border-bottom: 1px solid #500;
  padding: 8px 0;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
}

.who-row img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  background: #000;
}

.who-row .meta {
  font-size: 0.82rem;
  color: #ccc;
  line-height: 1.35;
}

.who-row .meta b { color: #fff; }
.who-row .zombie-tag { color: #6f9e4a; }

.who-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: #c0a8a8;
}

.who-field select {
  background: #1a1212;
  border: 1px solid #503838;
  color: #f0e0e0;
  padding: 8px 10px;
  font: inherit;
}

.score-list {
  margin: 0;
  padding: 0 0 0 22px;
  color: #eee;
  font-size: 0.9rem;
  line-height: 1.55;
}

.score-list li:first-child {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  list-style: none;
  margin-left: -22px;
  margin-bottom: 6px;
  text-align: center;
}

/* Draggable desktop popups ? drag by header */
.draggable-panel > header.drag-handle,
#invPanel.draggable-panel > header.drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.draggable-panel.dragging > header.drag-handle {
  cursor: grabbing;
}

.draggable-panel.dragging {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

@media (pointer: coarse) {
  .draggable-panel > header.drag-handle {
    cursor: default;
  }
}

/* Classic BYOND-style skill hotkey bar (Z X C V B) */
#hotkeyBar {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(18, 26, 18, 0.92), rgba(8, 12, 8, 0.94));
  border: 1px solid #3a5038;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

#hotkeyBar.hidden {
  display: none;
}

.hotkey-layers {
  display: flex;
  gap: 4px;
}

.hotkey-layers button {
  min-width: 28px;
  min-height: 28px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: #c8d8c4;
  background: #152018;
  border: 1px solid #3a4a38;
  border-radius: 4px;
  cursor: pointer;
}

.hotkey-layers button.active {
  color: #111;
  background: #8cbc64;
  border-color: #a8d878;
}

.hotkey-layers button.hk-layer-toggle {
  min-width: 36px;
  min-height: 32px;
  font-size: 0.85rem;
}

.hotkey-slots {
  display: flex;
  gap: 6px;
}

.hotkey-slot {
  position: relative;
  width: 52px;
  height: 56px;
  padding: 0;
  border: 1px solid #4a6048;
  border-radius: 6px;
  background: #0c140e;
  color: #e8f0e4;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  touch-action: manipulation;
}

.hotkey-slot:hover,
.hotkey-slot:focus-visible {
  border-color: #8cbc64;
}

.hotkey-slot.empty {
  opacity: 0.75;
}

.hotkey-slot .hk-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #9ab090;
  text-shadow: 0 1px 1px #000;
}

.hotkey-slot .hk-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  margin-bottom: 2px;
}

.hotkey-slot .hk-label {
  font-size: 0.55rem;
  line-height: 1.1;
  max-width: 48px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #dce8d4;
  margin-bottom: 3px;
}

.hotkey-slot .hk-cd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  pointer-events: none;
}

.hotkey-slot.flash {
  box-shadow: 0 0 0 2px #c8e888;
}

.hotkey-hint {
  margin: 0;
  font-size: 0.65rem;
  color: #7a9078;
}

/* Must follow base #hotkeyBar — otherwise left:50% wins on mobile */
@media (max-width: 900px), (pointer: coarse) {
  #hotkeyBar {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    transform: translateX(-8px);
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 5px 6px;
    max-height: none;
    max-width: min(260px, calc(100vw - 44px));
    z-index: 14;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border-radius: 0;
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
  }
  #hotkeyBar:not(.skills-collapsed) {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    min-height: 68px;
    box-sizing: border-box;
  }
  #hotkeyBar.skills-collapsed {
    display: flex;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    width: 0;
    max-width: 0;
    overflow: hidden;
  }
  #hotkeyBar.skills-collapsed #hotkeyLayers,
  #hotkeyBar.skills-collapsed #hotkeySlots,
  #hotkeyBar.skills-collapsed #hotkeyHint {
    display: none;
  }
  .hotkey-layers {
    display: none;
  }
  .hotkey-slots {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 3px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .hotkey-slot {
    width: 42px;
    height: 46px;
    flex: 1 1 0;
    min-width: 36px;
    max-width: 48px;
    border-radius: 0;
  }
  .hotkey-slot .hk-icon {
    width: 26px;
    height: 26px;
  }
  .hotkey-slot .hk-label {
    max-width: 40px;
    font-size: 0.5rem;
  }
  .hotkey-hint {
    display: none;
  }
}

@media (max-width: 640px) {
  #hotkeyBar {
    max-width: min(240px, calc(100vw - 40px));
  }
  .hotkey-slot {
    width: 40px;
    height: 44px;
    min-width: 34px;
  }
  .hotkey-slot .hk-icon {
    width: 24px;
    height: 24px;
  }
}
