:root {
  --bg: #070a10;
  --bg-2: #0a0f17;
  --panel: #0f1520;
  --panel-2: #131b27;
  --line: #1d2836;
  --line-2: #27374a;
  --text: #e6edf7;
  --muted: #8497af;
  --accent: #4ade80;
  --accent-soft: rgba(74, 222, 128, 0.14);
  --info: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(56, 189, 248, 0.1), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(74, 222, 128, 0.09), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------- topbar ------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(7, 10, 16, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  background: linear-gradient(160deg, #16352a, #0d1a24);
  border: 1px solid #23503c;
  box-shadow: 0 0 22px rgba(74, 222, 128, 0.18);
}

.brand-txt h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.4px;
}

.brand-txt p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-state {
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

.link-state.off {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.link-state.on {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.3);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--muted);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #55637a;
}

.status-pill[data-status="online"] {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
}

.status-pill[data-status="online"] .dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.status-pill[data-status="connecting"] {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
}

.status-pill[data-status="connecting"] .dot {
  background: var(--warn);
  animation: pulse 1s infinite;
}

.status-pill[data-status="offline"] {
  color: #93a3b8;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ------------------------------- layout ------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr) 358px;
  gap: 16px;
  align-items: start;
  padding: 18px 20px 40px;
  max-width: 1720px;
  margin: 0 auto;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: #c6d4e6;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head .card-title {
  margin: 0;
}

.card-sub {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.count-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

/* ------------------------------- forms ------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
  min-height: 42px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}

.hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.hint code {
  color: var(--text);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(74, 222, 128, 0.6);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.row-2 {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, #2ecc71, #1f9d57);
  border-color: #37e282;
  color: #04120a;
  box-shadow: 0 6px 18px rgba(46, 204, 113, 0.22);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #3ce083, #24b063);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: #b9c7d9;
}

.btn.ghost:hover {
  border-color: #3a4f68;
  background: rgba(255, 255, 255, 0.03);
}

.btn.subtle {
  background: rgba(56, 189, 248, 0.07);
  border-color: rgba(56, 189, 248, 0.25);
  color: #8ed8f8;
  font-size: 12px;
  padding: 8px 10px;
}

.btn.subtle:hover {
  background: rgba(56, 189, 248, 0.14);
}

.btn.small {
  padding: 6px 10px;
  font-size: 11.5px;
}

.ping-result {
  font-size: 11.5px;
  line-height: 1.55;
  color: #b9c7d9;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 9px;
  padding: 9px 11px;
  word-break: break-word;
}

.ping-result.err {
  color: #ffc9c9;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.25);
}

.ping-result b {
  color: #fff;
}

/* ------------------------------- stats ------------------------------- */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
}

.stat.wide {
  grid-column: span 2;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.bar {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: #101823;
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar .fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.fill.health {
  background: linear-gradient(90deg, #e05555, #ff7b7b);
}

.fill.food {
  background: linear-gradient(90deg, #b7791f, #fbbf24);
}

.bar b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ------------------------------- joueurs ------------------------------- */
.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12.5px;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-ping {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.player-btn {
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 2px 7px;
  font-size: 11px;
}

.player-btn:hover {
  color: var(--info);
  border-color: rgba(56, 189, 248, 0.4);
}

.empty-line {
  justify-content: center;
  color: var(--muted);
  font-style: italic;
}

/* ------------------------------- slots ------------------------------- */
.window-zone {
  min-height: 120px;
}

.placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  padding: 26px 16px;
  color: var(--muted);
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.012);
}

.placeholder p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.ph-icon {
  font-size: 22px;
  opacity: 0.7;
}

.placeholder.small {
  padding: 16px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}

.slots + .slots {
  margin-top: 8px;
}

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  aspect-ratio: 1;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid #1a2534;
  background: #0a1119;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.slot:hover {
  border-color: #3b5170;
  background: #101a26;
}

.slot:active {
  transform: scale(0.97);
}

.slot.empty {
  background: rgba(255, 255, 255, 0.018);
}

.slot.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(74, 222, 128, 0.22);
  background: rgba(74, 222, 128, 0.07);
}

.slot.hot {
  border-color: rgba(74, 222, 128, 0.5);
}

.glyph {
  font-size: 16px;
  line-height: 1.1;
}

.slot-name {
  max-width: 100%;
  font-size: 7.5px;
  line-height: 1.1;
  text-align: center;
  color: #8ea3bb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.count {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 0 3px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
}

.hotkey {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 8px;
  font-family: var(--mono);
  color: #7fdba2;
}

.inv-zone .slots:last-child {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.armor-row {
  display: flex;
  gap: 5px;
}

.armor-row .slot {
  width: 30px;
  aspect-ratio: 1;
}

.armor-row .glyph {
  font-size: 13px;
}

.armor-row .slot-name {
  display: none;
}

/* ------------------------------- sélection ------------------------------- */
.selection-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-color: rgba(74, 222, 128, 0.35);
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.07), var(--panel));
}

.sel-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sel-glyph {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  font-size: 20px;
  background: #0c1520;
  border: 1px solid var(--line-2);
}

.sel-main h3 {
  margin: 0;
  font-size: 14px;
}

.sel-main p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.sel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ------------------------------- pad ------------------------------- */
.pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.pad-btn {
  cursor: pointer;
  height: 46px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #16202d, #101823);
  color: #d3e0ef;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  user-select: none;
  touch-action: none;
  transition: background 0.1s, border-color 0.1s, transform 0.06s;
}

.pad-btn:hover {
  border-color: #3a5271;
}

.pad-btn.active {
  background: linear-gradient(180deg, #2ecc71, #1f9d57);
  border-color: #37e282;
  color: #04120a;
  transform: translateY(1px);
}

.pad-btn.stop {
  color: #ffb3b3;
  border-color: rgba(248, 113, 113, 0.35);
}

.pad-btn.stop:hover {
  background: rgba(248, 113, 113, 0.12);
}

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  margin-top: 12px;
}

.hotbar button {
  cursor: pointer;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0a1119;
  color: #8ea3bb;
  font-family: var(--mono);
  font-size: 11px;
}

.hotbar button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(74, 222, 128, 0.1);
}

/* ------------------------------- console ------------------------------- */
.console-card {
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.log {
  flex: 1;
  min-height: 240px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: #060a10;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  scrollbar-width: thin;
}

.log::-webkit-scrollbar,
.player-list::-webkit-scrollbar {
  width: 8px;
}

.log::-webkit-scrollbar-thumb,
.player-list::-webkit-scrollbar-thumb {
  background: #1e2b3b;
  border-radius: 99px;
}

.log-line {
  display: flex;
  gap: 7px;
  padding: 1px 0;
  word-break: break-word;
}

.log-time {
  flex: none;
  color: #46586e;
  font-size: 10.5px;
  padding-top: 1px;
}

.log-msg {
  min-width: 0;
}

.log-line.chat .log-msg {
  color: #d7e5f5;
}

.log-line.chat .log-player {
  color: var(--info);
  font-weight: 700;
}

.log-line.info .log-msg {
  color: #8fa3bb;
}

.log-line.system .log-msg {
  color: #b9a7e8;
}

.log-line.action .log-msg {
  color: #7fdba2;
}

.log-line.success .log-msg {
  color: var(--accent);
  font-weight: 700;
}

.log-line.out .log-msg {
  color: #fbd38d;
}

.log-line.error .log-msg {
  color: var(--danger);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 8px;
}

.chip {
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: #9fb1c7;
  font-family: var(--mono);
  font-size: 11px;
}

.chip:hover {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.07);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
}

.chat-form:focus-within {
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}

.chat-form .prompt {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}

.chat-form input {
  flex: 1;
  padding: 6px 0;
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: var(--mono);
  font-size: 12.5px;
}

.chat-form input:focus {
  box-shadow: none;
  border: none;
}

/* ------------------------------- toast ------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1a0d0d;
  background: var(--danger);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

/* ------------------------------- responsive ------------------------------- */
@media (max-width: 1360px) {
  .layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .col-right {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 12px 32px;
  }
  .col-right {
    grid-column: span 1;
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    padding: 12px 14px;
  }
  .brand-txt p {
    display: none;
  }
  .link-state {
    display: none;
  }
  .slots {
    gap: 4px;
  }
  .slot-name {
    display: none;
  }
}

/* ------------------------------- commandes ------------------------------- */
.cmd-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.cmd-group h3 {
  margin: 0 0 5px;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.cmd-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cmd-list .chip {
  font-size: 10.5px;
}

.card .card-sub + .cmd-groups {
  margin-top: 10px;
}
