:root {
  --bg: #0f1713;
  --bg-elev-1: #152019;
  --bg-elev-2: #1b2a20;
  --bg-elev-3: #243629;
  --bg-panel: rgba(20, 31, 24, 0.94);
  --bg-panel-soft: rgba(28, 42, 33, 0.88);
  --bg-glass: rgba(20, 29, 24, 0.72);

  --text: #edf6ef;
  --text-dim: #b7cbbd;
  --text-soft: #8ea291;

  --accent: #82d173;
  --accent-2: #b7f28f;
  --accent-3: #59b57f;
  --warning: #ffd166;
  --danger: #f76b6b;
  --danger-2: #ff9b9b;
  --info: #7ec8ff;
  --shadow: rgba(0, 0, 0, 0.35);
  --outline: rgba(255, 255, 255, 0.08);

  --health: #7ee081;
  --stamina: #5fd0ff;
  --hunger: #ffca6c;
  --thirst: #7bbfff;
  --infection: #d77cff;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;

  --header-h: 84px;
  --actionbar-h: 84px;
  --sidebar-w: 250px;
  --mini-map-size: 260px;

  --font-main: "Trebuchet MS", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;

  --ui-scale: 1;
  --transition-fast: 0.16s ease;
  --transition-med: 0.26s ease;
  --transition-slow: 0.42s ease;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  height: 100%;
  width: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(98, 158, 90, 0.18), transparent 35%),
    linear-gradient(180deg, #0f1713 0%, #101913 38%, #0b100d 100%);
  color: var(--text);
  font-family: var(--font-main);
  overflow: hidden;
  user-select: none;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-main);
}

button,
input,
select,
textarea {
  outline: none;
}

button {
  cursor: pointer;
  border: none;
  color: inherit;
  transition:
    transform var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    opacity var(--transition-fast);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: rgba(10, 16, 12, 0.65);
  color: var(--text);
  padding: 0.8rem 0.9rem;
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-soft);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

small {
  color: var(--text-soft);
}

.hidden {
  display: none !important;
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transform: scale(var(--ui-scale));
  transform-origin: top left;
}

/* -------------------------------------------------------------------------- */
/* Generic Cards / Panels */
/* -------------------------------------------------------------------------- */

.card,
.detail-panel,
.sidebar-section,
.boot-card,
.creator-shell,
.modal-window,
.resource-pill,
.stack-list > *,
.card-list > *,
.party-mini-list > * {
  background: var(--bg-panel);
  border: 1px solid var(--outline);
  box-shadow:
    0 10px 30px var(--shadow),
    inset 0 1px 0 rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
}

.card,
.detail-panel {
  border-radius: var(--radius-md);
  padding: 1rem;
}

.card.selected,
.party-management-card.selected,
.nearby-card.selected {
  border-color: rgba(130, 209, 115, 0.5);
  box-shadow:
    0 0 0 2px rgba(130, 209, 115, 0.12),
    0 10px 30px var(--shadow);
}

.compact-card {
  padding: 0.75rem;
}

.wide-panel {
  min-width: 0;
}

.stack-list,
.card-list,
.party-mini-list,
.status-chip-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 1rem;
}

.stack-list > *,
.card-list > *,
.party-mini-list > * {
  border-radius: 14px;
  padding: 0.85rem;
}

.status-chip-wrap {
  flex-direction: row;
  flex-wrap: wrap;
}

.status-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(130, 209, 115, 0.12);
  border: 1px solid rgba(130, 209, 115, 0.28);
  color: var(--accent-2);
  font-size: 0.82rem;
}

/* -------------------------------------------------------------------------- */
/* Buttons */
/* -------------------------------------------------------------------------- */

.primary-btn,
.secondary-btn,
.ghost-btn,
.hud-btn,
.panel-btn,
.action-btn,
.combat-btn,
.mini-btn,
.modal-close-btn,
.file-label {
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.primary-btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-3));
  color: #112114;
  padding: 0.9rem 1.15rem;
  box-shadow: 0 8px 24px rgba(89, 181, 127, 0.25);
}

.primary-btn:hover {
  box-shadow: 0 10px 28px rgba(89, 181, 127, 0.35);
}

.secondary-btn,
.file-label {
  background: rgba(130, 209, 115, 0.12);
  border: 1px solid rgba(130, 209, 115, 0.26);
  color: var(--accent-2);
  padding: 0.82rem 1rem;
}

.secondary-btn:hover,
.file-label:hover {
  background: rgba(130, 209, 115, 0.2);
}

.ghost-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--outline);
  color: var(--text);
  padding: 0.8rem 1rem;
}

.hud-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--outline);
  padding: 0.68rem 0.95rem;
  min-width: 76px;
}

.hud-btn.admin {
  border-color: rgba(255, 107, 107, 0.32);
  color: var(--danger-2);
}

.panel-btn {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--outline);
  padding: 0.75rem 0.7rem;
  min-height: 52px;
  text-align: center;
}

.panel-btn:hover {
  background: rgba(255,255,255,0.09);
}

.action-btn {
  min-width: 110px;
  padding: 0.92rem 1rem;
  background: rgba(13, 18, 15, 0.78);
  border: 1px solid var(--outline);
}

.action-btn.primary {
  background: linear-gradient(180deg, #95e07e, #4ea15d);
  color: #122014;
}

.combat-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--outline);
  min-height: 56px;
  padding: 0.9rem 1rem;
}

.mini-btn,
.modal-close-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--outline);
  padding: 0.56rem 0.75rem;
}

.sidebar-collapse-btn {
  min-width: 58px;
  padding: 0.42rem 0.58rem;
  font-size: 0.76rem;
}

.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/* Screen Layers */
/* -------------------------------------------------------------------------- */

.screen-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.screen-layer.active,
#gameScreen.active,
#combatScreen.active {
  opacity: 1;
  pointer-events: auto;
}

/* -------------------------------------------------------------------------- */
/* Boot Screen */
/* -------------------------------------------------------------------------- */

.boot-screen {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 20% 15%, rgba(130, 209, 115, 0.12), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(215, 124, 255, 0.09), transparent 28%),
    linear-gradient(180deg, rgba(10, 16, 12, 0.75), rgba(9, 13, 10, 0.92));
}

.boot-screen.active {
  display: grid;
}

.boot-card {
  width: min(700px, 100%);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(24, 39, 29, 0.96), rgba(16, 25, 20, 0.96));
}

.boot-logo-wrap {
  margin-bottom: 1.5rem;
}

.boot-logo {
  width: 118px;
  height: 118px;
  margin: 0 auto 1rem;
  border-radius: 28px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.3), transparent 15%),
    radial-gradient(circle at 60% 70%, rgba(130, 209, 115, 0.75), transparent 24%),
    radial-gradient(circle at 30% 75%, rgba(215, 124, 255, 0.44), transparent 26%),
    linear-gradient(180deg, #273c2b, #1a281d);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 0 0 10px rgba(130, 209, 115, 0.04),
    0 18px 40px rgba(0,0,0,0.4);
}

.game-title {
  margin-bottom: 0.4rem;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  letter-spacing: 0.08em;
}

.game-tagline {
  color: var(--text-dim);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.45;
}

.boot-actions {
  display: grid;
  gap: 0.85rem;
  margin: 1.75rem 0;
}

.boot-footer {
  color: var(--text-soft);
}

/* -------------------------------------------------------------------------- */
/* Character Creator */
/* -------------------------------------------------------------------------- */

#characterCreatorScreen {
  background:
    radial-gradient(circle at top left, rgba(130, 209, 115, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(13, 19, 15, 0.9), rgba(8, 11, 9, 0.96));
  padding: 1rem;
  overflow: auto;
}

#characterCreatorScreen.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.creator-shell {
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100dvh - 2rem);
  border-radius: 28px;
  padding: 1rem;
}

.creator-header,
.modal-header,
.combat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.creator-header {
  padding: 0.5rem 0 1rem;
}

.creator-header-actions,
.modal-header-actions,
.admin-console-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.creator-body {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1rem;
  min-height: 0;
}

.creator-preview-panel,
.creator-form-panel {
  min-width: 0;
}

.character-preview-card {
  border-radius: 24px;
  padding: 1rem;
  background: var(--bg-panel-soft);
  border: 1px solid var(--outline);
  min-height: 100%;
}

.avatar-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.2;
  max-height: 460px;
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 1rem;
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,0.08), transparent 24%),
    linear-gradient(180deg, #314433, #18221a 80%);
  border: 1px solid rgba(255,255,255,0.08);
}

.avatar-layer {
  position: absolute;
  inset: 0;
}

.avatar-base {
  background:
    radial-gradient(circle at 50% 28%, #f0c4a1 0 10%, transparent 10.5%),
    radial-gradient(circle at 50% 44%, #425843 0 18%, transparent 18.5%),
    radial-gradient(circle at 50% 78%, #314737 0 28%, transparent 28.5%);
}

.avatar-hair {
  background:
    radial-gradient(circle at 50% 22%, rgba(62, 37, 15, 0.92) 0 12%, transparent 12.4%);
}

.avatar-outfit {
  background:
    linear-gradient(180deg, transparent 0 45%, rgba(110, 154, 94, 0.85) 45% 68%, transparent 68%);
}

.avatar-accessory {
  background:
    radial-gradient(circle at 62% 41%, rgba(255, 214, 102, 0.88) 0 2.6%, transparent 3%);
}

.preview-meta {
  display: grid;
  gap: 0.55rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.9rem;
}

.form-field {
  display: grid;
  gap: 0.45rem;
}

.form-field span {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 700;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.creator-notes {
  margin-top: 1rem;
}

.creator-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* -------------------------------------------------------------------------- */
/* Main Game Layout */
/* -------------------------------------------------------------------------- */

#gameScreen {
  background:
    linear-gradient(180deg, rgba(11, 16, 12, 0.25), rgba(11, 16, 12, 0.6)),
    linear-gradient(180deg, #172219 0%, #111913 100%);
}

.top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 340px 1fr 260px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 1rem;
  z-index: 35;
  background:
    linear-gradient(180deg, rgba(8, 12, 10, 0.95), rgba(14, 20, 16, 0.86));
  border-bottom: 1px solid var(--outline);
  backdrop-filter: blur(10px);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-center {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: auto hidden;
  padding-bottom: 0.15rem;
}

.hud-logo-mini {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(180deg, rgba(130, 209, 115, 0.95), rgba(89, 181, 127, 0.95));
  color: #112114;
  box-shadow: 0 8px 18px rgba(89, 181, 127, 0.22);
}

.hud-day-block,
.hud-weather-block {
  display: grid;
  gap: 0.15rem;
}

.hud-stat-main {
  font-weight: 800;
  line-height: 1;
}

.hud-stat-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.resource-pill {
  min-width: 160px;
  max-width: 190px;
  border-radius: 18px;
  padding: 0.55rem 0.7rem;
  display: grid;
  gap: 0.3rem;
}

.resource-pill span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.resource-pill strong {
  font-size: 0.84rem;
}

.resource-pill .bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.resource-pill .fill {
  width: 72%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

#barHealth { background: linear-gradient(90deg, var(--health), #b3ff95); }
#barStamina { background: linear-gradient(90deg, var(--stamina), #9ee7ff); }
#barHunger { background: linear-gradient(90deg, var(--hunger), #ffe29f); }
#barThirst { background: linear-gradient(90deg, var(--thirst), #b0d9ff); }
#barInfection { background: linear-gradient(90deg, var(--infection), #ffb2ff); }

.resource-pill.danger {
  border-color: rgba(215, 124, 255, 0.3);
}

.game-layout {
  position: absolute;
  inset: var(--header-h) 0 var(--actionbar-h) 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  gap: 0.75rem;
  padding: 0.75rem;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.right-sidebar {
  min-height: 0;
}

.right-sidebar .sidebar-section {
  flex: 0 0 auto;
}

.right-sidebar .sidebar-section:last-child {
  flex: 1 1 240px;
  min-height: 220px;
}

.sidebar-section {
  border-radius: 20px;
  padding: 0.85rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
}

.sidebar-section h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.sidebar-section-header h3 {
  min-width: 0;
}

.collapsible-sidebar-body {
  transition:
    opacity var(--transition-fast),
    max-height var(--transition-med);
}

.collapsible-sidebar-body.collapsed {
  display: none !important;
}

.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.log-box {
  min-height: 120px;
  height: 100%;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: rgba(8, 12, 10, 0.62);
  padding: 0.8rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-dim);
  white-space: pre-wrap;
}

.play-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 26px;
  overflow: hidden;
  background: rgba(9, 14, 10, 0.62);
  border: 1px solid var(--outline);
  box-shadow: 0 16px 38px rgba(0,0,0,0.35);
}

.world-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 10%, rgba(130, 209, 115, 0.09), transparent 30%),
    linear-gradient(180deg, #26362a 0%, #1b291f 38%, #162118 100%);
}

#worldCanvas,
#fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
}

#fxCanvas {
  pointer-events: none;
}

.interaction-prompt {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 2rem));
  border-radius: 18px;
  padding: 0.8rem 1rem;
  background: rgba(9, 13, 10, 0.88);
  border: 1px solid rgba(130, 209, 115, 0.25);
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
  z-index: 5;
}

.prompt-title {
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.prompt-body {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.floating-layer,
.toast-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.toast-layer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 1rem;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  border-radius: 16px;
  padding: 0.85rem 1rem;
  background: rgba(10, 15, 11, 0.9);
  border: 1px solid var(--outline);
  box-shadow: 0 12px 24px rgba(0,0,0,0.28);
}

.bottom-action-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--actionbar-h);
  display: flex;
  gap: 0.7rem;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(11, 16, 12, 0.15), rgba(8, 12, 10, 0.88));
  border-top: 1px solid var(--outline);
  z-index: 6;
  overflow-x: auto;
}

.mini-map-shell {
  position: absolute;
  left: calc(var(--sidebar-w) + 1rem);
  right: auto;
  bottom: calc(var(--actionbar-h) + 1rem);
  top: auto;
  width: var(--mini-map-size);
  border-radius: 22px;
  padding: 0.7rem;
  z-index: 20;
  background: rgba(12, 18, 13, 0.92);
  border: 1px solid var(--outline);
  box-shadow: 0 14px 30px rgba(0,0,0,0.35);
}

.mini-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  font-weight: 700;
  cursor: grab;
}

.mini-map-shell.expanded {
  width: min(420px, calc(100vw - 2rem));
}

.mini-map-shell.collapsed {
  width: 170px;
}

.mini-map-shell.collapsed .mini-map-header {
  margin-bottom: 0;
}

#miniMapCanvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: linear-gradient(180deg, #273c31, #18211b);
  border: 1px solid rgba(255,255,255,0.06);
}

/* -------------------------------------------------------------------------- */
/* Combat */
/* -------------------------------------------------------------------------- */

.combat-screen {
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.05), transparent 30%),
    linear-gradient(180deg, rgba(18, 11, 18, 0.96), rgba(7, 5, 9, 0.98));
}

.combat-backdrop {
  position: absolute;
  inset: 0;
  padding: 1rem;
  display: grid;
  place-items: center;
}

.combat-arena {
  width: min(1480px, 100%);
  height: min(900px, 100%);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(29, 19, 31, 0.98), rgba(14, 11, 18, 0.98));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  padding: 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.9rem;
}

.combat-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 0;
}

.combat-enemy-side,
.combat-player-side {
  border-radius: 24px;
  padding: 1rem;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  min-height: 0;
}

.battlefield-grid {
  display: grid;
  gap: 0.9rem;
  height: 100%;
  align-content: center;
}

.enemy-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ally-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.battle-slot {
  min-height: 180px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  text-align: center;
}

.battle-slot.down {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.battle-portrait {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  margin-bottom: 0.6rem;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,0.22), transparent 18%),
    linear-gradient(180deg, #48674e, #233326);
}

.battle-portrait.down {
  opacity: 0.45;
}

.turn-order-strip {
  min-height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.035);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem;
  overflow-x: auto;
}

.turn-chip {
  flex: 0 0 auto;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  background: rgba(130, 209, 115, 0.1);
  border: 1px solid rgba(130, 209, 115, 0.22);
}

.turn-chip.active {
  background: rgba(130, 209, 115, 0.22);
  border-color: rgba(130, 209, 115, 0.46);
  color: var(--accent-2);
}

.combat-command-shell {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  gap: 0.9rem;
  min-height: 180px;
}

.combat-actor-card,
.combat-command-panel,
.combat-detail-panel {
  border-radius: 22px;
  padding: 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
}

.combat-command-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  align-content: start;
}

/* -------------------------------------------------------------------------- */
/* Modal System */
/* -------------------------------------------------------------------------- */

.modal-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 55;
}

.modal-window {
  position: absolute;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  width: min(1040px, calc(100vw - 2rem));
  max-height: calc(100dvh - 4rem);
  border-radius: 24px;
  overflow: hidden;
  z-index: 60;
  pointer-events: auto;
}

.modal-window.large {
  width: min(1320px, calc(100vw - 2rem));
}

.modal-window.hidden {
  display: none !important;
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-header {
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border-bottom: 1px solid var(--outline);
  cursor: grab;
}

.modal-header.drag-handle:active {
  cursor: grabbing;
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-body {
  padding: 1rem;
  overflow: auto;
  max-height: calc(100dvh - 9rem);
  background: rgba(16, 24, 18, 0.96);
}

.admin-header {
  border-bottom-color: rgba(255, 107, 107, 0.18);
}

.inventory-layout,
.split-layout,
.triple-layout,
.map-layout,
.settings-grid,
.admin-layout,
.party-management-layout {
  display: grid;
  gap: 1rem;
}

.inventory-layout,
.split-layout,
.map-layout,
.party-management-layout {
  grid-template-columns: 1fr 320px;
}

.triple-layout {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.admin-layout {
  grid-template-columns: 320px 1fr;
}

.overview-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.base-overview-root,
.habitat-management-block {
  display: grid;
  gap: 0.85rem;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.7rem;
}

.inventory-slot {
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--outline);
  padding: 0.5rem;
  display: grid;
  place-items: center;
  position: relative;
}

.inventory-slot:hover {
  border-color: rgba(130, 209, 115, 0.35);
}

.inventory-slot .qty {
  position: absolute;
  right: 0.45rem;
  bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--accent-2);
  font-weight: 800;
}

.detail-panel h3 {
  margin-bottom: 0.8rem;
}

.map-layout canvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, #24372b, #132018);
}

.card-list {
  max-height: 62dvh;
  overflow: auto;
}

#buildPanelContent,
#trapPanelContent,
#basePanelContent {
  max-height: calc(100dvh - 11rem);
  overflow: auto;
}

#partyMemberList {
  max-height: calc(100dvh - 12rem);
}

#partyMemberDetail {
  max-height: calc(100dvh - 12rem);
  overflow: auto;
}

/* -------------------------------------------------------------------------- */
/* Utility UI bits */
/* -------------------------------------------------------------------------- */

.party-mini-list > * {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.7rem;
  align-items: center;
}

.mini-portrait,
.icon-thumb {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,0.2), transparent 16%),
    linear-gradient(180deg, #577a5d, #2b3a2f);
  border: 1px solid rgba(255,255,255,0.08);
}

.meta-title {
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.meta-sub {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.danger-text {
  color: var(--danger-2);
}

.warning-text {
  color: var(--warning);
}

.info-text {
  color: var(--info);
}

.accent-text,
.success-text {
  color: var(--accent-2);
}

.nearby-card {
  cursor: pointer;
}

.nearby-card:hover,
.party-management-card:hover {
  border-color: rgba(130, 209, 115, 0.34);
  background: rgba(32, 48, 37, 0.96);
}

.fungus-pulse {
  animation: fungusPulse 2.8s infinite ease-in-out;
}

/* -------------------------------------------------------------------------- */
/* Mobile / Responsive */
/* -------------------------------------------------------------------------- */

@media (max-width: 1280px) {
  :root {
    --sidebar-w: 220px;
    --mini-map-size: 230px;
  }

  .top-hud {
    grid-template-columns: 280px 1fr 210px;
  }

  .resource-pill {
    min-width: 145px;
  }

  .creator-body {
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 1050px) {
  body {
    overflow: hidden;
  }

  .top-hud {
    grid-template-columns: 1fr;
    height: auto;
    min-height: var(--header-h);
    padding-bottom: 0.8rem;
  }

  .hud-left,
  .hud-center,
  .hud-right {
    justify-content: center;
    flex-wrap: wrap;
  }

  .game-layout {
    top: 0;
    grid-template-columns: 220px 1fr;
    grid-template-areas:
      "left main"
      "right main";
  }

  .left-sidebar {
    grid-area: left;
  }

  .right-sidebar {
    grid-area: right;
  }

  .play-area {
    grid-area: main;
  }

  .combat-command-shell,
  .inventory-layout,
  .split-layout,
  .map-layout,
  .admin-layout,
  .party-management-layout {
    grid-template-columns: 1fr;
  }

  .triple-layout {
    grid-template-columns: 1fr;
  }

  .combat-body {
    grid-template-columns: 1fr;
  }

  .combat-command-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  :root {
    --header-h: 128px;
    --actionbar-h: 94px;
    --mini-map-size: 180px;
  }

  .creator-body {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .game-layout {
    grid-template-columns: 1fr;
    padding: 0.5rem;
  }

  .left-sidebar,
  .right-sidebar {
    display: none;
  }

  .play-area {
    border-radius: 18px;
  }

  .mini-map-shell {
    left: auto;
    right: 0.6rem;
    top: auto;
    bottom: calc(var(--actionbar-h) + 0.6rem);
    width: var(--mini-map-size);
    padding: 0.5rem;
  }

  .bottom-action-bar {
    justify-content: flex-start;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  .action-btn {
    min-width: 96px;
    padding: 0.85rem 0.85rem;
  }

  .modal-window,
  .modal-window.large {
    top: 0.5rem;
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    border-radius: 20px;
  }

  .modal-body {
    max-height: calc(100dvh - 6rem);
    padding: 0.85rem;
  }

  .modal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-header-actions {
    width: 100%;
  }

  .modal-header-actions input {
    min-width: 0;
  }

  .combat-arena {
    padding: 0.75rem;
    border-radius: 20px;
  }

  .battle-slot {
    min-height: 130px;
  }
}

@media (max-width: 560px) {
  :root {
    --header-h: 144px;
    --actionbar-h: 100px;
  }

  html {
    font-size: 15px;
  }

  .boot-card,
  .creator-shell {
    padding: 1rem;
  }

  .game-title {
    font-size: 2.2rem;
  }

  .top-hud {
    padding: 0.6rem;
    gap: 0.55rem;
  }

  .hud-center {
    justify-content: flex-start;
  }

  .resource-pill {
    min-width: 140px;
  }

  .interaction-prompt {
    bottom: 112px;
  }

  .combat-command-panel {
    grid-template-columns: 1fr 1fr;
  }

  .enemy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ally-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .admin-console-actions {
    align-items: stretch;
  }

  .admin-console-actions > button,
  .admin-console-actions > .file-label {
    flex: 1 1 auto;
  }
}

/* -------------------------------------------------------------------------- */
/* Reduced Motion */
/* -------------------------------------------------------------------------- */

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

/* -------------------------------------------------------------------------- */
/* Scrollbars */
/* -------------------------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(130, 209, 115, 0.32) rgba(255,255,255,0.04);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(130, 209, 115, 0.28);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(130, 209, 115, 0.42);
}

/* -------------------------------------------------------------------------- */
/* Animations */
/* -------------------------------------------------------------------------- */

@keyframes fungusPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(130, 209, 115, 0.16),
      0 18px 40px rgba(0,0,0,0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow:
      0 0 0 14px rgba(130, 209, 115, 0.03),
      0 18px 40px rgba(0,0,0,0.4);
  }
}
/* -------------------------------------------------------------------------- */
/* World Camera / Map Controls                                                */
/* -------------------------------------------------------------------------- */
.world-nav-controls {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
}

.world-nav-btn,
.world-tool-btn {
  pointer-events: auto;
  border-radius: 999px;
  background: rgba(10, 16, 12, 0.76);
  border: 1px solid rgba(237, 246, 239, 0.16);
  color: var(--text);
  min-width: 38px;
  min-height: 38px;
  padding: 0.45rem 0.65rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.32);
  backdrop-filter: blur(8px);
}

.world-nav-btn:hover,
.world-tool-btn:hover {
  background: rgba(130, 209, 115, 0.22);
  border-color: rgba(130, 209, 115, 0.42);
}

.world-nav-up,
.world-nav-down,
.world-nav-left,
.world-nav-right {
  position: absolute;
}

.world-nav-up {
  top: 0.7rem;
  left: 50%;
  transform: translateX(-50%);
}

.world-nav-down {
  bottom: 0.7rem;
  left: 50%;
  transform: translateX(-50%);
}

.world-nav-left {
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
}

.world-nav-right {
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
}

.world-zoom-cluster {
  position: absolute;
  right: 0.8rem;
  top: 0.8rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 280px;
  pointer-events: auto;
}

.world-tool-btn {
  font-weight: 800;
  font-size: 0.9rem;
}

#btnWorldToggleLabels,
#btnWorldToggleBoat {
  border-radius: 14px;
  min-width: 64px;
}

.world-viewport.dragging-map {
  cursor: grabbing;
}

.world-viewport.can-drag-map {
  cursor: grab;
}

@media (max-width: 800px) {
  .world-zoom-cluster {
    left: 0.6rem;
    right: 0.6rem;
    top: 0.5rem;
    max-width: none;
    justify-content: center;
  }

  .world-nav-btn,
  .world-tool-btn {
    min-width: 34px;
    min-height: 34px;
    padding: 0.38rem 0.5rem;
    font-size: 0.82rem;
  }
}

.party-control-panel {
  margin-bottom: 0.85rem;
}

.party-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.party-control-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  text-align: left;
  min-height: 82px;
}

.party-control-btn span,
.party-control-btn small {
  color: var(--text-dim);
  font-weight: 500;
}


/* -------------------------------------------------------------------------- */
/* Admin / Catalogue Utility Grids                                            */
/* -------------------------------------------------------------------------- */
.admin-spawn-card {
  margin-bottom: 1rem;
}

.admin-spawn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
  align-items: end;
  margin: 0.65rem 0;
}

.admin-spawn-grid .form-field {
  margin: 0;
}
