/* Arcanium Live — the layer on the Arena: status pill, room panel, leaderboard,
 * toast. Sits on the site's tokens (styles.css :root). Host's screen only. */

/* ---------- topbar pill: the live status line ---------- */
.live-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #334155;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.live-trigger:hover { background: #fff; border-color: rgba(10, 132, 255, 0.35); }
.live-trigger:focus-visible { outline: 2px solid var(--accent, #0a84ff); outline-offset: 2px; }
.live-trigger-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: 0 0 auto; }
.live-trigger.is-live {
    border-color: rgba(52, 199, 89, 0.5);
    color: #166534;
    background: linear-gradient(180deg, rgba(52, 199, 89, 0.14), rgba(52, 199, 89, 0.08));
    box-shadow: 0 6px 18px rgba(52, 199, 89, 0.14);
}
.live-trigger.is-live .live-trigger-dot,
.live-panel .live-trigger-dot { background: #34c759; }
.live-trigger-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .14em; }
.live-trigger-sep { color: rgba(22, 101, 52, 0.5); }
.live-trigger-count { font-weight: 600; }
.live-trigger-timer {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.85); color: #0f172a;
}
.live-trigger-timer.is-urgent { background: var(--danger, #ff453a); color: #fff; }
@media (prefers-reduced-motion: no-preference) {
    .live-trigger.is-live .live-trigger-dot { animation: live-pulse 2s ease-in-out infinite; }
    .live-trigger-timer.is-urgent { animation: live-blink 1s steps(2) infinite; }
    @keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.45); } 50% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); } }
    @keyframes live-blink { 50% { opacity: .55; } }
}

/* ---------- shared pieces ---------- */
.live-btn {
    font: inherit; font-size: 13px; font-weight: 700;
    padding: 11px 16px; border-radius: 999px; cursor: pointer;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.10);
    color: var(--text, #111318);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.live-btn:hover:not(:disabled) { border-color: rgba(10, 132, 255, 0.4); box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08); }
.live-btn:active:not(:disabled) { transform: scale(.98); }
.live-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.live-btn--primary {
    background: linear-gradient(180deg, #2b95ff, var(--accent, #0a84ff));
    border-color: transparent; color: #fff; width: 100%; padding: 13px 16px;
    box-shadow: 0 10px 24px rgba(10, 132, 255, 0.28);
}
.live-btn--primary:hover:not(:disabled) { background: linear-gradient(180deg, #1f8dff, var(--accent-strong, #0066cc)); border-color: transparent; }
.live-btn--danger { color: var(--danger, #ff453a); border-color: rgba(255, 69, 58, 0.3); background: rgba(255, 69, 58, 0.06); box-shadow: none; }

/* ---------- room panel ---------- */
.live-panel {
    position: fixed;
    right: 24px;
    top: 96px;
    width: 300px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    z-index: 1302;
    background: var(--surface-strong, rgba(255, 255, 255, 0.96));
    border: 1px solid var(--line, rgba(15, 23, 42, 0.08));
    border-radius: var(--radius-lg, 24px);
    box-shadow: var(--shadow-lg, 0 30px 80px rgba(15, 23, 42, 0.12));
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text, #111318);
    font-size: 14px;
}
/* The panel sets display:flex, which would otherwise beat the browser's [hidden]. */
.live-panel[hidden], .live-board[hidden] { display: none !important; }
.live-panel-head { display: flex; justify-content: space-between; align-items: center; }
.live-panel-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.live-panel-x { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted, #667085); padding: 0 4px; border-radius: 8px; }
.live-panel-x:hover { color: var(--text, #111318); }
.live-panel-copy { margin: 0; color: var(--muted-strong, #475467); line-height: 1.5; }
.live-panel-err { margin: 0; min-height: 1.2em; color: var(--danger, #ff453a); font-size: 13px; }

.live-join-card {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 14px 12px 12px;
    border-radius: var(--radius-md, 18px);
    background: linear-gradient(180deg, rgba(10, 132, 255, 0.06), rgba(10, 132, 255, 0.02));
    border: 1px solid rgba(10, 132, 255, 0.14);
}
.live-code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-weight: 700; font-size: 44px; letter-spacing: .28em; line-height: 1;
    padding-left: .28em;   /* balances the trailing letter-spacing */
    color: var(--text, #111318);
}
.live-qr { display: block; width: 168px; height: 168px; padding: 6px; border-radius: 12px; background: #fff; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); }
.live-qr svg, .live-qr canvas, .live-qr img { width: 156px; height: 156px; }

/* On the Arena builder page (no overlay) the pill sits with the start buttons. */
.arena-builder-actions .live-trigger { align-self: center; }
.live-join { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--muted, #667085); word-break: break-all; text-align: center; }

.live-players { display: grid; gap: 2px; max-height: 190px; overflow-y: auto; }
.live-player { display: flex; justify-content: space-between; align-items: center; padding: 7px 2px; border-bottom: 1px solid var(--line, rgba(15, 23, 42, 0.08)); }
.live-player small { color: var(--muted, #667085); font-weight: 600; margin-left: 6px; }
.live-player.is-left { color: var(--muted, #667085); text-decoration: line-through; }
.live-player.is-empty { color: var(--muted, #667085); justify-content: center; border-bottom: 0; }
.live-player-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.live-mark { display: inline-block; width: 16px; color: #cbd5e1; font-size: 12px; }
.live-mark.is-in { color: #34c759; }

.live-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.live-controls .live-btn { width: 100%; padding: 11px 8px; white-space: nowrap; }

.live-settings { display: flex; gap: 14px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted-strong, #475467); }
.live-settings label { display: inline-flex; align-items: center; gap: 8px; }
.live-settings select {
    font: inherit; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12); background: #fff; color: var(--text, #111318);
}
.live-switch input { width: 16px; height: 16px; accent-color: var(--accent, #0a84ff); }

/* ---------- the board: slides in on reveal, out on next ---------- */
.live-board {
    position: fixed;
    left: 24px;        /* bottom-left: the feedback widget owns the bottom-right */
    bottom: 24px;
    width: 300px;
    z-index: 1301;
    background: var(--surface-strong, rgba(255, 255, 255, 0.96));
    border: 1px solid var(--line, rgba(15, 23, 42, 0.08));
    border-radius: var(--radius-lg, 24px);
    box-shadow: var(--shadow-lg, 0 30px 80px rgba(15, 23, 42, 0.14));
    padding: 14px 16px 12px;
    color: var(--text, #111318);
    font-size: 14px;
    opacity: 0;
    transform: translateY(16px) scale(.98);
    transition: opacity .24s ease, transform .24s cubic-bezier(.2, .8, .2, 1);
    pointer-events: none;
}
.live-board.is-on { opacity: 1; transform: none; pointer-events: auto; }
.live-board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 700; cursor: grab; user-select: none; touch-action: none; }
.live-panel-head { cursor: grab; user-select: none; touch-action: none; }
.live-board.is-dragging, .live-panel.is-dragging { cursor: grabbing; transition: none; box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22); }
.live-board.is-dragging .live-board-head, .live-panel.is-dragging .live-panel-head { cursor: grabbing; }
.live-board-sub { font-size: 12px; font-weight: 600; color: var(--muted, #667085); letter-spacing: .04em; text-transform: uppercase; }
.live-board-row {
    display: grid; grid-template-columns: 28px minmax(0, 1fr) 22px 34px; align-items: center; gap: 8px;
    padding: 7px 0; border-top: 1px solid var(--line, rgba(15, 23, 42, 0.08));
}
.live-board-row:first-of-type { border-top: 0; }
.live-board-row.is-left { color: var(--muted, #667085); }
.live-board-row.is-empty { grid-template-columns: 1fr; color: var(--muted, #667085); text-align: center; }
.live-board-rank { font-size: 15px; text-align: center; color: var(--muted-strong, #475467); font-weight: 700; }
.live-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.live-board-streak { margin-left: 6px; font-size: 12px; color: #b45309; font-weight: 700; }
.live-board-last { text-align: center; font-weight: 800; }
.live-board-last.is-right { color: #16a34a; }
.live-board-last.is-wrong { color: var(--danger, #ff453a); }
.live-board-last.is-none { color: #cbd5e1; }
.live-board-score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; }
.live-board-foot { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line, rgba(15, 23, 42, 0.08)); }
.live-board-count { font-size: 12.5px; font-weight: 600; color: var(--muted-strong, #475467); }
.live-board-foot .live-btn { padding: 9px 12px; font-size: 12.5px; }
.live-board-foot .live-btn--primary { width: auto; }

/* Final standings: a bigger card, rows arriving one after another. */
.live-board.is-final { width: 340px; padding: 18px 20px 16px; border-color: rgba(10, 132, 255, 0.25); box-shadow: 0 30px 80px rgba(10, 132, 255, 0.18); }
.live-board.is-final .live-board-head { font-size: 18px; margin-bottom: 10px; }
.live-board.is-final .live-board-row { padding: 9px 0; font-size: 15px; }
.live-board.is-final .live-board-row:first-of-type .live-board-name { font-weight: 800; font-size: 17px; }
.live-board.is-final .live-board-row:first-of-type .live-board-score { font-size: 19px; color: var(--accent-strong, #0066cc); }
@media (prefers-reduced-motion: no-preference) {
    .live-board.is-final.is-on .live-board-row { animation: live-row-in .45s cubic-bezier(.2, .8, .2, 1) both; }
    .live-board.is-final.is-on .live-board-row:nth-child(2) { animation-delay: .08s; }
    .live-board.is-final.is-on .live-board-row:nth-child(3) { animation-delay: .16s; }
    .live-board.is-final.is-on .live-board-row:nth-child(4) { animation-delay: .24s; }
    .live-board.is-final.is-on .live-board-row:nth-child(5) { animation-delay: .32s; }
    .live-board.is-final.is-on .live-board-row:nth-child(n+6) { animation-delay: .4s; }
    @keyframes live-row-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) { .live-board { transition: none; } }

/* ---------- toast ---------- */
.live-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
    z-index: 1303; opacity: 0; pointer-events: none;
    background: #111318; color: #fff; padding: 12px 16px; border-radius: 14px;
    font-size: 14px; max-width: min(90vw, 520px); box-shadow: var(--shadow-md, 0 18px 40px rgba(15, 23, 42, 0.18));
    transition: opacity .2s ease, transform .2s ease;
}
.live-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
    .live-panel { right: 12px; left: 12px; width: auto; top: auto; bottom: 12px; max-height: 70vh; }
    .live-board { left: 12px; right: 12px; width: auto; bottom: 12px; }
}

/* ---------- Phase 4: away, remove, room picks ---------- */
.live-player.is-away { color: var(--muted, #667085); }
.live-player.is-away small { color: #b45309; }
.live-player-right { display: inline-flex; align-items: center; gap: 8px; }
.live-player-x {
    border: 0; background: transparent; color: #cbd5e1; font-size: 16px; line-height: 1;
    cursor: pointer; padding: 2px 4px; border-radius: 6px;
}
.live-player:hover .live-player-x { color: var(--muted, #667085); }
.live-player-x:hover { color: var(--danger, #ff453a); background: rgba(255, 69, 58, 0.08); }
.live-board-away { margin-left: 6px; font-size: 11px; font-weight: 700; color: #b45309; text-transform: uppercase; letter-spacing: .04em; }
.hoad-choice-pct--live { background: rgba(10, 132, 255, 0.10); color: var(--accent-strong, #0066cc); }

/* ---------- Phase 5: history shelf (Arena page) ---------- */
.arena-live-history-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 4px; border-bottom: 1px solid rgba(15, 23, 42, 0.06); font-size: 13.5px; }
.arena-live-history-item:last-child { border-bottom: 0; }
.arena-live-history-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arena-live-history-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .14em; color: var(--text, #111318); }
.arena-live-history-sets { color: var(--muted-strong, #475467); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arena-live-history-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: rgba(52, 199, 89, 0.12); color: #166534; }
.arena-live-history-meta { display: flex; gap: 12px; flex: 0 0 auto; font-size: 12.5px; color: var(--muted, #667085); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    .arena-live-history-item { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ---------- Phase 5: admin section ---------- */
.live-admin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.live-admin-head h3 { margin: 0 0 4px; font-size: 20px; }
.live-admin-head p { margin: 0; color: var(--muted-strong, #475467); font-size: 14px; }
.live-admin-head select { font: inherit; font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(15, 23, 42, 0.12); background: #fff; }
.live-admin-now { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; background: rgba(248, 250, 252, 0.96); border: 1px solid rgba(15, 23, 42, 0.08); color: #475467; }
.live-admin-now .live-trigger-dot { background: #94a3b8; }
.live-admin-now.is-live { color: #166534; border-color: rgba(52, 199, 89, 0.5); background: rgba(52, 199, 89, 0.10); }
.live-admin-now.is-live .live-trigger-dot { background: #34c759; }
.live-admin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.live-admin-tile { background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(15, 23, 42, 0.08); border-radius: 18px; padding: 14px 16px; display: grid; gap: 2px; }
.live-admin-tile strong { font-size: 26px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.live-admin-tile span { font-size: 12.5px; font-weight: 600; color: var(--muted-strong, #475467); text-transform: uppercase; letter-spacing: .05em; }
.live-admin-tile small { font-size: 12px; color: var(--muted, #667085); }
.live-admin-sub { margin: 18px 0 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-strong, #475467); }
.live-admin-table { overflow-x: auto; border: 1px solid rgba(15, 23, 42, 0.08); border-radius: 14px; background: rgba(255, 255, 255, 0.92); }
.live-admin-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.live-admin-table th, .live-admin-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid rgba(15, 23, 42, 0.06); white-space: nowrap; }
.live-admin-table th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted, #667085); background: rgba(248, 250, 252, 0.9); }
.live-admin-table tr:last-child td { border-bottom: 0; }
.live-admin-table .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .1em; }
.live-admin-state { padding: 18px; color: var(--muted, #667085); font-size: 14px; }
.live-admin-state--error { color: var(--danger, #ff453a); }

/* ---------- Phase 6: characters ---------- */
.live-av { display: inline-block; margin-right: 6px; font-size: 16px; vertical-align: -1px; }
.live-board.is-final .live-board-row:first-of-type .live-av { font-size: 22px; }

/* ---------- Phase 7: illustrated avatars ---------- */
.live-av--img { border-radius: 50%; vertical-align: -5px; object-fit: cover; background: #eef2f7; }
.live-board.is-final .live-board-row:first-of-type .live-av--img { width: 28px; height: 28px; vertical-align: -8px; }
