:root {
  --primary: #22d3ee;
  --accent: #ffb300;
  --bg: #0b1020;
  --text: #f2f6ff;
  --rarity: #9aa5b1;
  --glass: color-mix(in srgb, var(--bg) 78%, transparent);
  --line: color-mix(in srgb, var(--text) 16%, transparent);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; touch-action: manipulation; }
body { position: fixed; inset: 0; }

#ar { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); }

.screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; text-align: center;
  padding: calc(24px + var(--sat)) calc(24px + var(--sar)) calc(24px + var(--sab)) calc(24px + var(--sal));
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--primary) 22%, var(--bg)) 0%, var(--bg) 70%); }
.splash-inner { max-width: 420px; width: 100%; display: grid; gap: 14px; justify-items: center; }
.logo { max-width: 160px; max-height: 90px; object-fit: contain; }
h1 { margin: 0; font-size: clamp(2rem, 9vw, 3rem); line-height: 1.05; letter-spacing: .02em;
  background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0; }
.tagline { margin: 0 0 14px; font-size: 1.1rem; opacity: .85; }
.hint { margin: 4px 0 0; font-size: .85rem; opacity: .6; }
#error-text { margin: 0; opacity: .85; line-height: 1.45; }

.btn-primary { appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 1.1rem; color: var(--bg);
  padding: 16px 32px; min-height: 52px; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 8px 28px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; }

.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: min(260px, 70vw); height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s; }
#loading-text { margin: 0; }

/* Escaneo */
.scan-hint { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: grid; place-items: center; }
.scan-hint p { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(40px + var(--sab)); margin: 0; padding: 10px 20px;
  border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line);
  font-weight: 600; animation: pulse 1.8s ease-in-out infinite; }
.reticle { position: relative; width: min(62vw, 300px); aspect-ratio: 63 / 88; animation: pulse 1.8s ease-in-out infinite; }
.reticle i { position: absolute; width: 28px; height: 28px; border: 4px solid var(--primary); }
.reticle i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.reticle i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.reticle i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.reticle i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }
@keyframes pulse { 50% { opacity: .55; } }

/* Panel */
.panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-height: 36vh; overflow: hidden;
  padding: 12px calc(16px + var(--sar)) calc(12px + var(--sab)) calc(16px + var(--sal));
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 2px solid var(--rarity); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.35);
  animation: slideUp .35s ease-out; }
@keyframes slideUp { from { transform: translateY(30%); opacity: 0; } }
@media (min-width: 700px) { .panel { left: 50%; right: auto; width: 560px; transform: translateX(-50%); animation-name: fadeIn; } @keyframes fadeIn { from { opacity: 0; } } }
.panel header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.title { min-width: 0; }
.panel h2 { font-size: 1.35rem; line-height: 1.1; }
.panel p { margin: 3px 0 0; font-size: .8rem; opacity: .75; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #0b1020; background: var(--rarity); box-shadow: 0 0 14px color-mix(in srgb, var(--rarity) 60%, transparent); }
.level { font-size: .8rem; font-weight: 700; color: var(--accent); }

.stats { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.stats li { display: grid; gap: 3px; font-size: .72rem; }
.stats .row { display: flex; justify-content: space-between; opacity: .9; }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .9s cubic-bezier(.2,.8,.2,1); }

.actions { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.actions::-webkit-scrollbar { display: none; }
.actions button { flex: 1 0 auto; appearance: none; cursor: pointer; font: inherit; font-weight: 700; font-size: .9rem; color: var(--text);
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: color-mix(in srgb, var(--text) 8%, transparent); }
.actions button:active, .actions button.on { background: var(--primary); color: var(--bg); border-color: var(--primary); }

@media (max-height: 560px) { .stats { display: none; } .panel p { display: none; } }
