body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .back { text-decoration: none; color: var(--muted); font-size: 1.8rem; line-height: 1; padding: 0 4px; }
.lights { display: inline-flex; gap: 4px; }
.lights i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.lights i:nth-child(1) { background: var(--verde); } .lights i:nth-child(2) { background: var(--amarillo); } .lights i:nth-child(3) { background: var(--rojo); }

.tab { display: none; }
.tab.active { display: block; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; border: 0; background: none; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
.tabbar button span { font-size: .72rem; font-weight: 700; }
.tabbar button.on { color: var(--text); }
.tabbar button.on span { color: var(--accent); }

h3 { margin: 22px 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; text-align: center; margin: 8px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Juego ---------- */
.onscreen { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.onscreen.live { border-color: var(--accent); color: var(--text); }
.onscreen.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); flex: none; }
.onscreen span { flex: 1; }

.strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.pchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px 7px 10px; cursor: pointer; font-weight: 600; font-size: .92rem; }
.pchip.done { opacity: .45; }
.pchip.sel { border-color: var(--lv); background: color-mix(in srgb, var(--lv) 18%, var(--surface)); opacity: 1; }
.pchip small { font-size: .8rem; }

.btn.spin { background: linear-gradient(90deg, var(--verde), var(--amarillo), var(--rojo)); color: #120a00; border: 0; text-shadow: 0 1px 0 #fff6; }

.draft { margin-top: 16px; background: var(--surface); border: 2px solid var(--lv); border-radius: 20px; padding: 16px; box-shadow: 0 0 40px color-mix(in srgb, var(--lv) 18%, transparent); }
.draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.draft .who { font-size: 1.7rem; font-weight: 900; line-height: 1.05; }
.badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.badge { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--surface2); }
.badge.lv { background: var(--lv); color: #000; }
.btn.up { border-color: var(--lv); white-space: nowrap; }
.preview { margin: 14px 0 10px; font-size: 1.2rem; font-weight: 700; line-height: 1.35; min-height: 3em; padding: 14px; border-radius: 14px; background: var(--bg); border: 1px dashed var(--line); }
.preview .kind { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; font-weight: 800; }
.parts { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.parts b { color: var(--text); }
.tagline { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tag { font-size: .7rem; padding: 2px 7px; border-radius: 6px; background: var(--surface2); color: var(--muted); }
.tools-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; padding: 10px; border-radius: 14px; background: var(--bg); }
.btn.show { margin-top: 12px; background: var(--text); color: var(--bg); border: 0; }
.btn.show.again { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.after { margin-top: 10px; }
.after .btn { padding: 14px; font-size: 1.05rem; }

/* ---------- Listas ---------- */
.item { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.item:active { background: var(--surface2); }
.item .t { font-weight: 600; }
.item .m { font-size: .8rem; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item.off { opacity: .45; }
.item.warnc { border-color: color-mix(in srgb, var(--amarillo) 40%, var(--line)); }
.slots { display: inline-flex; gap: 2px; }
.slots i { width: 12px; height: 8px; border-radius: 2px; background: var(--surface2); display: block; }
.slots i.on.lv-verde { background: var(--verde); } .slots i.on.lv-amarillo { background: var(--amarillo); } .slots i.on.lv-rojo { background: var(--rojo); }
.slots i.exp { border-radius: 2px 2px 2px 6px; }
.player-row { display: flex; align-items: center; gap: 10px; }
.player-row .name { font-weight: 800; font-size: 1.05rem; flex: 1; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.count { font-size: .8rem; color: var(--muted); margin: 8px 2px; }
.quickadd { display: flex; gap: 8px; margin-bottom: 14px; }
.quickadd input { flex: 1; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: #000a; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.sheet .footer { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--surface); padding: 14px 0 4px; margin-top: 16px; display: flex; gap: 8px; }
.sheet .footer .btn { flex: 1; padding: 14px; }
.help { font-size: .82rem; color: var(--muted); margin: 6px 0; }
.ph { display: flex; gap: 6px; margin-top: 6px; }

.grid-slots { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; align-items: center; }
.grid-slots .lvname { font-weight: 800; display: flex; align-items: center; gap: 8px; padding-right: 6px; }
.grid-slots button { padding: 12px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); cursor: pointer; font-weight: 600; font-size: .9rem; }
.grid-slots button.on { background: var(--lv); color: #000; border-color: transparent; }
.grid-slots .hd { font-size: .75rem; color: var(--muted); text-align: center; font-weight: 700; }

.slot-select { display: grid; gap: 8px; }
.slot-select label { display: flex; align-items: center; gap: 10px; }
.slot-select label span { width: 24px; font-weight: 800; color: var(--muted); }
.slot-select select { flex: 1; }
.urlbox { background: var(--surface2); border-radius: 12px; padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; word-break: break-all; margin-bottom: 8px; }
.urlbox small { display: block; font-family: system-ui, sans-serif; color: var(--muted); margin-bottom: 4px; }

/* ---------- iPhone / barra de acción ---------- */
html { -webkit-text-size-adjust: 100%; }
button, .btn, a.btn { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
.tabbar { height: calc(64px + env(safe-area-inset-bottom)); }
.tabbar button { padding: 9px 0 10px; }
.modal .sheet { max-height: calc(100dvh - env(safe-area-inset-top) - 12px); }

.actionbar { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 19; display: none; gap: 8px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
body.has-bar[data-tab="juego"] .actionbar { display: flex; }
body.has-bar[data-tab="juego"] { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.actionbar .btn { flex: 1; padding: 16px 10px; font-size: 1.08rem; font-weight: 800; border-radius: 14px; min-height: 56px; }
.actionbar .btn.show { background: var(--text); color: var(--bg); border: 0; }
.actionbar .btn.show.bad { background: var(--bad); color: #fff; }

.draft.cand { text-align: center; padding: 22px 16px; }
.draft.cand .who { font-size: 2.6rem; margin: 6px 0 10px; color: var(--lv); }
.cand-label { color: var(--muted); font-weight: 700; font-size: .9rem; animation: breathe 1.6s infinite; }
@keyframes breathe { 50% { opacity: .4; } }
.preview.castigo { border-color: var(--bad); }
.hiddenmark { color: var(--amarillo); }
.livemark { color: var(--ok); }
.seg button { min-height: 44px; }
.pchip { min-height: 40px; }
.ctitle { display: block; font-weight: 900; margin-bottom: 2px; }
.preview .ctitle { font-size: 1.05rem; color: var(--lv); margin-bottom: 4px; }
.onscreen.paused { border-color: var(--amarillo); color: var(--text); }
.onscreen .btn.sm { white-space: nowrap; }
