/* TOURNAMENT BRACKETS — TYGO GAMBLES */

:root {
    --green: #1fff87;
    --green-dim: rgba(31, 255, 135, 0.07);
    --green-glow: rgba(31, 255, 135, 0.22);
    --purple: #a044ff;
    --purple-deep: #8126ff;
    --purple-dim: rgba(160, 68, 255, 0.1);
    --bg-dark: #07030a;
    --card-bg: #0d0816;
    --card-bright: #110e1c;
    --line: rgba(160, 68, 255, 0.18);
    --line-bright: rgba(160, 68, 255, 0.4);
    --text-muted: #8a81ad;
    --gold: #ffca28;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-dark);
    color: #fff;
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* ── BACKGROUND ── */
.bg-glow {
    position: fixed; inset: 0; z-index: -2;
}

.bg-glow::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 60% 0%, rgba(129,38,255,0.14) 0%, transparent 65%),
        radial-gradient(ellipse 40% 30% at 10% 80%, rgba(31,255,135,0.04) 0%, transparent 55%);
}

.bg-glow::after {
    content: '';
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(160,68,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(160,68,255,0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 60% at 60% 20%, black 0%, transparent 100%);
}

/* Ambient floating particles */
.bg-particles { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

.bg-particle {
    position: absolute;
    border-radius: 50%;
    background: var(--purple);
    animation: floatParticle linear infinite;
}

@keyframes floatParticle {
    0%   { transform: translateY(0px) scale(1); opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(-120px) scale(0.3); opacity: 0; }
}

/* ── LAYOUT ── */
.main-layout {
    display: flex;
    height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: #080512;
    border-right: 1px solid var(--line);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
    gap: 0;
    position: relative;
}

/* Green shimmer on right edge of sidebar */
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: -1px; bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, var(--green) 40%, var(--purple) 70%, transparent 100%);
    opacity: 0.3;
    animation: sidebarShimmer 4s ease-in-out infinite;
}

@keyframes sidebarShimmer {
    0%, 100% { opacity: 0.15; }
    50%       { opacity: 0.5; }
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}

.sidebar-brand img {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(31,255,135,0.3);
}

.sidebar-brand span {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.75rem; font-weight: 800;
    letter-spacing: 3px;
    color: var(--green);
}

/* Control group */
.control-group { margin-bottom: 16px; }

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.label-row label {
    font-size: 0.58rem; font-weight: 900;
    letter-spacing: 2.5px;
    color: var(--purple);
}

.count-badge {
    font-size: 0.6rem; font-weight: 900;
    background: var(--purple-dim);
    border: 1px solid var(--line);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 20px;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
    font-family: 'Rajdhani', sans-serif;
}

.count-badge.valid {
    background: var(--green-dim);
    border-color: rgba(31,255,135,0.3);
    color: var(--green);
    box-shadow: 0 0 10px rgba(31,255,135,0.15);
}

.count-badge.invalid {
    background: rgba(255,60,60,0.08);
    border-color: rgba(255,60,60,0.25);
    color: #ff7070;
}

.input-hint {
    font-size: 0.58rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    opacity: 0.7;
    letter-spacing: 0.3px;
}

#playerInput {
    width: 100%;
    height: 260px;
    background: rgba(0,0,0,0.5);
    color: var(--green);
    border: 1px solid rgba(160,68,255,0.15);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Inter', monospace;
    font-size: 0.78rem;
    resize: none;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    line-height: 1.7;
}

#playerInput:focus {
    border-color: rgba(160,68,255,0.4);
    box-shadow: 0 0 0 3px rgba(160,68,255,0.07), inset 0 0 20px rgba(31,255,135,0.02);
}

#playerInput.flash {
    animation: inputFlash 0.4s ease;
}

@keyframes inputFlash {
    0%   { border-color: var(--green); box-shadow: 0 0 16px rgba(31,255,135,0.2); }
    100% { border-color: rgba(160,68,255,0.15); box-shadow: none; }
}

/* Buttons */
.action-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 14px;
    border-radius: 8px;
    font-weight: 900;
    cursor: pointer;
    border: none;
    font-size: 0.68rem;
    letter-spacing: 1.5px;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    font-family: 'Inter', sans-serif;
}

button svg {
    width: 13px; height: 13px;
    flex-shrink: 0;
    stroke-width: 2.5;
}

button:active { transform: scale(0.96); }

.btn-shuffle {
    background: var(--purple-dim);
    color: var(--purple);
    border: 1px solid rgba(160,68,255,0.25);
}
.btn-shuffle:hover {
    background: rgba(160,68,255,0.16);
    box-shadow: 0 0 16px rgba(160,68,255,0.15);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--green);
    color: #000;
    font-size: 0.72rem;
    box-shadow: 0 4px 20px rgba(31,255,135,0.2);
}
.btn-primary:hover {
    background: #36ffaa;
    box-shadow: 0 6px 28px rgba(31,255,135,0.35);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: rgba(255,255,255,0.18);
    font-size: 0.6rem;
    border: 1px solid rgba(255,255,255,0.07);
    letter-spacing: 1px;
}
.btn-outline:hover {
    color: #ff7070;
    border-color: rgba(255,60,60,0.25);
    background: rgba(255,60,60,0.05);
}

/* Sidebar shake on invalid input */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.45s ease; }

/* Round legend */
.sidebar-footer { margin-top: auto; }

.round-legend {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    transition: color 0.3s;
}

.legend-item.done { color: var(--green); }

.legend-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--line-bright);
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.legend-item.done .legend-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* ── CONTENT AREA ── */
.content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.scroll-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(160,68,255,0.3) transparent;
}

.scroll-wrapper::-webkit-scrollbar { width: 4px; height: 4px; }
.scroll-wrapper::-webkit-scrollbar-track { background: transparent; }
.scroll-wrapper::-webkit-scrollbar-thumb { background: rgba(160,68,255,0.3); border-radius: 4px; }

/* ── HEADER ── */
.tourney-header {
    padding: 28px 60px 20px;
    flex-shrink: 0;
    position: relative;
}

.header-eyebrow {
    font-size: 0.62rem; font-weight: 900;
    letter-spacing: 4px;
    color: var(--green);
    margin-bottom: 6px;
    opacity: 0.7;
}

.tourney-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 3px;
    line-height: 1;
}

.tourney-title span {
    background: linear-gradient(90deg, var(--purple), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-line {
    margin-top: 16px;
    height: 1px;
    background: linear-gradient(90deg, var(--purple-deep), var(--green), transparent);
    opacity: 0.35;
}

/* ── BRACKET CONTAINER ── */
.bracket-container {
    display: flex;
    padding: 30px 60px 80px;
    flex: 1;
    align-items: stretch;
    gap: 0;
}

/* ── ROUND COLUMNS ── */
.round-column {
    display: flex;
    flex-direction: column;
    width: 196px;
    flex-shrink: 0;
    margin-right: 56px;
    opacity: 0;
    animation: colReveal 0.5s ease forwards;
}

.round-column:last-child { margin-right: 0; }

@keyframes colReveal {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.round-label {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.round-label span {
    font-size: 0.58rem; font-weight: 900;
    letter-spacing: 2.5px;
    color: var(--purple);
    padding: 4px 12px;
    border: 1px solid rgba(160,68,255,0.2);
    border-radius: 20px;
    background: var(--purple-dim);
    white-space: nowrap;
}

.champion-col .round-label span {
    color: var(--gold);
    border-color: rgba(255,202,40,0.3);
    background: rgba(255,202,40,0.06);
}

/* ── MATCH WRAPPER (handles vertical spacing) ── */
.match-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: 8px 0;
}

/* ── HORIZONTAL CONNECTOR LINE ── */
.match-wrapper::after {
    content: '';
    position: absolute;
    right: -56px;
    top: 50%;
    width: 56px;
    height: 1px;
    background: linear-gradient(90deg, var(--line-bright), var(--line));
}

.round-column:last-child .match-wrapper::after,
.champion-col .match-wrapper::after { display: none; }

/* ── MATCHUP BOX ── */
.matchup-box {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    position: relative;
    z-index: 10;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.matchup-box:hover {
    border-color: rgba(160,68,255,0.35);
    box-shadow: 0 8px 30px rgba(129,38,255,0.12);
}

/* Top sheen line on each matchup */
.matchup-box::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(160,68,255,0.4), transparent);
    opacity: 0.6;
}

/* ── VS DIVIDER ── */
.vs-divider {
    text-align: center;
    font-size: 0.52rem; font-weight: 900;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.08);
    padding: 0;
    height: 1px;
    line-height: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.vs-divider::before {
    content: attr(class);
    display: none;
}

/* Actual divider line */
.vs-divider {
    display: flex;
    align-items: center;
    height: auto;
    padding: 0 10px;
    gap: 6px;
    font-size: 0;
}

.vs-divider::before, .vs-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.04);
    display: block;
}

/* ── PLAYER ROWS ── */
.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    opacity: 0.35;
    transition: background 0.25s, opacity 0.25s;
    position: relative;
}

.player-row.active { opacity: 1; }

.player-row.winner {
    background: rgba(31,255,135,0.06);
    opacity: 1;
}

/* Winner left accent */
.player-row.winner::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.player-row.loser {
    opacity: 0.35;
}

.player-row.loser .p-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.p-name {
    font-size: 0.78rem; font-weight: 800;
    color: #fff;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.3px;
    padding-right: 8px;
    transition: color 0.2s;
}

.player-row.winner .p-name { color: var(--green); }

.p-score {
    width: 42px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.07);
    color: var(--green);
    text-align: center;
    font-size: 0.8rem;
    border-radius: 5px;
    padding: 3px 4px;
    font-weight: 900;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    font-family: 'Rajdhani', sans-serif;
}

.p-score:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(160,68,255,0.15);
}

.p-score:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ── CHAMPION DISPLAY ── */
.champion-col { width: 180px; }

.champion-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    background: var(--card-bg);
    border: 1px solid rgba(255,202,40,0.15);
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.4s, box-shadow 0.4s;
}

.champion-display.revealed {
    border-color: rgba(255,202,40,0.4);
    box-shadow: 0 0 40px rgba(255,202,40,0.1), 0 20px 40px rgba(0,0,0,0.4);
    animation: champReveal 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes champReveal {
    from { transform: scale(0.88); opacity: 0.3; }
    to   { transform: scale(1);    opacity: 1; }
}

.champion-display::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(255,202,40,0.06) 0%, transparent 65%);
    pointer-events: none;
}

.champ-trophy-wrap {
    margin-bottom: 12px;
    position: relative;
}

.trophy-icon {
    width: 44px; height: 44px;
    fill: var(--gold);
    filter: drop-shadow(0 0 14px rgba(255,202,40,0.5));
    animation: trophyFloat 3s ease-in-out infinite;
}

@keyframes trophyFloat {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-5px); }
}

.champ-glow-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 1px solid rgba(255,202,40,0.3);
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% { transform: translate(-50%,-50%) scale(1);   opacity: 0.6; }
    50%       { transform: translate(-50%,-50%) scale(1.25); opacity: 0; }
}

.champ-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.3rem; font-weight: 800;
    color: var(--gold);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255,202,40,0.3);
    word-break: break-word;
}

/* ── EMPTY STATE ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 14px;
    padding: 80px 20px;
}

.empty-icon svg {
    width: 48px; height: 48px;
    stroke: rgba(160,68,255,0.25);
    margin-bottom: 4px;
}

.empty-text {
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 6px;
    color: rgba(255,255,255,0.06);
}

.empty-sub {
    font-size: 0.7rem;
    color: rgba(160,68,255,0.25);
    letter-spacing: 1px;
    font-weight: 600;
}

/* ── CHAMPION MODAL ── */
.champ-modal {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
}

.champ-modal.open {
    display: flex;
    animation: modalIn 0.35s ease both;
}

@keyframes modalIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.champ-modal-inner {
    position: relative;
    text-align: center;
    padding: 52px 48px 40px;
    background: #0a0514;
    border: 1px solid rgba(255,202,40,0.3);
    border-radius: 28px;
    max-width: 400px; width: 90%;
    box-shadow: 0 0 80px rgba(255,202,40,0.08), 0 40px 80px rgba(0,0,0,0.7);
    animation: modalPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both 0.05s;
}

@keyframes modalPop {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.champ-fireworks {
    position: absolute; inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 28px;
}

.fw-particle {
    position: absolute;
    width: 5px; height: 5px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: fwBurst 0.9s ease-out forwards;
}

@keyframes fwBurst {
    0%   { transform: translate(-50%,-50%) translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(-50%,-50%) translate(var(--dx),var(--dy)) scale(0); opacity: 0; }
}

.champ-crown {
    margin-bottom: 16px;
}

.champ-crown svg {
    width: 52px; height: 52px;
    fill: var(--gold);
    filter: drop-shadow(0 0 20px rgba(255,202,40,0.6));
    animation: crownBounce 1s cubic-bezier(0.34,1.56,0.64,1) both 0.2s;
}

@keyframes crownBounce {
    from { transform: scale(0) rotate(-20deg); }
    to   { transform: scale(1) rotate(0deg); }
}

.champ-label {
    font-size: 0.62rem; font-weight: 900;
    letter-spacing: 5px;
    color: rgba(255,202,40,0.5);
    margin-bottom: 10px;
}

.champ-name-display {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.4rem; font-weight: 800;
    color: var(--gold);
    letter-spacing: 2px;
    text-shadow: 0 0 30px rgba(255,202,40,0.4);
    margin-bottom: 28px;
    text-transform: uppercase;
    word-break: break-word;
    animation: nameReveal 0.5s ease both 0.3s;
}

@keyframes nameReveal {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.champ-close {
    background: var(--green-dim);
    border: 1px solid rgba(31,255,135,0.3);
    color: var(--green);
    padding: 10px 32px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 800; font-size: 0.75rem;
    letter-spacing: 2px;
    transition: 0.25s;
    display: block;
    width: 100%;
    justify-content: center;
}

.champ-close:hover {
    background: var(--green);
    color: #000;
    box-shadow: 0 0 20px rgba(31,255,135,0.3);
}

/* ── FOOTER ── */
.footer-v2 {
    border-top: 1px solid var(--line);
    padding: 40px 60px;
    background: rgba(8,5,18,0.8);
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-brand { display: flex; flex-direction: column; gap: 6px; }

.footer-brand img {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(160,68,255,0.3);
}

.footer-brand p {
    font-size: 0.7rem;
    color: #555c71;
    font-weight: 600;
}

.footer-links {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.footer-links a {
    text-decoration: none;
    color: #8a81ad;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    padding: 5px 10px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.footer-links a:hover {
    color: var(--green);
    background: var(--green-dim);
}

.footer-credit {
    font-size: 0.72rem;
    color: #555c71;
}

.vman {
    color: var(--purple);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}
.vman:hover { color: var(--green); }