:root {
  --bg: #14181c;
  --bg-2: #1b2026;
  --card: #20262d;
  --card-2: #272e36;
  --line: #313a44;
  --text: #e6e9ec;
  --muted: #8e99a5;
  --grass: #6aa84f;
  --grass-2: #5b8c32;
  --grass-ink: #0e1a07;
  --dirt: #866043;
  --gold: #e8b64c;
  --red: #e0605a;
  --blue: #5fa8d3;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
b, .mono { font-variant-numeric: tabular-nums; }

/* ---------- bloque de hierba ---------- */
.block-logo {
  width: 52px; height: 52px; border-radius: 6px;
  background:
    linear-gradient(var(--grass) 0 30%, transparent 30%),
    repeating-linear-gradient(90deg, transparent 0 18%, var(--grass-2) 18% 26%, transparent 26% 44%),
    linear-gradient(var(--grass-2) 0 38%, var(--dirt) 38%);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 6px 20px rgba(0,0,0,.35);
  image-rendering: pixelated;
}
.block-logo.sm { width: 34px; height: 34px; border-radius: 5px; flex: none; }
@media (max-width: 480px) { .pill > span { display: none; } .pill { padding: .45rem; } }

/* ---------- botones ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: .65rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover { border-color: #46515d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--grass); border-color: var(--grass); color: var(--grass-ink); }
.btn-primary:hover { background: #79b85c; border-color: #79b85c; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(224,96,90,.12); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

input, select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .75rem; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--grass); outline-offset: 1px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 400px at 50% -10%, rgba(106,168,79,.18), transparent); }
.login-card { width: 100%; max-width: 340px; display: grid; gap: .9rem; text-align: center; }
.login-card .block-logo { margin: 0 auto .4rem; }
.login-card label { display: grid; gap: .3rem; text-align: left; color: var(--muted); font-size: .85rem; }
.form-error { color: var(--red); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* ---------- cabecera y pestañas ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.address {
  background: none; border: 0; padding: 0; color: var(--muted); font: .82rem var(--mono); cursor: pointer;
}
.address:hover { color: var(--grass); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: .25rem .65rem; white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok i { background: var(--grass); box-shadow: 0 0 0 3px rgba(106,168,79,.2); }
.pill.bad i { background: var(--red); }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  max-width: 1100px; margin: 0 auto; padding: 0 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: .7rem .8rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--grass); }

.tab { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }

/* ---------- tarjetas ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: .4rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.two { grid-template-columns: 1fr; } }

.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #222a22, var(--card)); }
.hero-status { display: flex; align-items: center; gap: 14px; }
.hero-title { font-size: 1.25rem; font-weight: 700; }
.status-dot { width: 14px; height: 14px; border-radius: 3px; background: var(--muted); flex: none; }
.status-dot.on { background: var(--grass); box-shadow: 0 0 0 5px rgba(106,168,79,.18); }
.status-dot.off { background: var(--red); }
.status-dot.wait { background: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.hero-stats { display: flex; gap: 22px; }
.hero-stats div { display: grid; }
.hero-stats b { font-size: 1.35rem; }

.metric-head { display: flex; justify-content: space-between; align-items: baseline; }
.metric-head b { font-size: 1.3rem; }
.spark { width: 100%; height: 46px; display: block; margin: 8px 0 6px; overflow: visible; }
.spark path.line { fill: none; stroke: var(--grass); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark path.area { fill: rgba(106,168,79,.14); stroke: none; }
.metric[data-key="temp"] .spark path.line { stroke: var(--gold); }
.metric[data-key="temp"] .spark path.area { fill: rgba(232,182,76,.13); }
.metric[data-key="mem"] .spark path.line { stroke: var(--blue); }
.metric[data-key="mem"] .spark path.area { fill: rgba(95,168,211,.13); }
.cores { display: grid; grid-template-columns: repeat(var(--n, 8), 1fr); gap: 3px; }
.cores i { height: 6px; border-radius: 2px; background: var(--card-2); position: relative; overflow: hidden; }
.cores i::after { content: ""; position: absolute; inset: 0; transform-origin: left;
  transform: scaleX(var(--v, 0)); background: var(--grass); transition: transform .4s; }

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; }
.players img, .avatar { width: 28px; height: 28px; border-radius: 4px; image-rendering: pixelated; background: var(--card-2); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar { flex: 1; height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--grass); width: 0; transition: width .4s; }

/* ---------- acciones ---------- */
.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
@media (max-width: 700px) { .action-grid { grid-template-columns: 1fr 1fr; } }
.action {
  text-align: left; display: grid; gap: 2px; padding: 14px; border-radius: 9px; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text); font: inherit;
}
.action:hover { border-color: var(--grass); }
.action span { color: var(--muted); font-size: .82rem; }
.action.warn:hover { border-color: var(--gold); }
.action:disabled { opacity: .45; cursor: not-allowed; }
.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.danger-zone { border-color: rgba(224,96,90,.35); }
.vote-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.job-banner {
  max-width: 1068px; margin: 12px auto 0; display: flex; align-items: center; gap: 10px;
  background: rgba(232,182,76,.12); border: 1px solid rgba(232,182,76,.4); color: var(--gold);
  border-radius: var(--radius); padding: 10px 14px; margin-inline: 16px;
}
@media (min-width: 1100px) { .job-banner { margin-inline: auto; } }
.job-banner #job-text { flex: 1; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .btns { display: flex; gap: 6px; }
.tag { font-size: .72rem; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--grass); border-color: rgba(106,168,79,.5); }
.tag.err { color: var(--red); border-color: rgba(224,96,90,.5); }
.row { display: flex; gap: 8px; margin: 10px 0; }
.row input { flex: 1; }

/* ---------- consola ---------- */
.log {
  background: #0d1013; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  height: 55vh; overflow: auto; margin: 0; font: 12.5px/1.5 var(--mono); color: #c9d1d9;
  white-space: pre-wrap; word-break: break-word;
}
.log .w { color: var(--gold); } .log .e { color: var(--red); } .log .c { color: var(--grass); }
.prompt { font: 1rem var(--mono); color: var(--grass); align-self: center; }
#console-input { font-family: var(--mono); }
.seg { display: inline-flex; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; background: var(--bg-2); max-width: 100%; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600;
  padding: .4rem .8rem; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button[aria-checked="true"] { background: var(--card-2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.seg button[data-as="player"][aria-checked="true"] { color: var(--grass); }
.seg-hint { margin: .4rem 0 0; }
.cmd-out { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cmd-out li { font: 12.5px/1.45 var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; overflow-wrap: anywhere; }
.cmd-out .cmd { color: var(--grass); }
.cmd-out .who { color: var(--muted); }
.cmd-out .err { color: var(--red); }

/* ---------- diálogo y aviso ---------- */
dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; width: min(92vw, 380px);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: var(--card-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 9px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 32px); z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--red); color: #ffb3ae; }

/* ---------- añadidos: alertas, cuenta, registro ---------- */
.alert-banner {
  max-width: 1068px; margin: 12px 16px 0; display: grid; gap: 4px;
  background: rgba(224,96,90,.1); border: 1px solid rgba(224,96,90,.45); color: #ffb3ae;
  border-radius: var(--radius); padding: 10px 14px;
}
@media (min-width: 1100px) { .alert-banner { margin-inline: auto; } }
.hint { color: var(--muted); font-size: .78rem; }
.login-card a { justify-self: center; text-decoration: none; }
.login-card a:hover { color: var(--grass); }
dialog form { display: grid; gap: .8rem; }
dialog h3 { margin: 0; }
dialog label { display: grid; gap: .3rem; color: var(--muted); font-size: .85rem; }
.dialog-actions.spread { justify-content: space-between; flex-wrap: wrap; }
.dialog-actions.spread span { display: flex; gap: 8px; }
.tabs a { color: var(--muted); font-weight: 600; padding: .7rem .8rem; text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); }

/* ---------- chat ---------- */
.chat-card { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); }
.card-head { flex-wrap: wrap; }
.chat {
  list-style: none; margin: 0; padding: 10px; height: 58vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  background: #0d1013; border: 1px solid var(--line); border-radius: 8px;
}
.chat li { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; line-height: 1.4; }
.chat li.empty { justify-content: center; margin: auto 0; text-align: center; }
.chat time { color: #5e6873; font: .72rem var(--mono); flex: none; }
.chat img { width: 18px; height: 18px; border-radius: 3px; align-self: center; image-rendering: pixelated; }
.chat .who { color: var(--text); }
.chat .msg { overflow-wrap: anywhere; color: #d5dbe0; flex-basis: 100%; padding-left: 46px; margin-top: -3px; }
@media (min-width: 640px) { .chat .msg { flex-basis: auto; padding-left: 0; margin-top: 0; flex: 1; } }
.chat .sys .ev { color: var(--muted); font-size: .9rem; }
.chat .ev.adv { color: var(--gold); }
.chat .ev.death { color: #e79a95; }
.src { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 99px; }
.src.web { background: rgba(95,168,211,.15); color: var(--blue); }
.src.discord { background: rgba(114,137,218,.18); color: #9fb0ee; }

/* ---------- atajos ---------- */
.sc-grid .action:disabled span { opacity: .8; }

/* ---------- estadísticas ---------- */
.ranking { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.ranking li { display: flex; align-items: center; gap: 10px; }
.ranking .pos { width: 1.6em; text-align: right; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking li:nth-child(1) .pos { color: var(--gold); }
.ranking .rank-name { font-weight: 600; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.ranking .rank-val { min-width: 5.5em; text-align: right; }
.avatar { width: 28px; height: 28px; border-radius: 4px; image-rendering: pixelated; background: var(--card-2); flex: none; }
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.pcard-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.pcard-head img { width: 40px; height: 40px; border-radius: 6px; image-rendering: pixelated; }
.pstats { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 10px; margin: 0 0 12px; font-size: .9rem; }
.pstats dt { color: var(--muted); }
.pstats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.pfun { display: grid; gap: 4px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.pfun b { color: var(--text); text-transform: capitalize; }

/* ---------- usuarios ---------- */
.invite-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 10px 0; }
.invite-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; }
.list select { padding: .35rem .5rem; font-size: .85rem; }

.sessions-box { border-top: 1px solid var(--line); padding-top: 10px; }
.sessions-box .list li { padding: 7px 0; }
dialog { max-height: 90vh; overflow-y: auto; }

/* ---------- mundos ---------- */
.world-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; margin: 10px 0; }
.world-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; min-width: 0; }
.world-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
.world-form label.check input { width: auto; margin: 0; accent-color: var(--grass); }
.world-form .btn { justify-self: start; }
.worlds li.active-world .title { color: var(--grass); }
.worlds .title { font-weight: 600; }
.progress { height: 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; margin: 12px 0 6px; }
.progress-bar { height: 100%; width: 0; background: var(--grass); transition: width .6s; }
.pregen-form { display: grid; gap: 12px; margin: 12px 0 6px; }
.pregen-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .8rem; max-width: 360px; }
.pregen-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; max-width: none; }
.pregen-form label.check input { width: auto; margin: 0; accent-color: var(--grass); }
.pregen-form .btns { display: flex; gap: 8px; flex-wrap: wrap; }
#pregen-out { white-space: pre-wrap; word-break: break-word; }
code { font-family: ui-monospace, monospace; background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
