:root {
  color-scheme: dark;
  --background: #0f1720;
  --surface: #17212b;
  --surface-hover: #21303e;
  --border: #304252;
  --text: #edf5fb;
  --muted: #9db0c1;
  --primary: #3390ec;
  --primary-hover: #57a4ef;
  --danger: #df4b57;
  --danger-hover: #ed6771;
  --success: #4ab98a;
  --shadow: 0 14px 35px rgba(0, 0, 0, 0.22);
  --slot-size: 52px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--background);
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(51, 144, 236, 0.13), transparent 32rem),
    var(--background);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: pan-y;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.header,
.section-heading,
.toggle,
.form-row,
.custom-command,
.vital-heading,
.equipment-layout,
.drop-dialog-actions {
  display: flex;
  align-items: center;
}

.header,
.section-heading {
  justify-content: space-between;
  gap: 16px;
}

.header {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary-hover);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.8rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.card {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(23, 33, 43, 0.95);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-online {
  background: rgba(74, 185, 138, 0.18);
  color: #7ee2b7;
}

.badge-offline {
  background: rgba(223, 75, 87, 0.17);
  color: #ff9ba3;
}

.vitals {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.vital {
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(7, 13, 19, 0.35);
}

.vital-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.vital-label,
.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.vital-heading strong {
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 0.9rem;
}

.vital-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: #080e14;
}

.vital-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.22s ease;
}

.health-fill {
  background: linear-gradient(90deg, #d93f4f, #ff727e);
}

.food-fill {
  background: linear-gradient(90deg, #b77824, #f1c15b);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}

.stat {
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(7, 13, 19, 0.35);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
}

.stat strong {
  display: block;
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-text,
.inventory-summary {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.inventory-summary {
  margin-bottom: 0;
}

.equipment-card .section-heading,
.inventory-card .section-heading {
  align-items: flex-start;
}

.equipment-layout {
  align-items: flex-start;
  justify-content: center;
  gap: 38px;
  margin-top: 16px;
}

.armor-column,
.hands-column {
  display: grid;
  grid-template-columns: auto var(--slot-size);
  align-items: center;
  gap: 8px 10px;
}

.hands-column {
  grid-template-columns: var(--slot-size);
}

.hands-column .slot-label {
  text-align: center;
}

.slot-label {
  color: var(--muted);
  font-size: 0.76rem;
}

.mc-slot {
  position: relative;
  display: grid;
  width: var(--slot-size);
  height: var(--slot-size);
  padding: 0;
  place-items: center;
  overflow: visible;
  border: 2px solid #101820;
  border-top-color: #647383;
  border-left-color: #647383;
  border-right-color: #05080b;
  border-bottom-color: #05080b;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 44%),
    #2c3741;
  touch-action: none;
}

.mc-slot.is-empty::after {
  color: rgba(255, 255, 255, 0.18);
  content: "·";
  font-size: 1.5rem;
}

.mc-slot.is-selected {
  box-shadow: 0 0 0 2px var(--primary), 0 0 16px rgba(51, 144, 236, 0.4);
}

.mc-slot.drag-source {
  opacity: 0.42;
  outline: 2px solid #8fc6ff;
}

.mc-slot.drag-target {
  outline: 3px solid #7ee2b7;
  box-shadow: 0 0 15px rgba(126, 226, 183, 0.5);
}

.item-icon {
  width: 78%;
  height: 78%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.item-count {
  position: absolute;
  right: 3px;
  bottom: 0;
  color: #fff;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  pointer-events: none;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(9, var(--slot-size));
  justify-content: center;
  gap: 3px;
  margin-top: 15px;
  padding: 10px;
  border: 2px solid #101820;
  border-top-color: #53616f;
  border-left-color: #53616f;
  border-radius: 4px;
  background: #1a232c;
}

.inventory-grid::after {
  grid-column: 1 / -1;
  height: 8px;
  content: "";
}

.inventory-grid .mc-slot:nth-last-child(-n + 9) {
  margin-top: 4px;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  margin-top: 14px;
  border: 1px dashed rgba(223, 75, 87, 0.72);
  border-radius: 12px;
  background: rgba(223, 75, 87, 0.08);
  color: #ffb0b6;
  font-size: 0.84rem;
  font-weight: 700;
  text-align: center;
  transition: background 0.12s ease, transform 0.12s ease;
}

.drop-zone.drag-target {
  background: rgba(223, 75, 87, 0.3);
  transform: scale(1.02);
}

.drop-zone-icon {
  font-size: 1.25rem;
  font-weight: 900;
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  display: grid;
  width: var(--slot-size);
  height: var(--slot-size);
  place-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 2px solid #9cd0ff;
  border-radius: 4px;
  background: rgba(44, 55, 65, 0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
}

.drag-ghost .item-icon {
  width: 78%;
  height: 78%;
}

.drag-ghost .item-count {
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: #fff;
  font-family: Consolas, "Cascadia Code", monospace;
  font-weight: 900;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.action,
.icon-button,
.text-button,
.toggle {
  border: 0;
  border-radius: 10px;
  color: var(--text);
}

.action {
  min-height: 42px;
  padding: 9px 12px;
  background: var(--surface-hover);
  font-weight: 650;
  transition: background 0.15s ease, transform 0.15s ease;
}

.action:hover {
  background: #2c4050;
}

.action:active,
.icon-button:active,
.toggle:active {
  transform: translateY(1px);
}

.action.primary {
  background: var(--primary);
}

.action.primary:hover {
  background: var(--primary-hover);
}

.action.danger {
  background: var(--danger);
}

.action.danger:hover {
  background: var(--danger-hover);
}

.icon-button {
  width: 34px;
  height: 34px;
  background: var(--surface-hover);
  font-size: 1.25rem;
  line-height: 1;
}

.toggle-list {
  display: grid;
  gap: 8px;
}

.toggle {
  width: 100%;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 13px;
  background: rgba(7, 13, 19, 0.35);
  text-align: left;
}

.toggle:hover {
  background: var(--surface-hover);
}

.toggle strong {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
}

.toggle.is-on strong {
  background: rgba(74, 185, 138, 0.18);
  color: #7ee2b7;
}

.toggle.is-off strong {
  background: rgba(223, 75, 87, 0.17);
  color: #ff9ba3;
}

.form-row {
  align-items: end;
  gap: 10px;
}

label {
  display: grid;
  flex: 1;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

label.grow {
  flex: 2;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: #0d151d;
  color: var(--text);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.18);
}

.custom-command {
  gap: 10px;
}

.custom-command input {
  flex: 1;
}

.console-card {
  margin-bottom: 0;
}

.text-button {
  padding: 5px 0;
  background: transparent;
  color: var(--primary-hover);
  font-size: 0.84rem;
}

.command-log {
  min-height: 72px;
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  background: #0a1118;
  color: #bdcedd;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.drop-dialog {
  width: min(420px, calc(100% - 24px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.drop-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.drop-dialog-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.drop-dialog-content h2,
.drop-dialog-text {
  margin: 0;
}

.drop-dialog-text {
  color: var(--muted);
  line-height: 1.45;
}

.drop-dialog-actions {
  justify-content: flex-end;
  gap: 9px;
}

button:disabled,
input:disabled {
  cursor: wait;
  opacity: 0.6;
}

@media (max-width: 620px) {
  :root {
    --slot-size: calc((100vw - 58px) / 9);
  }

  .app {
    padding: 14px 12px 28px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .equipment-layout {
    gap: 18px;
  }

  .inventory-grid {
    gap: 2px;
    padding: 7px;
  }

  .item-count {
    right: 2px;
    font-size: 0.7rem;
  }
}

@media (max-width: 520px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: end;
  }

  .form-row label.grow {
    grid-column: span 2;
  }

  .form-row .action {
    grid-column: span 2;
  }

  #gotoForm label {
    grid-column: span 1;
  }

  #gotoForm .action {
    grid-column: span 1;
  }

  .drop-zone {
    font-size: 0.74rem;
  }
}