:root {
  --bg: #0f1420;
  --panel: rgba(18, 24, 38, 0.86);
  --panel-solid: #161d2e;
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef2f8;
  --muted: #9aa6bb;
  --accent: #5cc44a;
  --accent-dark: #3a8c2c;
  --danger: #e0533f;
  --gold: #ffd54f;
  --blue: #81d4fa;
  --slot: 46px;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, 'Segoe UI', Roboto, sans-serif; user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
code { background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 5px; user-select: text; }
a { color: var(--blue); }

/* ---------- pantallas ---------- */
#screens { position: fixed; inset: 0; overflow: auto; z-index: 20; }
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 14px; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.45)); }
.screen:has(.topbar) { justify-content: flex-start; }
.loading { text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); }
.panel.narrow { width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
.panel.wide { width: min(980px, 100%); }
.panel h2 { margin: 0 0 4px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: #ff8a7a; min-height: 1em; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }

.logo { font-weight: 900; font-size: 64px; letter-spacing: 1px; text-align: center; line-height: 1; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.5)); }
.logo .l1 { color: #fff; text-shadow: 3px 3px 0 #3d3d3d; }
.logo .l2 { color: var(--accent); text-shadow: 3px 3px 0 #1f4d17; }
.logo.small { font-size: 30px; filter: none; }
.logo.small .l1, .logo.small .l2 { text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field span, .label { font-weight: 600; font-size: 13px; color: var(--muted); }
.field small { color: var(--muted); }
.input { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font: inherit; outline: none; width: 100%; user-select: text; }
.input:focus { border-color: var(--accent); }
.input.small { padding: 6px 10px; width: 160px; }
select.input { padding: 9px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }

.btn { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer; font-weight: 600; transition: transform 0.06s, background 0.15s; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, 0.16); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(#69d055, #43a334); border-color: #2f7b23; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); box-shadow: 0 3px 0 #2c6e21; }
.btn.primary:hover { background: linear-gradient(#78dc64, #4cb03c); }
.btn.danger { background: rgba(224, 83, 63, 0.18); border-color: rgba(224, 83, 63, 0.5); }
.btn.danger:hover { background: rgba(224, 83, 63, 0.35); }
.btn.big { padding: 13px 20px; font-size: 17px; }
.btn.small { padding: 5px 9px; font-size: 13px; }
.download { text-align: center; font-weight: 600; }

/* menú principal */
.topbar { width: 100%; max-width: 1400px; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 20px; }
.who { font-weight: 700; margin-right: 6px; }
.menu { width: 100%; max-width: 1400px; display: grid; grid-template-columns: 280px 1fr 280px; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.worldlist { display: flex; flex-direction: column; gap: 8px; }
.worldcard { text-align: left; background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; border-radius: 9px; padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; }
.worldcard small { grid-column: 1; color: var(--muted); }
.worldcard .online { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 13px; }
.worldcard:hover { background: rgba(255, 255, 255, 0.1); }
.worldcard.on { border-color: var(--accent); background: rgba(92, 196, 74, 0.14); }
.worlddetail { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.mapwrap { display: flex; flex-direction: column; gap: 4px; }
.mapcanvas { width: min(420px, 100%); aspect-ratio: 1; image-rendering: pixelated; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.2); background: #234; }
.charcard { align-items: center; text-align: center; }
canvas.preview { width: 100%; height: 300px; cursor: grab; }
canvas.preview.big { height: 380px; }

.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 4px; }
.typecard { text-align: left; background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; }
.typecard small { color: var(--muted); }
.typecard.on { border-color: var(--accent); background: rgba(92, 196, 74, 0.14); }
.form { display: flex; flex-direction: column; gap: 12px; min-width: min(560px, 80vw); }

/* personaje */
.charscreen { width: 100%; max-width: 1200px; display: grid; grid-template-columns: 1fr 420px; gap: 14px; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.charpick { text-align: left; background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; border-radius: 10px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.charpick .emoji { font-size: 28px; }
.charpick small { color: var(--muted); min-height: 3em; }
.charpick.on { border-color: var(--accent); background: rgba(92, 196, 74, 0.14); }
.lookopts { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.opt > span { font-weight: 600; font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); cursor: pointer; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.opt.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.opt.colors label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
input[type=color] { width: 36px; height: 28px; border: none; background: none; padding: 0; cursor: pointer; }
.stats { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.stats.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.stat span { min-width: 18px; }
.stats:not(.mini) .stat span { min-width: 92px; }
.meter { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
.meter div { height: 100%; background: linear-gradient(90deg, #5cc44a, #b2e85b); }

/* administración */
.adminwrap { display: flex; flex-direction: column; gap: 12px; }
.admin { display: flex; flex-direction: column; gap: 12px; }
.adminbody { display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tab { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; }
.panel.inline .input { width: auto; flex: 1; min-width: 120px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* modal y avisos */
.modal-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { max-width: min(720px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; align-items: center; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); padding: 10px 16px; border-radius: 9px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); transition: opacity 0.4s, transform 0.4s; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud.hidden > *:not(.tint) { display: none; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); mix-blend-mode: difference; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: #fff; }
.crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
.crosshair::after { left: 0; top: 10px; width: 22px; height: 2px; }
.hotbar { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 3px; background: rgba(0, 0, 0, 0.4); padding: 4px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.15); }
.slot { width: var(--slot); height: var(--slot); background: rgba(0, 0, 0, 0.35); border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 6px; position: relative; display: flex; align-items: center; justify-content: center; }
.slot img { width: 82%; height: 82%; image-rendering: pixelated; pointer-events: none; }
.slot .count { position: absolute; right: 3px; bottom: 0; font-weight: 800; font-size: 14px; text-shadow: 2px 2px 0 #000; }
.slot .dur { position: absolute; left: 5px; right: 5px; bottom: 4px; height: 3px; background: #000; }
.slot .dur div { height: 100%; }
.slot.sel { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.12); }
.slot.big { width: calc(var(--slot) * 1.3); height: calc(var(--slot) * 1.3); }
.hotbar .slot::after { content: attr(data-key); position: absolute; left: 4px; top: 1px; font-size: 10px; opacity: 0.6; }
.bars { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); width: calc(9 * var(--slot) + 40px); display: flex; flex-direction: column; gap: 3px; }
.barrow { display: flex; justify-content: space-between; }
.bar { display: flex; gap: 1px; }
.food { flex-direction: row-reverse; }
.ic { width: 18px; height: 18px; display: inline-block; background-size: contain; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6)); }
.ic.heart { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Cpath d='M1 1h3v1h1V1h3v1h1v3H8v1H7v1H6v1H5v1H4V8H3V7H2V6H1V5H0V2h1z' fill='%23300'/%3E%3Cpath d='M1 2h2v1h1v1h1V3h1V2h2v3H7v1H6v1H5v1H4V7H3V6H2V5H1z' fill='%23e53935'/%3E%3Cpath d='M2 2h1v1H2z' fill='%23fff'/%3E%3C/svg%3E"); }
.ic.heart.half { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Cpath d='M1 1h3v1h1V1h3v1h1v3H8v1H7v1H6v1H5v1H4V8H3V7H2V6H1V5H0V2h1z' fill='%23300'/%3E%3Cpath d='M1 2h2v1h1v5H3V6H2V5H1z' fill='%23e53935'/%3E%3Cpath d='M5 3h1V2h2v3H7v1H6v1H5z' fill='%23422'/%3E%3C/svg%3E"); }
.ic.heart.empty { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Cpath d='M1 1h3v1h1V1h3v1h1v3H8v1H7v1H6v1H5v1H4V8H3V7H2V6H1V5H0V2h1z' fill='%23300'/%3E%3Cpath d='M1 2h2v1h1v1h1V3h1V2h2v3H7v1H6v1H5v1H4V7H3V6H2V5H1z' fill='%23422'/%3E%3C/svg%3E"); }
.hearts.low .ic.heart:not(.empty) { animation: shakeh 0.4s infinite; }
@keyframes shakeh { 50% { transform: translateY(-2px); } }
.ic.food { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Cpath d='M4 0h4v1h1v4H8v1H6v1H5v1H3v1H1V8H0V6h1V5h1V4h1V2h1z' fill='%23301'/%3E%3Cpath d='M4 1h4v4H6v1H5v1H4V5H3V3h1z' fill='%23b5651d'/%3E%3Cpath d='M5 2h2v1H5z' fill='%23e8a060'/%3E%3Cpath d='M1 6h2v1h1v1H1z' fill='%23eee'/%3E%3C/svg%3E"); }
.ic.food.half { opacity: 0.75; clip-path: inset(0 0 0 50%); }
.ic.food.empty { opacity: 0.25; filter: grayscale(1); }
.ic.bubble { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'%3E%3Cpath d='M3 1h3v1h1v1h1v3H7v1H6v1H3V7H2V6H1V3h1V2h1z' fill='%2329b6f6'/%3E%3Cpath d='M3 2h2v1H4v1H3z' fill='%23fff'/%3E%3C/svg%3E"); }
.air { justify-content: flex-end; }
.itemname { position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); font-weight: 700; text-shadow: 2px 2px 0 #000; opacity: 0; }
.itemname.fade { animation: fadeName 2.2s forwards; }
@keyframes fadeName { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.modebadge { position: absolute; top: 10px; right: 12px; font-weight: 700; text-shadow: 1px 1px 0 #000; }
.coords { position: absolute; top: 10px; left: 12px; font-weight: 700; text-shadow: 1px 1px 0 #000; font-variant-numeric: tabular-nums; }
.chatlog { position: absolute; left: 10px; bottom: 120px; width: min(520px, 60vw); max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
.chatlog .line { background: rgba(0, 0, 0, 0.45); padding: 3px 8px; border-radius: 4px; text-shadow: 1px 1px 0 #000; transition: opacity 1s; overflow-wrap: anywhere; }
.chatlog .line.old { opacity: 0; }
.chatlog.open .line.old { opacity: 1; }
.chatlog.open { pointer-events: auto; }
.line.info { color: #ffe082; } .line.join, .line.leave { color: #a5d6a7; } .line.death { color: #ef9a9a; } .line.whisper { color: #ce93d8; }
.role-superadmin { color: var(--gold); } .role-admin { color: var(--blue); } .role-user { color: #fff; }
.chatinput { position: absolute; left: 10px; bottom: 84px; width: min(520px, 60vw); pointer-events: auto; background: rgba(0, 0, 0, 0.7); border: 1px solid var(--line); border-radius: 6px; color: #fff; padding: 9px 10px; font: inherit; outline: none; user-select: text; }
.debug { position: absolute; left: 10px; top: 36px; margin: 0; font: 13px/1.45 ui-monospace, Consolas, monospace; background: rgba(0, 0, 0, 0.5); padding: 8px 10px; border-radius: 6px; text-shadow: 1px 1px 0 #000; }
.playerlist { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); min-width: 240px; }
.vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.55); }
.vignette.hit { animation: hit 0.45s; }
@keyframes hit { 0% { box-shadow: inset 0 0 160px rgba(220, 0, 0, 0.75); } 100% { box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.55); } }
.tint { position: absolute; inset: 0; transition: background 0.4s; }
.tint.water { background: rgba(20, 70, 160, 0.22); }
.tint.lava { background: rgba(255, 90, 0, 0.45); }
.tint.sleep { background: rgba(0, 0, 10, 0.75); transition: background 2s; }

/* ---------- inventario ---------- */
#inventory { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.invwrap { display: flex; gap: 14px; align-items: flex-start; max-height: 100%; }
.invwin { display: flex; flex-direction: column; gap: 10px; }
.invhead { display: flex; gap: 8px; align-items: center; }
.invhead h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 3px; }
.grid .slot { cursor: pointer; pointer-events: auto; }
.grid .slot:hover { background: rgba(255, 255, 255, 0.18); }
.grid.hot { margin-top: 6px; }
.cgrid { max-height: 300px; overflow-y: auto; padding-right: 4px; }
.sep { height: 1px; background: var(--line); }
.invtop { display: flex; gap: 18px; align-items: center; justify-content: space-between; }
.charbox { max-width: 240px; display: flex; flex-direction: column; gap: 3px; }
.charname { font-weight: 800; font-size: 17px; }
.craftrow { display: flex; align-items: center; gap: 12px; }
.arrow { font-size: 28px; color: var(--muted); }
.slot.out { border-color: rgba(92, 196, 74, 0.6); }
.cursor-stack { position: fixed; pointer-events: none; z-index: 300; transform: translate(-50%, -50%); background: none !important; border: none !important; }
.trash { cursor: pointer; font-size: 22px; }
.creative { display: flex; flex-direction: column; gap: 8px; }
.furnace { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.furnace .col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fslot { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); }
.flame { font-size: 22px; filter: grayscale(calc(1 - var(--v))); opacity: calc(0.3 + var(--v) * 0.7); }
.progress { height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 5px; overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, #ffb300, #ff6f00); }
.furnace .hint { grid-column: 1 / -1; }
.recipes { width: 360px; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.rlist { display: flex; flex-direction: column; gap: 6px; }
.recipe { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 6px; }
.recipe.dim { opacity: 0.55; }
.rgrid { display: grid; grid-template-columns: repeat(3, 22px); gap: 2px; }
.rcell { width: 22px; height: 22px; background: rgba(0, 0, 0, 0.35); border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.rcell img, .rout img, .smelt img { width: 20px; height: 20px; image-rendering: pixelated; }
.rout { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.rout img { width: 32px; height: 32px; }
.rout small, .smelt small { color: var(--muted); }
.smelt { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.smelt small { margin-left: 6px; }

/* ---------- capas del juego (pausa, muerte...) ---------- */
#ui { position: fixed; inset: 0; z-index: 30; }
.overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay.scroll { align-items: flex-start; overflow: auto; }
.pause { display: flex; flex-direction: column; gap: 10px; width: min(380px, 100%); }
.pause.wide { width: min(640px, 100%); max-height: 92vh; overflow: auto; }
.pause .mapcanvas { width: 100%; }
.slider input { width: 100%; accent-color: var(--accent); }
.keys td { padding: 4px 8px; }
kbd { background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 2px 8px; font: 600 13px system-ui; white-space: nowrap; }
.death { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.death h1 { font-size: 54px; margin: 0; color: #ff6b5b; text-shadow: 3px 3px 0 #000; }
.emotes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 1100px) {
  .menu { grid-template-columns: 1fr; }
  .charscreen { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  :root { --slot: 34px; }
  .logo { font-size: 44px; }
  .invwrap { flex-direction: column; }
  .recipes { width: 100%; }
}

.requests { border-color: rgba(255, 213, 79, 0.5); display: flex; flex-direction: column; gap: 8px; }
.request { background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 8px 10px; }

a.btn { text-decoration: none; display: inline-flex; align-items: center; }
