/* ============ PIXEL COLECCIÓN - estética retro pixelart ============ */
:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --panel: #0f3460;
  --ink: #e8e8e8;
  --dim: #9aa5c4;
  --red: #e94560;
  --yellow: #ffd93d;
  --green: #6bcb77;
  --blue: #4d96ff;
  --purple: #b983ff;
  --border: 3px;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.3;
  min-height: 100dvh;
  image-rendering: pixelated;
}

/* scanlines CRT */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0 1px, transparent 1px 3px);
  pointer-events: none; z-index: 9999;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

h1, h2, h3, .pixel { font-family: var(--font-pixel); line-height: 1.6; }
h1 { font-size: .95rem; } h2 { font-size: .8rem; } h3 { font-size: .7rem; }

a { color: var(--blue); text-decoration: none; }

/* ---------- boot screen ---------- */
.boot-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
.boot-logo {
  font-family: var(--font-pixel); font-size: 1.4rem; text-align: center; line-height: 2;
  color: var(--yellow); text-shadow: 4px 4px 0 var(--red);
  animation: blink-slow 1.2s steps(2) infinite;
}
.boot-text { font-family: var(--font-pixel); font-size: .6rem; color: var(--dim); }
@keyframes blink-slow { 50% { opacity: .6; } }

/* ---------- cajas pixel ---------- */
.box {
  background: var(--bg2);
  border: var(--border) solid var(--ink);
  box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  padding: 14px;
}

/* ---------- botones ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-pixel); font-size: .65rem;
  color: var(--bg); background: var(--yellow);
  border: var(--border) solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  padding: 12px 16px;
  cursor: pointer; text-align: center;
  text-transform: uppercase;
  user-select: none;
}
.btn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 rgba(0,0,0,.5); }
.btn-red { background: var(--red); color: #fff; }
.btn-green { background: var(--green); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--panel);
  border-bottom: var(--border) solid var(--ink);
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .title {
  font-family: var(--font-pixel); font-size: .75rem; color: var(--yellow);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .back { font-family: var(--font-pixel); font-size: .8rem; color: var(--ink); background: none; border: none; padding: 4px 8px 4px 0; cursor: pointer; }
.avatar-mini {
  width: 34px; height: 34px; border: 2px solid var(--ink); object-fit: cover;
  background: var(--bg2); font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
}

/* ---------- contenido ---------- */
.content { flex: 1; padding: 16px 12px calc(84px + env(safe-area-inset-bottom)); max-width: 680px; width: 100%; margin: 0 auto; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--panel);
  border-top: var(--border) solid var(--ink);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px 8px; color: var(--dim);
  font-family: var(--font-pixel); font-size: .42rem;
}
.bottomnav a.active { color: var(--yellow); }
.bottomnav svg { width: 26px; height: 26px; }
.bottomnav a.active svg rect { fill: var(--yellow); }
.bottomnav svg rect { fill: var(--dim); }

/* ---------- dashboard ---------- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.stat-card { text-align: center; padding: 18px 8px 14px; cursor: pointer; }
.stat-card .icon svg { width: 42px; height: 42px; }
.stat-card .num { font-family: var(--font-pixel); font-size: 1.5rem; margin: 8px 0 4px; }
.stat-card .label { font-family: var(--font-pixel); font-size: .5rem; color: var(--dim); }
.stat-card.c-games .num { color: var(--green); } .stat-card.c-games svg rect { fill: var(--green); }
.stat-card.c-consoles .num { color: var(--red); } .stat-card.c-consoles svg rect { fill: var(--red); }
.stat-card.c-accessories .num { color: var(--blue); } .stat-card.c-accessories svg rect { fill: var(--blue); }
.stat-card.c-collections .num { color: var(--purple); } .stat-card.c-collections svg rect { fill: var(--purple); }
.value-banner { margin-top: 14px; text-align: center; padding: 14px; }
.value-banner .v { font-family: var(--font-pixel); font-size: 1.1rem; color: var(--yellow); }
.value-banner .l { font-family: var(--font-pixel); font-size: .5rem; color: var(--dim); margin-top: 6px; }

/* ---------- listados ---------- */
.searchrow { display: flex; gap: 8px; margin-bottom: 14px; }
.searchrow input { flex: 1; }
.item-list { display: flex; flex-direction: column; gap: 12px; }
.item-card {
  display: flex; gap: 12px; align-items: center; cursor: pointer;
  background: var(--bg2); border: var(--border) solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,.45); padding: 10px;
}
.item-card:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 rgba(0,0,0,.45); }
.thumb {
  width: 64px; height: 64px; flex-shrink: 0;
  border: 2px solid var(--ink); object-fit: cover;
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  image-rendering: pixelated;
}
.thumb svg { width: 36px; height: 36px; } .thumb svg rect { fill: var(--dim); }
.item-card .info { flex: 1; min-width: 0; }
.item-card .name { font-family: var(--font-pixel); font-size: .6rem; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .sub { color: var(--dim); font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .val { color: var(--yellow); font-size: 1.05rem; }
.badge {
  font-family: var(--font-pixel); font-size: .42rem; padding: 4px 6px;
  border: 2px solid var(--ink);
}
.badge-sold { background: var(--red); color: #fff; }
.empty { text-align: center; padding: 40px 10px; color: var(--dim); }
.empty .pixel { font-size: .6rem; line-height: 2; }

/* fab añadir */
.fab {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 90;
  width: 56px; height: 56px;
  font-family: var(--font-pixel); font-size: 1.3rem;
  background: var(--green); color: var(--bg);
  border: var(--border) solid var(--ink); box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  cursor: pointer;
}
.fab:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 rgba(0,0,0,.5); }

/* ---------- formularios ---------- */
input, select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 1.25rem;
  color: var(--ink); background: var(--bg2);
  border: var(--border) solid var(--ink);
  padding: 10px 12px;
  border-radius: 0; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); outline-offset: -3px; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-family: var(--font-pixel); font-size: .5rem; color: var(--dim); margin: 14px 0 6px; text-transform: uppercase; }
.form-section {
  font-family: var(--font-pixel); font-size: .6rem; color: var(--yellow);
  margin: 24px 0 4px; padding-bottom: 6px; border-bottom: 2px dashed var(--dim);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-section svg { width: 16px; height: 16px; vertical-align: -2px; }
.form-section svg rect { fill: var(--yellow); }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.check-row input { width: 26px; height: 26px; accent-color: var(--red); }
.check-row span { font-family: var(--font-pixel); font-size: .55rem; }

/* fotos */
.photo-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.photo-slot {
  position: relative; aspect-ratio: 1; border: var(--border) dashed var(--dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 2rem; cursor: pointer; overflow: hidden;
  background: var(--bg2);
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .del {
  position: absolute; top: 2px; right: 2px;
  background: var(--red); color: #fff; border: 2px solid var(--ink);
  font-family: var(--font-pixel); font-size: .55rem; padding: 4px 6px; cursor: pointer;
}
.photo-slot.loading { animation: blink-slow .6s steps(2) infinite; }

/* ---------- ficha detalle ---------- */
.photo-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin-bottom: 14px; }
.photo-strip img {
  width: min(78vw, 420px); aspect-ratio: 1; object-fit: cover; scroll-snap-align: center;
  border: var(--border) solid var(--ink); flex-shrink: 0;
}
.detail-title { color: var(--yellow); margin-bottom: 4px; font-size: .85rem; }
.detail-sub { color: var(--dim); margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--dim); border: var(--border) solid var(--ink); }
.field { background: var(--bg2); padding: 8px 10px; }
.field.wide { grid-column: 1 / -1; }
.field .k { font-family: var(--font-pixel); font-size: .42rem; color: var(--dim); text-transform: uppercase; }
.field .v { font-size: 1.15rem; word-break: break-word; }
.detail-actions { display: flex; gap: 10px; margin-top: 18px; }
.detail-actions .btn { flex: 1; }

/* barra de progreso cromos */
.progress-wrap { margin: 14px 0; }
.progress-bar {
  height: 26px; border: var(--border) solid var(--ink); background: var(--bg2);
  position: relative; overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--green) 0 8px, #4da75f 8px 16px);
}
.progress-wrap .txt { font-family: var(--font-pixel); font-size: .5rem; margin-top: 6px; color: var(--dim); text-align: center; }

/* ---------- login ---------- */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px 14px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-logo {
  font-family: var(--font-pixel); font-size: 1.15rem; text-align: center; line-height: 1.9;
  color: var(--yellow); text-shadow: 3px 3px 0 var(--red); margin-bottom: 24px;
}
.auth-switch { text-align: center; margin-top: 16px; font-size: 1.15rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 999; max-width: 90vw;
  background: var(--ink); color: var(--bg);
  font-family: var(--font-pixel); font-size: .55rem; line-height: 1.6;
  border: var(--border) solid var(--bg); box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  padding: 12px 16px; text-align: center;
}
.toast.error { background: var(--red); color: #fff; }

/* ---------- perfil ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; }
.avatar-big {
  width: 96px; height: 96px; border: var(--border) solid var(--ink);
  object-fit: cover; background: var(--panel);
  display: flex; align-items: center; justify-content: center; font-size: 3rem;
}

/* búsqueda global */
.search-group-title { font-family: var(--font-pixel); font-size: .6rem; color: var(--yellow); margin: 20px 0 10px; }

@media (min-width: 700px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
