/* Theyblade Battler — control panel, deck and layout editor (provisional look). */
:root {
  --bg: #16161b;
  --panel: #212128;
  --panel-2: #2a2a33;
  --line: #3b3b47;
  --text: #f2f2f5;
  --muted: #a3a3ae;
  --a: #ff168f;
  --b: #12c8da;
  --win: #4fd068;
  --loss: #ff5a62;
  --warn: #f4b44a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ------------------------------------------------ top bar + tabs */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.brand { font-weight: 900; letter-spacing: 2px; font-size: 17px; }
.brand span { color: var(--a); }
.conn { margin-left: auto; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #4a2328; color: #ffb3b8; }
.conn.on { background: #1f3d27; color: #9df0ad; }

.tabs { display: flex; overflow-x: auto; padding: 0 8px; gap: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; padding: 9px 12px; color: var(--muted); font-weight: 800; letter-spacing: 1px; font-size: 13px; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--a); }

main { max-width: 980px; margin: 0 auto; padding: 14px 16px 40px; }
.tabpage { display: none; }
.tabpage.active { display: block; }

/* ------------------------------------------------ cards + forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card-title { font-weight: 900; letter-spacing: 1.5px; font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card-title .grow { flex: 1; }
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 640px) {
  .grid-2.stack { grid-template-columns: 1fr; }
}
label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.5px; }
input, select, textarea { width: 100%; margin-top: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--b); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-weight: 800; letter-spacing: 0.5px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--a); border-color: var(--a); color: #fff; }
.btn.danger { background: #3d1c21; border-color: #6b2b33; color: #ffb3b8; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.on { background: #1f3d27; border-color: var(--win); color: #9df0ad; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }

.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 8px; font-weight: 900; letter-spacing: 1px; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--a); color: #fff; }

/* ------------------------------------------------ live status */
.status { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; }
.st-side { min-width: 0; }
.st-side.b { text-align: right; }
.st-label { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }
.st-side.a .st-label { color: var(--a); }
.st-side.b .st-label { color: var(--b); }
.st-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-score { font-size: 36px; font-weight: 900; text-align: center; white-space: nowrap; }
.st-sub { grid-column: 1 / -1; text-align: center; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------ action pads */
.pads { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.pad { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; border-top: 4px solid var(--c, var(--line)); }
.pad.side-a { --c: var(--a); }
.pad.side-b { --c: var(--b); }
.pad.win { --c: var(--win); }
.pad.loss { --c: var(--loss); }
.pad-title { font-size: 12px; font-weight: 900; letter-spacing: 1px; color: var(--c); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad-btns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.fbtn { min-height: 64px; border-radius: 10px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel-2)); font-weight: 900; font-size: 15px; letter-spacing: 0.5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
.fbtn small { font-size: 11px; color: var(--muted); font-weight: 700; }
.fbtn:active { transform: scale(0.96); background: var(--c); }
.fbtn.xt { background: color-mix(in srgb, var(--c) 34%, var(--panel-2)); }
.misc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.misc .btn { min-height: 52px; }

/* ------------------------------------------------ lists */
.events { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow: auto; font-size: 14px; }
.ev { display: flex; gap: 10px; padding: 6px 8px; border-radius: 6px; background: var(--panel-2); }
.ev .n { color: var(--muted); width: 26px; text-align: right; }
.ev .t { flex: 1; }
.ev.win .t b { color: var(--win); }
.ev.loss .t b { color: var(--loss); }
.ev.ignored { opacity: 0.45; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 6px 4px 12px; font-size: 14px; }
.chip button { border: 0; background: #3a3a45; color: var(--muted); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }

.items { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.item { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .n { color: var(--muted); width: 22px; text-align: right; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; min-width: 32px; height: 32px; cursor: pointer; }

.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline > :first-child { flex: 1; }

details.hist { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
details.hist summary { cursor: pointer; font-weight: 700; }
details.hist textarea { margin-top: 8px; }

.links { display: flex; flex-direction: column; gap: 8px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row code { flex: 1; background: var(--panel-2); padding: 8px 10px; border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: fit-content; margin-top: 10px; }
.qr svg { display: block; width: 200px; height: 200px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.keys kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-family: inherit; font-weight: 800; }

/* ------------------------------------------------ toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: #333340; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; opacity: 0; pointer-events: none; transition: 0.25s; z-index: 100; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #6b2b33; }
.toast.ok { background: #1f5a30; }
