:root {
  --bg: #0b0b0c;
  --bg-2: #131315;
  --surface: #19191c;
  --surface-2: #222226;
  --line: #2e2e33;
  --line-2: #44444b;
  --text: #ededef;
  --muted: #9b9ba3;
  --accent: #c8202a;
  --accent-text: #f0504f;
  --accent-ink: #ffffff;
  --ok: #7fae6a;
  --danger: #ff6b5e;
  --radius: 10px;
  --font: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow-x: hidden;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(200, 32, 42, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
strong { color: var(--text); }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- arranque ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.boot-card { text-align: center; }
.boot-msg { color: var(--muted); max-width: 360px; margin: 0 auto; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { height: 54px; width: auto; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
.boot-logo { width: 190px; max-width: 60vw; height: auto; filter: drop-shadow(0 6px 18px rgba(200,32,42,.35)); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03) rotate(-1deg); } }
.boot-msg { margin-top: 18px !important; }
.brand-name { font-weight: 700; letter-spacing: .1em; font-size: 15px; text-transform: uppercase; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; min-height: 100%; max-width: 1280px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.top-right { display: flex; align-items: stretch; gap: 10px; }
.lbl { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.char-pick, .balance {
  display: flex; flex-direction: column; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 10px;
}
.char-pick select {
  background: transparent; border: 0; padding: 0; font-weight: 600; max-width: 160px;
  outline: none; cursor: pointer;
}
.char-pick select option { background: var(--surface); }
.balance { border-color: rgba(200,32,42,.45); background: rgba(200,32,42,.08); min-width: 96px; }
.balance .amount { font-family: var(--mono); font-weight: 700; font-size: 17px; color: var(--accent-text); }
.balance .amount.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
  background: none; border: 0; padding: 12px 12px 10px; cursor: pointer; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-text); }
.badge {
  outline: 1px solid rgba(255,255,255,.25);
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; font-size: 11px; letter-spacing: 0;
  display: inline-grid; place-items: center; background: var(--danger); color: #fff;
}
.badge.soft { background: var(--surface-2); color: var(--accent-text); }

.banner {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: var(--radius);
  background: rgba(208, 99, 75, .12); border: 1px solid rgba(208, 99, 75, .4);
}
.link { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; cursor: pointer; }

main { flex: 1; min-height: 0; }
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* ---------- tienda ---------- */
#tab-shop.active { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.sidebar, .catalog { min-width: 0; }
.sidebar { position: sticky; top: 12px; }
.search input, .field {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 12px; outline: none;
}
.search input:focus, .field:focus { border-color: var(--accent-text); }
.cat-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: left;
  color: var(--muted);
}
.cat-list button:hover { background: var(--surface); color: var(--text); }
.cat-list button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.cat-list .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.catalog-head { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 12px; }
.catalog-head h2 { margin: 0; font-size: 18px; letter-spacing: .08em; text-transform: uppercase; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb {
  aspect-ratio: 4 / 3; display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, #1c1c1f 0 10px, #18181a 10px 20px);
  border-bottom: 1px solid var(--line);
}
.thumb img { max-width: 70%; max-height: 70%; object-fit: contain; }
.thumb img.px { image-rendering: pixelated; width: 56px; height: 56px; }
.thumb .noimg { font-size: 11px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.card-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-weight: 600; line-height: 1.25; font-size: 14px; }
.card-price { margin-top: auto; font-family: var(--mono); color: var(--accent-text); font-weight: 700; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* ---------- detalle (sheet) ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.sheet-panel {
  position: relative; width: min(520px, 100%); max-height: calc(100% - 16px); overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.sheet-x { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 26px; color: var(--muted); cursor: pointer; }
.sheet-top { display: flex; gap: 16px; align-items: center; }
.sheet-img {
  width: 112px; height: 112px; flex: none; border-radius: var(--radius); display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, #1c1c1f 0 10px, #18181a 10px 20px); border: 1px solid var(--line);
}
.sheet-img img { max-width: 84%; max-height: 84%; }
.sheet-img img.px { image-rendering: pixelated; width: 80px; height: 80px; }
.tag { display: inline-block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sheet-top h3 { margin: 2px 0 4px; font-size: 20px; line-height: 1.2; padding-right: 20px; }
.sheet-price { font-family: var(--mono); color: var(--accent-text); font-size: 18px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin: 16px 0 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.stats dt { overflow-wrap: anywhere; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stats dd { margin: 1px 0 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.sheet-buy { display: flex; gap: 10px; margin-top: 18px; }
.qty { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.qty button { width: 36px; background: none; border: 0; cursor: pointer; font-size: 18px; color: var(--muted); }
.qty button:hover { color: var(--text); background: var(--surface-2); }
.qty input { width: 44px; text-align: center; background: none; border: 0; outline: none; font-family: var(--mono); -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#sheet-note { margin: 10px 0 0; }

/* ---------- botones ---------- */
.btn {
  border: 1px solid var(--line-2); background: var(--surface-2); border-radius: var(--radius);
  padding: 9px 16px; cursor: pointer; font-weight: 600; letter-spacing: .03em;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent-text); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #121a08; }
.btn.danger { background: transparent; border-color: rgba(208,99,75,.6); color: var(--danger); }
.btn.wide { flex: 1; }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--accent-ink); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- servicios ---------- */
.services { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.service { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.service h3 { margin: 4px 0 0; font-size: 16px; letter-spacing: .04em; }
.service p { margin: 0; font-size: 14px; }
.svc-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { font-family: var(--mono); color: var(--accent-text); font-weight: 700; font-size: 17px; }
.svc-icon { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); position: relative; background: var(--surface-2); }
.svc-icon.heal::before, .svc-icon.heal::after { content: ""; position: absolute; background: var(--danger); inset: 9px 15px; border-radius: 2px; }
.svc-icon.heal::after { inset: 15px 9px; }
.svc-icon.home::before { content: ""; position: absolute; left: 9px; right: 9px; bottom: 8px; height: 11px; background: var(--ok); border-radius: 1px; }
.svc-icon.home::after { content: ""; position: absolute; left: 7px; top: 7px; border: 10px solid transparent; border-bottom: 9px solid var(--ok); border-top: 0; }
.svc-icon.tp::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; border: 2px dashed var(--accent); }
.svc-icon.tp::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--accent); }
.tp-out { font-size: 13px; }
.tp-incoming { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.tp-req {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border: 1px solid rgba(200,32,42,.5); background: rgba(200,32,42,.08); border-radius: 12px; padding: 12px 14px;
}
.tp-req .actions { display: flex; gap: 8px; }

/* ---------- eventos ---------- */
.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.event { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.event h3 { margin: 0; font-size: 16px; }
.event .pts { font-family: var(--mono); color: var(--accent-text); font-weight: 700; font-size: 20px; }
.event .items { display: flex; flex-wrap: wrap; gap: 4px; }
.event .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 6px; }
.claimed { color: var(--ok); font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- personajes ---------- */
.chars-wrap { max-width: 560px; }
.char-form label { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; }
.char-form p { margin: 4px 0 10px; }
.row { display: flex; gap: 8px; }
.char-list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.char-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.char-list .name { font-weight: 600; }
.char-list .home { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---------- avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast {
  background: var(--surface-2); border: 1px solid var(--line-2); border-left: 4px solid var(--ok);
  border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: rise .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }

/* ---------- móvil ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .brand-sub { display: none; }
  .brand-logo { height: 42px; }
  .brand-name { font-size: 14px; }
  .top-right { width: 100%; }
  .char-pick { flex: 1; }
  .char-pick select { max-width: none; width: 100%; }
  #tab-shop.active { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sidebar { position: static; }
  .cat-list { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 6px; padding-bottom: 2px; }
  .cat-list button { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
  .cat-list button.active { box-shadow: none; border-color: var(--accent-text); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .sheet { align-items: end; padding: 0; }
  .sheet-panel { width: 100%; border-radius: 16px 16px 0 0; max-height: 88%; }
}
