:root {
    --bg: #0b0d12;
    --panel: #121720;
    --panel-soft: #171d28;
    --border: #252d3b;
    --text: #f3f5f8;
    --muted: #97a3b6;
    --primary: #6ea8fe;
    --success: #5acb8a;
    --radius: 16px;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Inter, Segoe UI, Roboto, system-ui, sans-serif;
}

body {
    background: radial-gradient(circle at 20% 0%, #131824 0%, #0b0d12 45%, #090b0f 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.blitz-header,
.panel,
.type-card,
.round-box,
.match-card,
.table-wrap {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.quick-nav {
    position: sticky;
    top: 10px;
    z-index: 120;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.86), rgba(18, 23, 32, 0.68));
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    margin-bottom: 18px;
}

.quick-nav-account {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.quick-nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s ease;
}

.quick-nav-btn:hover {
    border-color: #3a4b67;
    color: var(--text);
    background: rgba(110, 168, 254, 0.08);
}

.blitz-header {
    padding: 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo span {
    display: inline-flex;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.subtitle {
    display: inline-flex;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.user-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.global-handle-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

html:not([data-auth-chip-ready="1"]) .global-handle-chip[data-global-handle-chip] {
    visibility: hidden;
}

.global-handle-chip.not-verified {
    display: inline-block;
    background: linear-gradient(180deg,#60a5fa,#3b82f6);
    color: #071325;
    border-color: rgba(59,130,246,0.28);
    font-weight: 700;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13.3333px;
    line-height: normal;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.global-handle-chip.not-verified:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(59,130,246,0.12); }

.global-handle-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.nav-btn,
.primary-btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 12px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s ease;
    cursor: pointer;
}

.nav-btn {
    background: #1b2232;
    color: var(--text);
    border-color: var(--border);
}

.primary-btn {
    margin-top: 12px;
    background: linear-gradient(180deg, #67d69a, #4dbd82);
    color: #06120b;
    border-color: #5acb8a;
}

.nav-btn:hover,
.primary-btn:hover {
    transform: translateY(-1px);
    border-color: #3b4660;
}

/* Center the Generate Bracket button inside the panel */
.config-group > #generateBracketBtn {
    display: block;
    margin: 12px auto 0;
}

.panel {
    padding: 18px;
    margin-bottom: 14px;
}

.panel h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

/* Highlight winner player chip inside match cards */
.player-chip.player-winner {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(90, 203, 138, 0.06); /* soft green */
    box-shadow: 0 0 0 3px rgba(90, 203, 138, 0.08);
}

.match-card .player-chip.player-winner::after {
    content: "🏆";
    margin-left: 8px;
    font-size: 14px;
    opacity: 0.95;
}

/* When the cup is moved into the points text, hide the pseudo-element */
.match-card .player-chip.no-winner-after::after {
    display: none;
}

.winner {
    font-weight: 700;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.winner-subtext {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

/* Remove underline for links inside winner labels/subtext */
.winner a,
.winner-subtext a {
    text-decoration: none;
    color: inherit;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.type-card {
    padding: 12px;
    cursor: pointer;
    transition: 0.2s ease;
}

.type-card input {
    display: none;
}

.type-card h3 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.type-card p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.type-card.selected {
    border-color: #5b7cb3;
    background: rgba(110, 168, 254, 0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.create-options {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
}

.config-group {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: var(--panel);
}

.problems-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.problems-list-head {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    padding: 6px 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    align-items: center;
    margin-bottom: 8px;
}

/* Dim and visually indicate disabled create problems area */
.problems-list.create-disabled {
    opacity: 0.6;
}

/* Make bracket problems list show a visible, themed scrollbar (match index) */
#bracketProblemsList,
.problems-list.bracket-specific {
    scrollbar-width: thin;
    scrollbar-color: rgba(110,168,254,0.72) transparent;
}

#bracketProblemsList::-webkit-scrollbar,
.problems-list.bracket-specific::-webkit-scrollbar {
    width: 10px;
}

#bracketProblemsList::-webkit-scrollbar-track,
.problems-list.bracket-specific::-webkit-scrollbar-track {
    background: transparent;
}

#bracketProblemsList::-webkit-scrollbar-thumb,
.problems-list.bracket-specific::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0.08);
}

/* Apply the same themed native scrollbar across other scrollable areas on bracket page */
body.bracket-page,
body.bracket-page textarea,
body.bracket-page .saved-list,
body.bracket-page .bracket-tree,
body.bracket-page .problems-list,
body.bracket-page .panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(110,168,254,0.72) transparent;
}


/* Banner for admin-disabled features (centered, reddish warning) */
.public-announcement.feature-disabled-banner {
    /* keep floating default but support push mode via .push */
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 40px));
    z-index: 9999;
    border-radius: 8px;
    text-align: center;
    padding: 12px 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.public-announcement.feature-disabled-banner.is-danger {
    background: linear-gradient(135deg, #831313, #b22222);
    border-color: rgba(120,16,16,0.45);
    color: #fff;
    font-weight: 700;
}

@media (max-width: 520px) {
    .public-announcement.feature-disabled-banner {
        top: 8px;
        padding: 10px 12px;
        width: calc(100% - 24px);
        border-radius: 6px;
        font-size: 0.95rem;
    }
}

/* Push layout variant for bracket page */
.public-announcement.feature-disabled-banner.push {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 12px;
    border-radius: 8px;
    box-shadow: none;
}
.public-announcement.feature-disabled-banner.push .banner-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border:0; background:transparent; color:#fff; cursor:pointer; padding:6px 8px; }
.feature-disabled-banner.slide-up { transition: max-height 260ms ease, padding 200ms ease, margin 200ms ease, opacity 200ms ease; overflow: hidden; }
body.bracket-page::-webkit-scrollbar,
body.bracket-page textarea::-webkit-scrollbar,
body.bracket-page .saved-list::-webkit-scrollbar,
body.bracket-page .bracket-tree::-webkit-scrollbar,
body.bracket-page .problems-list::-webkit-scrollbar,
body.bracket-page .panel::-webkit-scrollbar {
    width: 10px;
}

body.bracket-page::-webkit-scrollbar-track,
body.bracket-page textarea::-webkit-scrollbar-track,
body.bracket-page .saved-list::-webkit-scrollbar-track,
body.bracket-page .bracket-tree::-webkit-scrollbar-track,
body.bracket-page .problems-list::-webkit-scrollbar-track,
body.bracket-page .panel::-webkit-scrollbar-track {
    background: transparent;
}

/* Saved bracket select checkbox: hidden by default, visible on card hover or when any checked */
.saved-select-checkbox {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.saved-card:hover .saved-select-checkbox,
.saved-list.show-all-checks .saved-select-checkbox {
    opacity: 1;
    visibility: visible;
}

body.bracket-page::-webkit-scrollbar-thumb,
body.bracket-page textarea::-webkit-scrollbar-thumb,
body.bracket-page .saved-list::-webkit-scrollbar-thumb,
body.bracket-page .bracket-tree::-webkit-scrollbar-thumb,
body.bracket-page .problems-list::-webkit-scrollbar-thumb,
body.bracket-page .panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0.08);
}

.create-problem-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    background: #141b27;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
}

.create-problem-item input,
.create-problem-item select {
    width: 100%;
}

/* Style for rating select inside create-problem-item to match app theme */
.create-problem-item .problem-rating-create {
    width: 120px;
    max-width: 45%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
}

.create-problem-item .problem-rating-create:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.remove-create-problem {
    background: transparent;
    color: #ff7d7d;
    border: 1px solid #4f2d33;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
}

.remove-create-problem:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.86rem;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

.participants-tools {
    display: flex;
    justify-content: flex-start;
    margin-top: 8px;
}

#shuffledNamesPreview {
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-soft);
    line-height: 1.45;
    white-space: pre-line;
}

.output-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.meta {
    color: var(--muted);
}

.bracket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.bracket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 12px;
    align-items: start;
}

.bracket-tree {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    column-gap: 44px;
    align-items: center;
    overflow-x: auto;
    overflow-y: visible;
    padding: 10px 26px 16px 6px;
    cursor: grab;
}

.bracket-tree.dragging {
    cursor: grabbing !important;
    user-select: none;
}

.standings-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
    padding: 10px;
}

.standings-panel h4 {
    margin-bottom: 8px;
}

.standings-table-wrap {
    overflow-x: auto;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.standings-table th,
.standings-table td {
    border-bottom: 1px solid var(--border);
    padding: 6px;
    text-align: left;
    white-space: nowrap;
}

.tree-connections {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.round-box {
    position: relative;
    z-index: 1;
    padding: 12px;
    min-width: 320px;
    max-width: none;
    border-color: var(--round-border, var(--border));
    background: linear-gradient(180deg, var(--round-bg-top, rgba(255, 255, 255, 0.02)), var(--round-bg-bottom, rgba(255, 255, 255, 0)));
}

.round-box.round-stage-opening {
    border-color: #2f4a72;
    background: linear-gradient(180deg, rgba(110, 168, 254, 0.16), rgba(110, 168, 254, 0.04));
}

.round-box.round-stage-mid {
    border-color: #30543f;
    background: linear-gradient(180deg, rgba(90, 203, 138, 0.15), rgba(90, 203, 138, 0.04));
}

.round-box.round-stage-semifinal {
    border-color: #5a4377;
    background: linear-gradient(180deg, rgba(198, 123, 243, 0.18), rgba(198, 123, 243, 0.05));
}

.round-box.round-stage-final {
    border-color: #6b5331;
    background: linear-gradient(180deg, rgba(255, 184, 106, 0.2), rgba(255, 184, 106, 0.06));
}

.round-matches {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-left: 24px;
    padding-right: 24px;
}

.match-node {
    position: relative;
}

.round-box:not(:first-child) .round-matches::before,
.round-box:not(:last-child) .round-matches::after {
    content: none;
    position: absolute;
    top: 16px;
    bottom: 16px;
    width: 2px;
    background: #415579;
}

.round-box:not(:first-child) .round-matches::before {
    left: 0;
}

.round-box:not(:last-child) .round-matches::after {
    right: 0;
}

.round-box:not(:last-child) .match-node::after {
    content: none;
    position: absolute;
    right: -24px;
    top: 50%;
    width: 24px;
    height: 2px;
    background: transparent;
}

.round-box:not(:first-child) .match-node::before {
    content: none;
    position: absolute;
    left: -24px;
    top: 50%;
    width: 24px;
    height: 2px;
    background: #415579;
}

.round-box h4 {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.match-card {
    position: relative;
    padding: 10px;
    background: #131b28;
    border: 1px solid #26324a;
    border-radius: 10px;
}

.round-box:not(:last-child) .match-card::after {
    content: none;
    position: absolute;
    right: -24px;
    top: 50%;
    width: 18px;
    height: 2px;
    background: #6f8fbe;
    transform: translateY(-50%);
}

.round-box:not(:last-child) .match-card::before {
    content: none;
    position: absolute;
    right: -30px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid #6f8fbe;
    transform: translateY(-50%);
}

.match-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Live badge inside match cards (top-right) */
.match-card { position: relative; }
.match-card .live-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(11,17,22,0.6);
    border: 1px solid rgba(255,255,255,0.03);
    z-index: 10;
    font-size: 0.50rem;
    color: var(--muted);
}
.match-card .live-badge .live-text { color: var(--success); font-weight:700; letter-spacing:0.06em; }

/* Small heartbeat dot shown beside the main live-dot inside match cards */
.match-card .live-badge .live-heart {
    width: 8px;
    height: 8px;
    display: inline-block;
    background: #5acb8a;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(90, 203, 138, 0.5);
    animation: livePulse 1.2s ease-in-out infinite;
}

@keyframes livePulse {
    0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(90,203,138,0.45); }
    60% { transform: scale(1.15); opacity: 0.85; box-shadow: 0 0 0 6px rgba(90,203,138,0); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(90,203,138,0); }
}

.team-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.92rem;
    padding: 6px 8px;
    background: #0f1520;
    border: 1px solid #27334a;
    border-radius: 8px;
}

/* Ensure the inner span stretches so player-chip width:100% works */
.team-row > span {
    display: block;
    width: 100%;
}

.player-chip {
    display: flex;
    width: 100%;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

/* Make player handles appear bold inside bracket UI */
.player-handle-link,
.player-handle-link span {
    font-weight: 700;
}

.player-handle-max {
    font-weight: 700;
}

.player-handle-legendary-first {
    color: #1a1f29;
    font-weight: 800;
}

.player-handle-legendary-rest {
    color: #ff2f3d;
    font-weight: 800;
}

.player-handle-ultra-first {
    color: #ff2f3d;
    font-weight: 800;
}

.player-handle-ultra-rest {
    color: #1a1f29;
    font-weight: 800;
}

.player-current-rating {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: lowercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Display max rating beside current rating in bracket UI */
.player-max-rating {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: lowercase;
    margin-left: auto;
    white-space: nowrap;
}

/* Right-align points inside the player chip */
.player-points {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 700;
    opacity: 0.9;
    white-space: nowrap;
    text-align: right;
}

/* Container to stack and right-align both ratings (standings only) */
.standings-panel .player-ratings {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: auto;
    gap: 2px;
}

.rank-newbie { color: #8a8f99; }
.rank-pupil { color: #74ca77; }
.rank-specialist { color: #4bc7b8; }
.rank-expert { color: #6ea8fe; }
.rank-cm { color: #c67bf3; }
.rank-master,
.rank-im { color: #ffb86a; }
.rank-gm,
.rank-lgm { color: #ff7d7d; }

.vs-row {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    margin: 6px 0;
}

.match-points {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--muted);
}

.match-history-link {
    display: inline-block;
    margin-top: 6px;
    color: #9dc4ff;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
}

.match-history-link:hover,
.match-history-link-btn:hover {
    text-decoration: underline;
}

.match-history-link-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-top: 1px solid var(--border);
    padding: 9px;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #151d2b;
}

tr:first-child th,
tr:first-child td {
    border-top: none;
}

.note {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 10px;
}

.saved-list {
    display: grid;
    gap: 12px;
}

.saved-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #121925;
    padding: 12px;
}

/* Past bracket visual treatment */
.saved-card.past {
    border-color: rgba(110, 80, 180, 0.6);
    background: linear-gradient(180deg, rgba(34,18,65,0.9), rgba(20,13,40,0.95));
    box-shadow: 0 2px 10px rgba(60,30,120,0.08) inset;
}
.saved-card.past .saved-head {
    position: relative;
    /* match default saved-head spacing so past cards align with active cards */
    padding-left: 25px; /* create gap between decorative bar and text */
    /* align text with the decorative bar: make the bar the source of truth */
    padding-top: 12px;
    padding-bottom: 0;
    align-items: flex-start;
}

/* Reduce top padding inside past cards so title sits closer to the top */
.saved-card.past {
    padding-top: 8px;
}
.saved-card.past .saved-head::before {
    content: '';
    position: absolute;
    /* align the decorative bar with the card's inner padding */
    left: 12px;
    /* match the mobile/top padding used by .saved-head so visual spacing is consistent */
    top: 12px;
    bottom: 12px;
    width: 4px;
    border-radius: 4px;
    background: rgba(110,80,180,0.85);
}
.saved-card.past .saved-meta { color: #bfa7ff; }
.saved-card.past .saved-expand { color: #d9c7ff; }
.saved-card.past .small-btn { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.04); }

.saved-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.saved-toggle {
    cursor: pointer;
    margin-bottom: 0;
}

.saved-expand {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.saved-title-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}

.saved-title-live-dot {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 14px;
    border-radius: 999px;
    flex: 0 0 auto;
    background:
        radial-gradient(circle at 7px 50%, #7cffe8 0 2px, rgba(124, 255, 232, 0.22) 2.5px, transparent 5px),
        linear-gradient(135deg, rgba(88, 204, 255, 0.2), rgba(70, 255, 208, 0.2));
    border: 1px solid rgba(110, 209, 255, 0.42);
    box-shadow: inset 0 0 10px rgba(90, 206, 255, 0.2), 0 0 0 1px rgba(8, 16, 28, 0.34);
    overflow: hidden;
    animation: bracketTitleBeaconBreathe 1.8s ease-in-out infinite;
}

.saved-title-live-dot::before {
    content: "";
    position: absolute;
    top: 1px;
    bottom: 1px;
    width: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    transform: translateX(-130%);
    animation: bracketTitleSignalSweep 1.9s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

.saved-title-live-dot::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    border: 1px solid rgba(124, 255, 232, 0.65);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 0 rgba(124, 255, 232, 0.45);
    animation: bracketTitleBeaconPulse 1.3s ease-out infinite;
}

@keyframes bracketTitleSignalSweep {
    0% { transform: translateX(-140%); opacity: 0; }
    20% { opacity: 0.85; }
    55% { opacity: 0.95; }
    100% { transform: translateX(240%); opacity: 0; }
}

@keyframes bracketTitleBeaconPulse {
    0% { box-shadow: 0 0 0 0 rgba(124, 255, 232, 0.45); opacity: 1; }
    80% { box-shadow: 0 0 0 6px rgba(124, 255, 232, 0); opacity: 0.8; }
    100% { box-shadow: 0 0 0 0 rgba(124, 255, 232, 0); opacity: 1; }
}

@keyframes bracketTitleBeaconBreathe {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-0.5px) scale(1.03); }
    100% { transform: translateY(0) scale(1); }
}

.saved-head .saved-title-main {
    display: inline-flex;
    align-items: center;
}

.saved-details {
    margin-top: 10px;
}

.saved-meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.saved-actions {
    display: flex;
    gap: 8px;
}

.small-btn {
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.85rem;
    cursor: pointer;
}

.small-btn.primary {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    color: #081223;
    border-color: #6ea8fe;
}

.small-btn.success {
    background: linear-gradient(180deg, #7fe3a6, #5acb8a);
    color: #072213;
    border-color: #5acb8a;
}

.small-btn.success:disabled {
    opacity: 0.9;
    color: #072213;
    border-color: #7fe3a6;
    background: linear-gradient(180deg, #9defc1, #7fe3a6);
}

.small-btn.danger {
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #250706;
    border-color: #ff7d7d;
}

/* Make the small action buttons on the bracket form match hover green theme */
#shuffleNamesBtn,
#bracketAddProblemBtn {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 7px 10px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.14s ease, transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

#shuffleNamesBtn:hover,
#bracketAddProblemBtn:hover,
#shuffleNamesBtn:focus-visible,
#bracketAddProblemBtn:focus-visible {
    background: linear-gradient(180deg, #7fe3a6, #5acb8a);
    color: #072213;
    border-color: #5acb8a;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(42,150,85,0.10);
    outline: none;
}

#shuffleNamesBtn:disabled,
#bracketAddProblemBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Centered pill-style "See more" matching the page theme
   Applied to both saved & past brackets lists */
#savedBracketsSeeMoreBtn,
#pastBracketsSeeMoreBtn {
    display: block;
    margin: 14px auto;
    /* tighter left side, more room on right for chevron */
    padding: 10px 40px 10px 12px;
    font-size: 0.9rem;
    width: min(180px, calc(100% - 40px));
    max-width: 100%;
    border-radius: 999px;
    text-align: center;
    background: linear-gradient(180deg, var(--panel-soft), var(--panel));
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: relative;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

#savedBracketsSeeMoreBtn::after,
#pastBracketsSeeMoreBtn::after {
    content: "";
    display: inline-block;
    width: 18px;
    height: 14px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'><path d='M1 1 L6 6 L11 1 M1 5 L6 10 L11 5' stroke='%23f3f5f8' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

#savedBracketsSeeMoreBtn:hover,
#pastBracketsSeeMoreBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    background: linear-gradient(180deg, #7fe3a6, #5acb8a);
    color: #072213;
    border-color: #5acb8a;
}

#savedBracketsSeeMoreBtn:hover::after,
#pastBracketsSeeMoreBtn:hover::after {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'><path d='M1 1 L6 6 L11 1 M1 5 L6 10 L11 5' stroke='%23072213' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

@media (max-width: 520px) {
    #savedBracketsSeeMoreBtn,
    #pastBracketsSeeMoreBtn {
        width: calc(100% - 36px);
        min-width: 0;
        padding: 10px 36px 10px 10px; /* mobile: slightly reduced left padding */
    }
    #savedBracketsSeeMoreBtn::after,
    #pastBracketsSeeMoreBtn::after { right: 12px; width: 16px; height: 12px; }
}

/* Hide per-card delete buttons by default to reduce visual clutter; reveal on hover or when any selection exists */
.saved-card .delete-bracket-btn {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.saved-card:hover .delete-bracket-btn,
.saved-card:focus-within .delete-bracket-btn,
.saved-list.show-all-checks .saved-card .delete-bracket-btn {
    opacity: 1;
    visibility: visible;
}

/* Hide per-card share buttons by default; reveal on hover (matches delete button behavior) */
.saved-card .share-bracket-btn {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.saved-card:hover .share-bracket-btn,
.saved-card:focus-within .share-bracket-btn,
.saved-list.show-all-checks .saved-card .share-bracket-btn {
    opacity: 1;
    visibility: visible;
}

/* Make share button more eye-catching on desktop */
.saved-card .share-bracket-btn {
    /* Glass / frosted effect */
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 8px 10px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 8px 26px rgba(2,6,23,0.45);
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.12s ease;
    position: relative;
    overflow: hidden;
}
.saved-card .share-bracket-btn:hover,
.saved-card .share-bracket-btn:focus {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 18px 40px rgba(2,6,23,0.5), 0 0 0 6px rgba(47,116,255,0.06);
}

/* Slight pulsing attention animation when visible */
@keyframes sharePulse {
    0% { box-shadow: 0 8px 26px rgba(2,6,23,0.25); }
    50% { box-shadow: 0 12px 34px rgba(47,116,255,0.06); }
    100% { box-shadow: 0 8px 26px rgba(2,6,23,0.25); }
}
.saved-card:hover .share-bracket-btn {
    animation: sharePulse 2.2s infinite ease-in-out;
}

/* Run glare continuously while hovered or focused */
.saved-card:hover .share-bracket-btn::before,
.saved-card:focus-within .share-bracket-btn::before {
    /* Quick sweep early in a 20s cycle, then remain hidden */
    animation: glareMove 20s ease-in-out infinite;
}

/* Moving glare / sheen effect */
.saved-card .share-bracket-btn::before {
    content: '';
    position: absolute;
    top: -30%;
    left: 0;
    /* make the sheen wide enough to sweep across entire button */
    width: 60%;
    height: 160%;
    background: linear-gradient(120deg, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.36) 42%, rgba(255,255,255,0.14) 58%, rgba(255,255,255,0.0) 100%);
    transform: translateX(-140%) skewX(-18deg);
    filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    animation: none;
}

@keyframes glareMove {
    /* Brief visible sweep at start of each 20s cycle, then stay hidden */
    0% { transform: translateX(-140%) skewX(-18deg); opacity: 0; }
    5% { opacity: 0.9; }
    10% { transform: translateX(120%) skewX(-18deg); opacity: 0.9; }
    14% { opacity: 0; }
    100% { transform: translateX(140%) skewX(-18deg); opacity: 0; }
}

/* Reduce motion on small screens for performance */
@media (max-width: 640px) {
    .saved-card .share-bracket-btn::before { display: none; }
}

/* Mobile: move actions to top-right and show compact icon */
@media (max-width: 640px) {
    .saved-head {
        position: relative;
        padding-right: 96px; /* space for action icons */
        padding-top: 8px; /* avoid actions overlapping the title */
        align-items: flex-start;
    }
    /* saved-actions will be positioned below the expand label (defined further down) */
    /* compact circular delete icon */
    .saved-card .delete-bracket-btn {
        padding: 6px;
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        font-size: 0; /* hide textual label */
        overflow: hidden;
    }
    .saved-card .delete-bracket-btn::before {
        content: '🗑️';
        font-size: 16px;
        line-height: 1;
    }
    .saved-card .share-bracket-btn {
        padding: 6px;
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        font-size: 0; /* hide textual label */
        overflow: hidden;
        margin-left: 8px;
    }
    .saved-card .share-bracket-btn::before {
        content: '🔗';
        font-size: 16px;
        line-height: 1;
    }
    /* hide original button text for screenreaders will still read inner text; keep accessible name via aria-label in JS if needed */
    .saved-card .delete-bracket-btn[aria-label]::before { }

    /* Place the expand label at the top-right corner for both active and past cards; position it relative to the header */
    .saved-head .saved-expand {
        position: absolute;
        right: 12px;
        top: 8px;
        font-size: 0.82rem;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        font-weight: 700;
        opacity: 0.8; /* 80% opacity as requested */
        z-index: 6;
    }

    /* Mobile: center the decorative bar and vertically center header content */
    .saved-card.past .saved-head {
        padding-top: 6px; /* slightly tighter on mobile */
        padding-bottom: 6px;
        align-items: center; /* vertically center title with bar */
    }

    /* Position the bar using center-transform so it stays vertically centered
       relative to the header regardless of font-size or line-height. */
    .saved-card.past .saved-head::before {
        top: 50%;
        bottom: auto;
        left: 8px;
        transform: translateY(-50%);
        height: calc(100% - 12px);
    }

    /* Stack actions vertically below the expand label */
    .saved-card .saved-actions {
        position: absolute;
        right: 12px;
        top: 40px;
        display: flex;
        gap: 8px;
        align-items: center;
        flex-direction: column;
        z-index: 5;
    }

    /* slightly reduce past-card top padding on mobile for tighter layout */
    .saved-card.past {
        padding-top: 6px;
    }

    /* Reduce left gap between the decorative bar and text for past cards on mobile */
    .saved-card.past .saved-head {
        padding-left: 16px;
    }
    /* Nudge the title and meta together so they align with the bar */
    .saved-card.past .saved-head > div {
        transform: translateY(-6px);
    }
}

/* Make delete button in past brackets visible but not overly bright */
.saved-card.past .delete-bracket-btn,
.saved-card.past .small-btn.delete-bracket-btn,
.saved-list.show-all-checks .saved-card.past .delete-bracket-btn {
    background: linear-gradient(180deg, rgba(255,86,86,0.08), rgba(255,86,86,0.04));
    color: #ffecec;
    border-color: rgba(255,86,86,0.22);
    box-shadow: 0 6px 12px rgba(0,0,0,0.18);
}
.saved-card.past .delete-bracket-btn:hover,
.saved-card.past .delete-bracket-btn:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.22);
    background: linear-gradient(180deg, rgba(255,86,86,0.12), rgba(255,86,86,0.06));
    border-color: rgba(255,86,86,0.34);
}

/* Ensure disabled state still looks appropriate */
.saved-card.past .delete-bracket-btn:disabled {
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.small-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.small-btn.primary:disabled {
    opacity: 0.9;
    color: #081223;
    border-color: #6ea8fe;
    background: linear-gradient(180deg, #8bbcff, #6ea8fe);
}

/* Winner button: bright, eye-catching and focus-friendly */
.small-btn.winner-btn {
    position: relative;
    background: transparent; /* outline-only */
    color: #ffd54a; /* bright gold text */
    border: 2px solid transparent;
    padding: 7px 12px;
    font-weight: 800;
    border-radius: 8px;
    box-shadow: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
    /* gradient stroke using border-image so there's no fill */
    background-color: transparent;
    border: 2px solid transparent;
    border-image: linear-gradient(90deg, #28a745, #6ddf6d) 1;
}

/* Crown icon before the label */
.small-btn.winner-btn::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: -3px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2328a745'><path d='M12 2l2.9 5.88L21 9l-4.5 3.9L17.8 21 12 17.77 6.2 21l1.3-8.1L3 9l6.1-.12L12 2z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    filter: drop-shadow(0 1px 0 rgba(0,0,0,0.12));
}

.small-btn.winner-btn:hover {
    transform: translateY(-2px);
    /* no fill on hover — preserve outline-only appearance; add subtle glow */
    box-shadow: 0 12px 30px rgba(40,167,69,0.12);
}

.small-btn.winner-btn:focus,
.small-btn.winner-btn:focus-visible {
    outline: none;
    /* focus ring only — no fill */
    box-shadow: 0 0 0 6px rgba(40,167,69,0.12);
}

/* Winner block (inline display) — user provided style */
.winner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem; /* match .small-btn */
    font-weight: 700;
    color: var(--text);
    border: 2px solid transparent;
    padding: 7px 10px; /* match .small-btn spacing */
    border-radius: 8px;
    background-color: transparent; /* ensure no fill */
    /* gradient stroke using border-image */
    border-image: linear-gradient(90deg, #28a745, #6ddf6d) 1;
    width: auto;
    margin: 0 8px 0 0; /* keep inline spacing with other controls */
}

.winner-subtext {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: #6ddf6d; /* light green */
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.02em;
}

/* Remove underline for links inside winner */
.winner a {
    text-decoration: none;
    color: inherit;
}

.site-footer {
    margin-top: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
    font-size: 0.9rem;
}

.site-footer a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.site-footer a:hover {
    text-decoration: underline;
}

.site-version {
    margin-top: 2px;
    font-size: 0.72rem;
    opacity: 0.78;
    letter-spacing: 0.03em;
}

@media (max-width: 980px) {
    .type-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .bracket-layout {
        grid-template-columns: 1fr;
    }

    .create-options {
        grid-template-columns: 1fr;
    }

    .create-problem-item {
        grid-template-columns: 1fr;
    }

    .remove-create-problem {
        width: 100%;
        height: auto;
        padding: 8px;
    }
}

/* Saved brackets responsive search: show compact icon on small screens */
.saved-brackets-search .saved-search-btn {
    display: none;
    padding: 6px 8px;
    min-width: 40px;
}
.saved-brackets-search input#savedBracketsSearch {
    transition: width 160ms ease, opacity 160ms ease;
}

@media (max-width: 720px) {
    /* use wrapping row so left toolbar stays left and right controls stay right */
    .saved-brackets-search { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
    .saved-brackets-search .saved-search-btn { display: inline-flex; }
    .saved-brackets-search-right { display:flex; gap:8px; align-items:center; justify-content:space-between; flex-wrap:wrap; }
    /* hide input by default on small screens; reveal only when toggled open */
    .saved-brackets-search input#savedBracketsSearch { display: none; width: 0; opacity: 0; padding-left: 6px; }
    .saved-brackets-search.search-open input#savedBracketsSearch { display: block; width: 180px; opacity: 1; }

    /* Ensure Mine toggle remains visible */
    .saved-brackets-search-right .small-btn { flex: 0 0 auto; display: inline-flex; }
    .saved-brackets-search-left { display:flex; align-items:center; gap:8px; }

    /* Keep bulk actions (select all / delete) on the left; allow them to wrap if needed */
    .saved-brackets-search-left { order: 0; justify-content: flex-start; }
    .saved-brackets-search-left #savedBracketsSelectAll { margin-right: 8px; }
    .saved-brackets-search-left #savedBracketsDeleteSelectedBtn { white-space: normal; max-width: 240px; }

    /* Right zone aligns right and stays on the same row where possible */
    .saved-brackets-search-right { order: 1; margin-left: auto; display:flex; gap:8px; align-items:center; }
    .saved-brackets-search-right .saved-search-btn { margin-left: 0; }
}

/* Mobile tweaks for match cards: keep action buttons from overlapping and resize badges */
@media (max-width: 720px) {
    .match-card .saved-actions {
        position: static !important;
        margin-top: 8px !important;
        display: flex;
        gap: 6px;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
    }

    .match-card .live-badge {
        top: 6px !important;
        right: 6px !important;
        padding: 4px 6px !important;
        font-size: 0.65rem !important;
    }

    /* Ensure player chips stack neatly and badges don't push content down awkwardly */
    .team-row {
        padding: 6px 6px;
    }

    .player-chip {
        align-items: center !important;
    }
}

/* Mobile: mirror wide-viewport orientation using a two-column grid so
   action block (Advanced/Create + History) stays to the right. */
@media (max-width: 720px) {
    .match-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-auto-rows: auto;
        gap: 8px;
        align-items: center;
    }

    /* Make the header span both columns */
    .match-card .match-head {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        gap: 8px;
        align-items: center;
        font-size: 0.82rem;
    }

    /* Team rows live in the left column */
    .match-card .team-row:first-of-type { grid-column: 1 / 2; }
    .match-card .vs-row { grid-column: 1 / 2; text-align: center; }
    .match-card .team-row:last-of-type { grid-column: 1 / 2; }

    /* Keep actions in the right column and vertically centered */
    .match-card .saved-actions {
        grid-column: 2 / 3;
        grid-row: 2 / 4;
        align-self: center;
        justify-self: end;
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: nowrap;
    }

    /* Winner/create block stacks internally but remains compact so History sits beside it */
    .match-card .saved-actions > div {
        display: inline-flex !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .match-card .saved-actions .create-room-btn,
    .match-card .saved-actions .match-history-link-btn,
    .match-card .saved-actions .small-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }

    .match-card .saved-actions .create-room-btn { margin-right: 8px; }
}

/* Force action buttons to remain side-by-side on mobile (advanced/create + history) */
@media (max-width: 720px) {
    .match-card .saved-actions {
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        width: auto !important;
    }

    /* Keep winner/create block compact and stacked internally, so it sits beside History */
    .match-card .saved-actions > div {
        display: inline-flex !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .match-card .saved-actions .create-room-btn,
    .match-card .saved-actions .match-history-link-btn,
    .match-card .saved-actions .small-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }

    /* Give a little breathing room between primary and secondary actions */
    .match-card .saved-actions .create-room-btn { margin-right: 8px; }
}

/* Fix saved-card header on small screens: avoid title collapsing into narrow column */
@media (max-width: 720px) {
    .saved-head {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }
    .saved-head > div:nth-child(1) { /* checkbox area */
        flex: 0 0 auto;
        order: 0;
    }
    .saved-head > div:nth-child(2) { /* title area */
        flex: 1 1 100%;
        min-width: 0;
        order: 1;
    }
    .saved-head > .saved-actions { /* actions area */
        flex: 0 0 auto;
        order: 2;
        margin-left: 0;
    }
    .saved-head strong {
        display: block;
        white-space: nowrap; /* keep title on single line */
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Remove underline from player/handle links inside bracket view */
.player-chip a,
.player-handle-max a,
.player-handle-ultra-first a,
.player-handle-ultra-rest a,
.global-handle-chip,
.global-handle-chip a {
    text-decoration: none;
    text-decoration-skip-ink: none;
}

.player-chip a:hover,
.player-handle-max a:hover,
.player-handle-ultra-first a:hover,
.player-handle-ultra-rest a:hover,
.global-handle-chip:hover,
.global-handle-chip a:hover {
    text-decoration: none;
}

/* Standings info popup (hover) */
.standings-info-wrap {
    position: relative;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

.standings-info-btn {
    width: 20px;
    height: 20px;
    line-height: 18px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.06);
    background: linear-gradient(180deg,#fff,#fbfbfb);
    color: #0b69ff;
    font-size: 12px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}

.standings-info-btn:focus { outline: 2px solid rgba(11,105,255,0.18); }

.standings-info-popup {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1000;
    width: min(420px, 86vw);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    background: #fff;
    color: #111;
    font-size: 13px;
    transform-origin: top right;
    animation: fadeInScale .14s ease both;
    max-height: calc(100vh - 64px);
    overflow: auto;
}

.standings-info-popup::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0,0,0,0.04);
}

/* When measuring (JS), make it render but hidden so we can compute sizes */
.standings-info-popup.measuring { display: block; visibility: hidden; }

/* Flip horizontally when there's not enough space on the right */
.standings-info-popup.flip-horizontal {
    left: 0;
    right: auto;
    transform-origin: top left;
}
.standings-info-popup.flip-horizontal::before {
    right: auto;
    left: 14px;
    box-shadow: 2px -2px 4px rgba(0,0,0,0.04);
}

/* Flip vertically (show above the button) */
.standings-info-popup.flip-vertical {
    top: auto;
    bottom: calc(100% + 8px);
    transform-origin: bottom right;
}
.standings-info-popup.flip-vertical::before {
    top: auto;
    bottom: -8px;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.04);
}

.standings-info-popup.visible {
    display: block;
    visibility: visible;
}


.standings-info-card .standings-info-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: #111;
    font-size: 12px;
}

.standings-info-card .standings-info-body {
    color: #333;
    line-height: 1.45;
    font-weight: 400;
}

.standings-info-card .standings-info-body strong { font-weight: 600; }

.standings-info-card p { margin: 0 0 8px 0; }

.standings-info-card .standings-info-section h5 {
    margin: 10px 0 6px 0;
    font-size: 13px;
    font-weight: 700;
    color: #222;
}

.standings-info-card ol,
.standings-info-card ul { margin: 0 0 0 18px; padding: 0; }

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Mobile-friendly tweaks: tighter columns and improved horizontal scroll
   Also override mobile grid rules so actions sit below match content (like wide view) */
@media (max-width: 720px) {
    /* Allow smoother native scrolling on touch devices */
    .bracket-tree {
        -webkit-overflow-scrolling: touch;
        column-gap: 18px; /* tighter spacing so more rounds are visible */
        padding: 8px 12px 12px 6px;
    }

    /* Reduce each round width so the layout feels more like desktop on narrow screens */
    .round-box {
        min-width: 240px; /* was 320px */
        padding: 10px;
    }

    /* Reduce spacing inside rounds so match cards appear wider relative to viewport */
    .round-matches {
        gap: 10px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .match-card {
        /* Force normal document flow so the actions appear after the match rows
           (desktop behavior). This overrides earlier mobile grid rules. */
        display: block !important;
        padding: 8px;
    }

    .match-card .match-head {
        display: flex !important;
        justify-content: space-between !important;
        gap: 8px;
        align-items: center;
        font-size: 0.82rem;
    }

    .team-row {
        padding: 6px;
        font-size: 0.95rem;
    }

    /* Ensure the actions sit below the card content and span full width like on desktop */
    .match-card .saved-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        margin-top: 8px !important;
        justify-content: flex-end !important; /* keep buttons aligned to the right */
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        align-self: auto !important;
        justify-self: auto !important;
    }

    /* Slightly reduce font spacing inside player chips */
    .player-chip { gap: 6px; }
}

/* Strong mobile override to keep action buttons side-by-side on very
   narrow screens (phones). This forces the Create/History controls to
   share a single row and shrink as needed rather than stacking. */
@media (max-width: 480px) {
    .match-card .saved-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .match-card .saved-actions .create-room-btn {
        display: inline-flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex: 1 1 60% !important;
        min-width: 0 !important;
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
    }

    .match-card .saved-actions .match-history-link-btn {
        display: inline-flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex: 0 1 35% !important;
        min-width: 0 !important;
        padding: 6px 8px !important;
        font-size: 0.85rem !important;
    }

    .match-card .saved-actions .small-btn {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* Ensure action buttons remain side-by-side on narrow screens by
   allowing them to shrink and share available space. This keeps the
   Create / History buttons on a single row (similar to wider view). */
@media (max-width: 720px) {
    .match-card .saved-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        align-items: center !important;
        justify-content: flex-end !important;
    }

    .match-card .saved-actions .small-btn,
    .match-card .saved-actions .create-room-btn,
    .match-card .saved-actions .match-history-link-btn {
        min-width: 0 !important; /* allow flex items to shrink */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Prefer the primary/create button to take more space, history stays compact */
    .match-card .saved-actions .create-room-btn {
        flex: 1 1 65% !important;
    }
    .match-card .saved-actions .match-history-link-btn {
        flex: 0 1 35% !important;
        display: inline-flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
}
