:root {
  --panel: rgba(14, 20, 24, 0.78);
  --panel-solid: #121a1f;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f1ece1;
  --muted: #a9b1ad;
  --accent: #f2b544;
  --accent-2: #3cc4a6;
  --danger: #ff5a4f;
  --good: #7fdc6f;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #000; color: var(--text);
  font-family: 'Nunito', system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px;
  border: 1px solid rgba(255,255,255,.35); border-bottom-width: 2px; border-radius: 5px;
  background: rgba(255,255,255,.1); font: 700 12px 'Nunito', sans-serif; text-align: center; color: #fff;
}

/* ---------- pantallas ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 50; background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.55));
}
#loading { background: #0b1418; z-index: 100; }
.load-box { text-align: center; }
.load-box p { color: var(--muted); font-size: 16px; max-width: 420px; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.12); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.menu-card {
  width: min(560px, calc(100vw - 32px)); padding: 34px 36px 30px;
  background: linear-gradient(180deg, rgba(18,28,32,.86), rgba(10,16,18,.9));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55); backdrop-filter: blur(6px);
  text-align: center;
}
.small-card { width: min(420px, calc(100vw - 32px)); }
.menu-card h1 {
  font-family: 'Cinzel', serif; font-weight: 900; font-size: 54px; margin: 0 0 6px; letter-spacing: 2px;
  background: linear-gradient(180deg, #ffe3a3, #e59a3a); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 30px rgba(229,154,58,.25);
}
.menu-card h2 { font-family: 'Cinzel', serif; font-size: 30px; margin: 0 0 16px; }
.menu-card h3 { margin: 10px 0 14px; font-weight: 800; }
.tagline { color: var(--muted); margin: 0 0 26px; line-height: 1.5; }
.tagline b { color: var(--accent); }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.btn {
  font: 800 16px 'Nunito', sans-serif; color: var(--text); cursor: pointer;
  padding: 13px 18px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255,255,255,.06); transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.25); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #f2b544, #d98f22); color: #1d1406; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { font-size: 14px; padding: 9px 14px; font-weight: 600; }
.back { margin-top: 16px; }
.warn-text { color: var(--accent); font-size: 13px; }

.diff-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.diff {
  cursor: pointer; padding: 16px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--text); font-family: 'Nunito', sans-serif;
  display: flex; flex-direction: column; gap: 8px; transition: all .15s;
}
.diff b { font-size: 18px; }
.diff span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.diff:hover { border-color: var(--accent); background: rgba(242,181,68,.1); transform: translateY(-2px); }
.diff[data-d="2"]:hover { border-color: var(--danger); background: rgba(255,90,79,.1); }

.controls-list {
  display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; text-align: left;
  font-size: 14px; margin: 6px auto 0; max-width: 420px;
}
.controls-list div:nth-child(odd) { text-align: right; white-space: nowrap; }
#pauseControls { margin-top: 16px; }

.dead-card h2 { color: var(--danger); }
.win-card h2 { color: var(--good); }
#deadCause { font-size: 18px; font-weight: 800; }
#winStats { line-height: 1.7; color: var(--muted); }
#winStats b { color: var(--text); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#clock {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; padding: 7px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 16px;
}
#timeLabel { color: var(--muted); font-variant-numeric: tabular-nums; }
#objective {
  position: absolute; top: 14px; left: 14px; max-width: 330px; padding: 10px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); font-size: 14px; line-height: 1.35;
}
#objective small { display: block; color: var(--accent); font-weight: 800; letter-spacing: 1.5px; font-size: 10.5px; margin-bottom: 3px; }
#objective.flash { animation: objflash 1.2s ease; }
@keyframes objflash { 0% { box-shadow: 0 0 0 0 rgba(242,181,68,.9); } 100% { box-shadow: 0 0 0 18px rgba(242,181,68,0); } }
#minimapWrap { position: absolute; top: 14px; right: 14px; width: 180px; height: 180px; }
#minimap { width: 180px; height: 180px; border-radius: 50%; border: 3px solid rgba(255,255,255,.18); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#minimapWrap .n { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 12px; text-shadow: 0 1px 3px #000; }

#stats {
  position: absolute; left: 14px; bottom: 14px; padding: 12px 14px; border-radius: 14px; width: 250px;
  background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px;
}
.stat { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.bar { flex: 1; height: 11px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; border-radius: 6px; transition: width .25s; }
.bar i.health { background: linear-gradient(90deg, #d4302b, #ff6b5a); }
.bar i.hunger { background: linear-gradient(90deg, #c7771f, #f2b544); }
.bar i.thirst { background: linear-gradient(90deg, #1f7fc7, #50c8ff); }
.bar i.stamina { background: linear-gradient(90deg, #b6c23a, #eaf06a); }
.bar i.low { animation: pulse 0.8s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .35; } }
#statusIcons { font-size: 12.5px; color: var(--accent); min-height: 0; }
.temp-bar { position: relative; }
.temp-bar b { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: rgba(255,255,255,.55); }
#bossBar { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(420px, 60vw); text-align: center; }
#bossName { font-family: 'Cinzel', serif; font-weight: 900; font-size: 17px; color: #ffcf8a; text-shadow: 0 2px 6px #000; margin-bottom: 4px; }
#bossBar .bar { height: 12px; border: 1px solid rgba(255,255,255,.25); }
#bossFill { background: linear-gradient(90deg, #8a1010, #e0402a); }
.chest-grid { margin-bottom: 4px; }
.chest-grid .slot { background: rgba(242,181,68,.07); border-color: rgba(242,181,68,.18); }
#statusIcons:empty { display: none; }

#hotbar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
}
.slot {
  position: relative; width: 58px; height: 58px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.slot.sel { border-color: var(--accent); background: rgba(242,181,68,.16); box-shadow: 0 0 14px rgba(242,181,68,.35); }
.slot .num { position: absolute; top: 2px; left: 5px; font-size: 11px; font-weight: 800; color: var(--muted); }
.slot .cnt { position: absolute; bottom: 1px; right: 5px; font-size: 13px; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.slot .dur { position: absolute; left: 6px; right: 6px; bottom: 4px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.5); overflow: hidden; }
.slot .dur i { display: block; height: 100%; background: var(--good); }
#heldName {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%);
  font-weight: 800; font-size: 15px; text-shadow: 0 2px 6px #000; transition: opacity .4s; opacity: 0;
}
#heldName.show { opacity: 1; }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35); opacity: .85;
}
#crosshair.active { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: transparent; border: 2px solid var(--accent); }
#prompt {
  position: absolute; top: calc(50% + 26px); left: 50%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 10px; background: rgba(0,0,0,.55); font-size: 14.5px; white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
#prompt:empty { display: none; }
#prompt .warn { color: var(--accent); }
#prompt .hp { display: inline-block; width: 60px; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; margin-left: 8px; vertical-align: middle; overflow: hidden; }
#prompt .hp i { display: block; height: 100%; background: var(--danger); }

#messages {
  position: absolute; left: 14px; bottom: 232px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start;
}
.msg {
  padding: 6px 12px; border-radius: 9px; background: rgba(0,0,0,.6); font-size: 14px; font-weight: 600;
  border-left: 3px solid rgba(255,255,255,.3); animation: msgin .25s ease; transition: opacity .6s, transform .6s;
}
.msg.good { border-left-color: var(--good); }
.msg.warn { border-left-color: var(--accent); }
.msg.bad { border-left-color: var(--danger); }
.msg.item { border-left-color: var(--accent-2); }
.msg.out { opacity: 0; transform: translateX(-20px); }
@keyframes msgin { from { opacity: 0; transform: translateX(-20px); } }

#banner {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel', serif; font-size: 52px; font-weight: 900; letter-spacing: 3px;
  color: #ffe6b0; text-shadow: 0 4px 30px rgba(0,0,0,.7); opacity: 0; transition: opacity 1s; text-align: center;
}
#banner small { display: block; font-family: 'Nunito', sans-serif; font-size: 18px; letter-spacing: 0; color: var(--text); font-weight: 600; }
#banner.show { opacity: 1; }

#vignette {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(190,0,0,.75) 100%);
}
#keyhint { position: absolute; bottom: 90px; right: 14px; font-size: 12px; color: rgba(255,255,255,.7); text-shadow: 0 1px 3px #000; }

/* ---------- Inventario ---------- */
#inventory {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
}
.inv-wrap {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 22px;
  width: min(1200px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  padding: 24px; border-radius: 18px; background: rgba(14,20,24,.94); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.inv-wrap h2 { font-family: 'Cinzel', serif; margin: 0 0 4px; font-size: 24px; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.inv-label { font-size: 11px; letter-spacing: 1.5px; font-weight: 800; color: var(--muted); margin: 10px 0 6px; text-transform: uppercase; }
.inv-grid { display: grid; grid-template-columns: repeat(8, 58px); gap: 6px; }
.inv-grid .slot { cursor: pointer; }
.inv-grid .slot:hover { border-color: rgba(255,255,255,.35); }
.inv-grid .slot.picked { border-color: var(--accent-2); box-shadow: 0 0 12px rgba(60,196,166,.5); }
#itemInfo { margin-top: 14px; min-height: 76px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.04); font-size: 13.5px; line-height: 1.45; max-width: 506px; }
#itemInfo b { font-size: 15px; }
#itemInfo button { margin-top: 6px; }
.craft-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#craftTabs { display: flex; gap: 6px; margin: 12px 0 6px; flex-wrap: wrap; max-width: 506px; }
#craftTabs button {
  cursor: pointer; font: 700 13.5px 'Nunito', sans-serif; padding: 7px 13px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text);
}
#craftTabs button.on { background: var(--accent); color: #1d1406; border-color: transparent; }
/* Recetario (libro de todos los objetos) */
#craftTabs button.book-tab { border-color: rgba(60,196,166,.55); }
#craftTabs button.book-tab.on { background: var(--accent-2); color: #06201a; }
.req[data-book], .recipe .ic[data-book] { cursor: pointer; }
.req[data-book]:hover { background: rgba(255,255,255,.15); }
.bk-head { position: sticky; top: 0; z-index: 2; background: rgb(14,20,24); padding-bottom: 8px; }
#bookSearch { width: 100%; box-sizing: border-box; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); font: 600 14px 'Nunito', sans-serif; outline: none; }
#bookSearch:focus { border-color: var(--accent-2); }
.bk-cats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.bk-cats button { cursor: pointer; font: 700 12px 'Nunito', sans-serif; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); }
.bk-cats button.on { background: var(--accent-2); color: #06201a; border-color: transparent; }
#bookList { display: flex; flex-direction: column; gap: 7px; }
.bk-item { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 12px; border-radius: 11px; background: rgba(255,255,255,.04); border: 1px solid transparent; }
.bk-item.focus { border-color: var(--accent-2); background: rgba(60,196,166,.09); }
.bk-ic { font-size: 34px; text-align: center; }
.bk-ic img.ico { width: 48px; height: 48px; }
.bk-nm { font-weight: 800; font-size: 15px; }
.bk-have { font-size: 11.5px; font-weight: 700; color: var(--good); background: rgba(127,220,111,.12); padding: 1px 7px; border-radius: 6px; margin-left: 4px; }
.bk-ds { color: var(--muted); font-size: 12.5px; margin: 1px 0 3px; }
.bk-h { font-size: 10.5px; letter-spacing: 1px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin: 7px 0 2px; }
.bk-src { margin: 0; padding-left: 16px; font-size: 13px; line-height: 1.5; }
.bk-src li { margin: 1px 0; }
.bk-lock { color: #f2b544; font-size: 12px; }
.bk-link { cursor: pointer; color: #9fe0d0; font-weight: 700; white-space: nowrap; }
.bk-link:hover { text-decoration: underline; }
.bk-uses { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 13px; }
.bk-trade { font-size: 12.5px; color: var(--muted); }
.bk-empty { padding: 20px; text-align: center; }
.bk-act { margin: 6px 0 4px; padding: 8px 10px; border-radius: 9px; background: rgba(60,196,166,.1); border: 1px solid rgba(60,196,166,.3); font-size: 13px; line-height: 1.5; }
.bk-act .btn { margin: 6px 6px 0 0; }
.bk-act .small-text { font-size: 11.5px; }
#hoverTip { position: fixed; z-index: 90; pointer-events: none; padding: 5px 10px; border-radius: 8px; background: rgba(10,14,18,.96); border: 1px solid var(--line); font-size: 13px; color: var(--text); white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
#hoverTip small { display: block; color: var(--muted); font-size: 11px; }
#recipes { overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding-right: 6px; max-height: calc(100vh - 90px); }
.inv-label.inv-first { margin-top: 26px; }
.inv-col .inv-label { margin-top: 16px; }
.inv-col .inv-label.inv-first { margin-top: 26px; }
.recipe {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: 11px; background: rgba(255,255,255,.04); border: 1px solid transparent;
}
.recipe.ok { border-color: rgba(127,220,111,.3); background: rgba(127,220,111,.06); }
.recipe .ic { font-size: 30px; text-align: center; }
.recipe .nm { font-weight: 800; font-size: 15px; }
.recipe .ds { color: var(--muted); font-size: 12.5px; margin: 1px 0 4px; }
.req { display: inline-block; margin: 2px 6px 0 0; padding: 1px 7px; border-radius: 6px; font-size: 12.5px; font-weight: 700; background: rgba(255,255,255,.07); }
.req.ok { color: var(--good); }
.req.no { color: #ff8a80; }
.recipe button {
  cursor: pointer; font: 800 13.5px 'Nunito', sans-serif; padding: 8px 14px; border-radius: 9px; border: none;
  background: var(--accent); color: #1d1406;
}
.recipe button:disabled { background: rgba(255,255,255,.1); color: var(--muted); cursor: not-allowed; }
.close {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); font-size: 16px; cursor: pointer;
}
.close:hover { background: rgba(255,255,255,.15); }

/* ---------- Mapa ---------- */
#bigmap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
.map-card { padding: 16px; border-radius: 18px; background: rgba(14,20,24,.94); border: 1px solid var(--line); }
#bigmapCanvas { display: block; width: min(640px, calc(100vh - 120px), calc(100vw - 64px)); height: auto; border-radius: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; justify-content: center; max-width: 640px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

#clickToPlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.3); cursor: pointer;
}
#clickToPlay div { padding: 14px 24px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 18px; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 80; transition: opacity 1.2s; }
#fade.on { opacity: 1; }

/* ---------- Multijugador ---------- */
.mp-info { text-align: left; font-size: 14.5px; line-height: 1.5; }
.mp-info ol { padding-left: 20px; }
.mp-label { display: block; text-align: left; font-size: 13px; font-weight: 800; color: var(--muted); margin: 8px 0 6px; letter-spacing: .5px; }
#mpName {
  display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.07); color: var(--text); font: 700 16px 'Nunito', sans-serif; outline: none;
}
#mpName:focus { border-color: var(--accent); }
#mpColors { display: flex; gap: 8px; margin-bottom: 16px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
#mpConnect { width: 100%; }
#mpPlayers { list-style: none; padding: 0; margin: 10px 0 16px; text-align: left; }
#mpPlayers li, #playerList div { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-weight: 700; }
#mpPlayers i, #playerList i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
#mpLobbyText { line-height: 1.5; }
#mpHostOpts .btn { width: 100%; margin-bottom: 10px; }
#fps { position: absolute; top: 198px; right: 16px; font-size: 11.5px; font-weight: 800; color: rgba(255,255,255,.7); text-shadow: 0 1px 2px #000; }
#playerList { position: absolute; top: 216px; right: 14px; min-width: 150px; padding: 0; font-size: 13px; text-shadow: 0 1px 3px #000; }
#playerList:not(:empty) { padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
#playerList small { color: var(--accent); font-weight: 800; font-size: 10.5px; letter-spacing: 1px; }
#chatInput {
  position: absolute; left: 14px; bottom: 192px; width: 360px; padding: 9px 12px; border-radius: 10px; pointer-events: auto;
  border: 1px solid var(--accent); background: rgba(0,0,0,.75); color: #fff; font: 600 14px 'Nunito', sans-serif; outline: none;
}
.msg.chat { border-left-color: #9fd3ff; background: rgba(0,0,0,.7); }

@media (max-width: 900px) {
  .inv-wrap { grid-template-columns: 1fr; overflow-y: auto; }
  .inv-grid { grid-template-columns: repeat(8, 44px); }
  #craftTabs { max-width: 394px; }
  .inv-grid .slot { width: 44px; height: 44px; font-size: 22px; }
  #objective { max-width: 220px; font-size: 12.5px; }
  .diff-cards { grid-template-columns: 1fr; }
}

/* ---------- Archipiélago: HUD nuevo ---------- */
#islandLabel { color: var(--accent); font-size: 13px; font-weight: 800; }
#islandLabel:empty { display: none; }
#compass {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 13.5px;
}
#compassArrow { width: 26px; height: 26px; border-radius: 50%; background: #f4ecd8; color: #b8231a; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: transform .15s linear; box-shadow: inset 0 0 0 2px #c8a050; }
#compassArrow { transform-origin: 50% 50%; }
#vsHud { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; text-align: center; }
#compass:not(.hidden) ~ #vsHud { top: 100px; }
.vs-teams { display: flex; gap: 8px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.vs-team { padding: 2px 9px; border-radius: 8px; border: 2px solid var(--tc); font-weight: 800; font-size: 13px; }
.vs-team.me { background: color-mix(in srgb, var(--tc) 30%, transparent); }
#vsHud .warn { color: var(--accent); font-weight: 800; margin-top: 4px; }
.team-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.bar i.oxy { background: linear-gradient(90deg, #3aa0d8, #a8e8ff); }
#shipHud {
  position: absolute; right: 14px; bottom: 110px; width: 250px; padding: 10px 13px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; line-height: 1.55;
}
#shipHud .sh-name { font-family: 'Cinzel', serif; font-weight: 900; font-size: 15px; }
#shipHud .sh-hp { height: 8px; margin: 3px 0 5px; }
#shipHud .sh-hp i { background: linear-gradient(90deg, #8a5a30, #e0a060); }
#shipHud .wind { display: inline-block; transition: transform .3s; font-weight: 900; color: #9fd3ff; }
#powerHud { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); padding: 4px 12px; border-radius: 10px; background: rgba(60,20,70,.7); border: 1px solid rgba(220,160,255,.4); font-size: 13px; }
#heldName { bottom: 120px; }

/* ---------- Diálogo ---------- */
#dialog {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 40; width: min(640px, calc(100vw - 32px));
  padding: 16px 20px; border-radius: 14px; background: rgba(22,16,10,.94); border: 2px solid #8a6a3a; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.dlg-who { font-family: 'Cinzel', serif; font-weight: 900; color: #f2c46a; font-size: 17px; margin-bottom: 6px; }
.dlg-text { font-size: 16px; line-height: 1.5; }
.dlg-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.dlg-opts button { text-align: left; cursor: pointer; font: 700 14.5px 'Nunito', sans-serif; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); }
.dlg-opts button:hover { background: rgba(242,181,68,.18); border-color: var(--accent); }

/* ---------- Bitácora ---------- */
#journal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
.journal-card {
  position: relative; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 60px); overflow-y: auto; padding: 24px 28px; border-radius: 18px;
  background: linear-gradient(180deg, #2a2016, #1c150e); border: 2px solid #6a5030; color: #f1e6cf;
}
.journal-card h2 { font-family: 'Cinzel', serif; margin: 0 0 8px; }
.journal-card h3 { margin: 16px 0 6px; color: #f2c46a; font-size: 16px; }
.journal-card ul { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 14px; }
.journal-card li { margin-bottom: 4px; }

/* ---------- Mapa ---------- */
#bigmapCanvas { cursor: crosshair; }
.map-info { font-size: 12px; margin: 6px 0 0; text-align: center; }

/* ---------- Lobby LAN ---------- */
.mp-input, #mpName {
  display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.07); color: var(--text); font: 700 16px 'Nunito', sans-serif; outline: none;
}
.mp-input:focus { border-color: var(--accent); }
#mpAddr { margin-bottom: 14px; }
#mpModeTabs { display: flex; gap: 8px; margin: 6px 0 12px; }
#mpModeTabs button { flex: 1; cursor: pointer; font: 800 15px 'Nunito', sans-serif; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); }
#mpModeTabs button.on { background: var(--accent); color: #1d1406; border-color: transparent; }
#mpModeTabs button:disabled { cursor: default; }
.menu-card { max-height: calc(100vh - 30px); overflow-y: auto; }
.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; text-align: left; font-size: 13px; font-weight: 800; color: var(--muted); }
.vs-grid .wide { grid-column: 1 / -1; }
.vs-grid select, .opt-row select { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: #1b2328; color: var(--text); font: 700 13.5px 'Nunito', sans-serif; }
.opt-row { display: block; text-align: left; font-size: 13px; font-weight: 800; color: var(--muted); margin: 12px 0 4px; }
.vs-checks { display: flex; flex-direction: column; gap: 5px; text-align: left; font-size: 13.5px; margin: 12px 0; }
.vs-checks b { color: var(--accent); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin-top: 6px; }
.vs-checks .sub { padding-left: 24px; }
.vs-checks select { margin-left: 6px; padding: 3px 6px; border-radius: 6px; background: #1b2328; color: var(--text); border: 1px solid var(--line); }
#mpTeams { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.team-btn { cursor: pointer; padding: 8px; border-radius: 10px; border: 2px solid var(--tc); background: rgba(255,255,255,.04); color: var(--text); font: 700 13px 'Nunito', sans-serif; text-align: center; }
.team-btn.on { background: color-mix(in srgb, var(--tc) 35%, transparent); }
.team-btn small { color: var(--muted); }
#vsStart { width: 100%; margin-top: 6px; }
.small-text { font-size: 13px; }
.version { font-size: 12px; margin: 6px 0 0; }

#underwater { position: fixed; inset: 0; z-index: 5; pointer-events: none; background: radial-gradient(ellipse at center, rgba(30,120,150,.22), rgba(8,50,80,.55)); }

#btnDownloads { text-decoration: none; display: block; }
.update-note { font-size: 13px; color: var(--good); margin: 6px 0 0; }
.update-note .btn { margin-left: 6px; padding: 5px 10px; font-size: 12.5px; }
.mp-ips { font-size: 13px; line-height: 1.5; padding: 8px 12px; border-radius: 10px; background: rgba(60,196,166,.1); border: 1px solid rgba(60,196,166,.35); }

.equip-grid { grid-template-columns: repeat(4, 58px); }
.eq-slot { cursor: pointer; background: rgba(160,120,255,.08); border-color: rgba(160,120,255,.25); }
.eq-slot.filled { border-color: rgba(160,120,255,.6); }
.eq-ph { opacity: .28; filter: grayscale(1); }
.eq-line { color: #b8a4ff; }
#eqStats { letter-spacing: 0; text-transform: none; font-weight: 700; margin-left: 8px; }

/* ---------- Iconos del paquete de texturas (img/items) ---------- */
img.ico { width: 1.3em; height: 1.3em; vertical-align: -0.3em; object-fit: contain; pointer-events: none; user-select: none; }
img.ico.xs { width: 1.25em; height: 1.25em; vertical-align: -0.32em; }
img.ico.sm { width: 1.6em; height: 1.6em; vertical-align: -0.45em; }
.slot img.ico { width: 78%; height: 78%; vertical-align: middle; filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); }
.recipe .ic img.ico { width: 44px; height: 44px; }

/* ---------- Controles táctiles (touch.js): móvil y tableta ---------- */
body.touch, body.touch #game canvas { touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#tLook { position: fixed; inset: 0; z-index: 5; touch-action: none; }
#tJoy { position: fixed; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.08), rgba(255,255,255,.16)); border: 2px solid rgba(255,255,255,.35); transition: opacity .12s; }
#tJoy.on { opacity: 1; }
#tJoy i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; border-radius: 50%; transform: translate(-50%, -50%);
  background: rgba(255,255,255,.55); box-shadow: 0 2px 10px rgba(0,0,0,.4); }
#tUI { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
.t-btn { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 2px solid rgba(255,255,255,.28);
  background: rgba(14,20,24,.55); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  width: 56px; height: 56px; padding: 0; backdrop-filter: blur(2px); box-shadow: 0 3px 10px rgba(0,0,0,.35); -webkit-tap-highlight-color: transparent; }
.t-btn .ti { font-size: 22px; line-height: 1; }
.t-btn .tt { font-size: 8.5px; font-weight: 800; letter-spacing: .2px; opacity: .85; margin-top: 2px; white-space: nowrap; }
.t-btn.down { background: rgba(242,181,68,.55); border-color: var(--accent); transform: scale(.94); }
.t-btn.cd { opacity: .45; }
.t-btn.hidden { display: none; }
/* Botones de acción alrededor del de atacar (abajo a la derecha) */
.t-acts .t-atk { right: calc(20px + env(safe-area-inset-right)); bottom: 24px; width: 80px; height: 80px; border-color: rgba(255,120,100,.55); background: rgba(90,20,14,.5); }
.t-acts .t-atk .ti { font-size: 32px; }
.t-acts .t-hvy { right: calc(112px + env(safe-area-inset-right)); bottom: 18px; }
.t-acts .t-par { right: calc(30px + env(safe-area-inset-right)); bottom: 116px; }
.t-acts .t-dge { right: calc(98px + env(safe-area-inset-right)); bottom: 88px; }
.t-acts .t-jmp { right: calc(180px + env(safe-area-inset-right)); bottom: 18px; }
.t-acts .t-dwn { right: calc(180px + env(safe-area-inset-right)); bottom: 82px; }
.t-acts .t-act { right: calc(34px + env(safe-area-inset-right)); bottom: 184px; width: 52px; height: 52px; }
.t-acts .t-lck { right: calc(104px + env(safe-area-inset-right)); bottom: 158px; width: 46px; height: 46px; }
.t-acts .t-tec { right: calc(166px + env(safe-area-inset-right)); bottom: 132px; width: 46px; height: 46px; }
.t-acts .t-ult { right: calc(230px + env(safe-area-inset-right)); bottom: 104px; width: 46px; height: 46px; }
.t-acts .t-dem { right: calc(92px + env(safe-area-inset-right)); bottom: 226px; width: 46px; height: 46px; }
.t-acts .t-lck .ti, .t-acts .t-tec .ti, .t-acts .t-ult .ti, .t-acts .t-dem .ti { font-size: 18px; }
/* Menú (arriba, a la izquierda del minimapa) */
.t-menu { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: calc(122px + env(safe-area-inset-right)); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; max-width: 170px; }
.t-menu .t-btn { position: static; width: 38px; height: 38px; border-radius: 11px; }
.t-menu .t-btn .ti { font-size: 17px; }
.t-menu .t-btn .tt { display: none; }
#tBack { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 70; width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); background: rgba(14,20,24,.85); color: #fff; font-size: 22px; font-weight: 800; }
#tBack.hidden { display: none; }
#tRotate { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; background: #0b1418; color: var(--text); text-align: center; font-size: 18px; font-weight: 800; padding: 24px; }
#tRotate b { display: block; font-size: 64px; margin-bottom: 12px; animation: tRot 1.6s ease-in-out infinite; }
@keyframes tRot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
#tRotate.hidden, #tUI.hidden, #tLook.hidden { display: none; }
/* HUD más compacto en la pantalla del móvil */
body.touch #keyhint, body.touch #clickToPlay, body.touch #styleHud { display: none !important; }
body.touch #stats { left: calc(8px + env(safe-area-inset-left)); top: 8px; bottom: auto; width: 150px; padding: 6px 9px; gap: 3px; border-radius: 10px; }
body.touch .stat { font-size: 11px; gap: 6px; }
body.touch .bar { height: 7px; }
body.touch #statusIcons { font-size: 10px; }
body.touch #objective { top: 118px; left: calc(8px + env(safe-area-inset-left)); max-width: 190px; font-size: 11px; padding: 6px 9px; }
body.touch #minimapWrap, body.touch #minimap { width: 108px; height: 108px; }
body.touch #minimapWrap { top: 8px; right: calc(8px + env(safe-area-inset-right)); }
body.touch #fps { display: none; }
body.touch #clock { transform: translateX(-50%) scale(.8); transform-origin: top center; }
body.touch #compass { top: 44px; transform: translateX(-50%) scale(.85); }
body.touch #hotbar { bottom: 6px; gap: 3px; padding: 4px; border-radius: 10px; pointer-events: auto; }
body.touch #hotbar .slot { width: 38px; height: 38px; font-size: 19px; border-radius: 8px; }
body.touch #hotbar .slot .num { display: none; }
body.touch #heldName { bottom: 56px; font-size: 12px; }
body.touch #messages { left: calc(8px + env(safe-area-inset-left)); bottom: auto; top: 196px; max-width: 40vw; }
body.touch #messages .msg:nth-last-child(n+4) { display: none; }
body.touch .msg { font-size: 11px; padding: 4px 8px; }
body.touch #banner { font-size: 30px; top: 18%; }
body.touch #banner small { font-size: 13px; }
body.touch #prompt { font-size: 12px; top: calc(50% + 18px); white-space: normal; max-width: 60vw; text-align: center; }
body.touch #bossBar { top: 70px; width: min(300px, 44vw); }
body.touch #bossName { font-size: 13px; }
body.touch #duelHud { top: 72px; transform: translateX(-50%) scale(.85); }
body.touch #dialog { bottom: 12px; }
body.touch #dialogOpts button { min-height: 40px; }
body.touch .screen, body.touch #inventory, body.touch #bigmap, body.touch #journal { overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* Pantallas bajas (móvil en horizontal): menús más compactos */
@media (max-height: 520px) {
  .menu-card { padding: 14px 20px; }
  .menu-card h1 { font-size: 32px; margin: 0 0 4px; }
  .menu-card .tagline { display: none; }
  .menu-buttons { gap: 6px; }
  .menu-buttons .btn.big, .btn.big { padding: 8px 16px !important; font-size: 15px !important; min-height: 0 !important; }
  .fac-box { padding: 12px; }
  .fac-box h2 { font-size: 20px; }
  .fac-card { padding: 10px; gap: 5px; }
  .fac-card ul { font-size: 12px; gap: 3px; }
  .fac-intro { font-size: 12px; }
  .fac-ic { font-size: 30px; }
}
