/* ═══════════════════════════════════════════════════
   THE BLADER NETWORK — Main Stylesheet
   Cyber Beyblade X Aesthetic
   ═══════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
html { scroll-behavior: smooth; }
button, a, input, select, textarea {
    touch-action: manipulation;
    -webkit-touch-callout: none;
}
button, .btn, .nav-tab, .mobile-nav-tab {
    -webkit-user-select: none;
    user-select: none;
}

/* ── Design Tokens ────────────────────────────────── */
:root {
    --primary:       #00ff41;
    --secondary:     #00d4ff;
    --accent:        #ffffff;
    --dark:          #000000;
    --light:         #ffffff;
    --success:       #00ff41;
    --danger:        #ff2d55;
    --warning:       #ffcc00;
    --info:          #00d4ff;

    --bbx-red:       #ff2d55;
    --bbx-blue:      #00d4ff;
    --bbx-gold:      #ffcc00;
    --bbx-dark:      #000000;
    --electric-green:#00ff41;

    /* Glass surfaces */
    --glass:         rgba(0, 255, 65, 0.06);
    --glass-hover:   rgba(0, 255, 65, 0.10);
    --glass-border:  rgba(0, 255, 65, 0.18);
    --glass-border-bright: rgba(0, 255, 65, 0.4);

    /* UI */
    --bg:            #050508;
    --bg-card:       rgba(8, 12, 20, 0.92);
    --text-muted:    rgba(255,255,255,0.5);
    --text-dim:      rgba(255,255,255,0.3);
    --radius:        14px;
    --radius-sm:     9px;
    --radius-lg:     20px;

    /* Premium */
    --premium:       #ffcc00;
    --purple:        #bf5af2;
}

/* ── Body & Background ────────────────────────────── */
body {
    font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--light);
    overflow-x: hidden;
    position: relative;
    padding-bottom: 85px;
    line-height: 1.5;
}

/* ── Background Animation ─────────────────────────── */
.bg-animation {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.beyblade-x {
    position: absolute;
    width: 55px;
    height: 55px;
    border: 2px solid var(--bbx-red);
    border-radius: 50%;
    opacity: 0.12;
    animation: spinX 7s linear infinite, floatX 12s ease-in-out infinite;
    will-change: transform;
}
.beyblade-x::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 26px; height: 26px;
    border: 1.5px solid var(--bbx-red);
    border-radius: 50%;
}
.beyblade-x::after {
    content: 'X';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 900;
    color: var(--bbx-red);
    text-shadow: 0 0 8px var(--bbx-red);
}
.beyblade-x:nth-child(3n)   { border-color: var(--bbx-blue);  opacity: 0.08; }
.beyblade-x:nth-child(3n)::before { border-color: var(--bbx-blue); }
.beyblade-x:nth-child(3n)::after  { color: var(--bbx-blue); text-shadow: 0 0 8px var(--bbx-blue); }
.beyblade-x:nth-child(5n)   { border-color: var(--bbx-gold); opacity: 0.07; }

@keyframes spinX {
    to { transform: rotate(360deg); }
}
@keyframes floatX {
    0%,100% { transform: rotate(0deg) translateY(0); }
    25%  { transform: rotate(90deg) translateY(-25px) translateX(15px); }
    50%  { transform: rotate(180deg) translateY(-15px) translateX(-15px); }
    75%  { transform: rotate(270deg) translateY(-35px) translateX(8px); }
}

.energy-line {
    position: absolute;
    width: 1px;
    height: 90px;
    background: linear-gradient(to bottom, transparent, var(--bbx-gold), transparent);
    opacity: 0.2;
    animation: energyPulse 2s ease-in-out infinite;
}
@keyframes energyPulse {
    0%,100% { opacity: 0.08; height: 70px; }
    50%     { opacity: 0.3;  height: 110px; }
}

/* ── Glitch Logo ──────────────────────────────────── */
.glitch-x {
    display: inline-block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--bbx-red);
    text-shadow: 0 0 12px var(--bbx-red), 0 0 24px rgba(255,45,85,0.4);
    animation: glitch 5s infinite;
    position: relative;
}
.glitch-x::before, .glitch-x::after {
    content: 'X';
    position: absolute;
    inset: 0;
}
.glitch-x::before {
    color: var(--bbx-red);
    animation: glitch-1 5s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}
.glitch-x::after {
    color: var(--bbx-red);
    animation: glitch-2 5s infinite linear alternate-reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}
@keyframes glitch {
    0%,93%,100% { transform: translate(0); }
    94% { transform: translate(-2px, 2px); }
    96% { transform: translate(2px, -2px); }
    98% { transform: translate(-2px, -2px); }
}
@keyframes glitch-1 {
    0%,93%,100% { transform: translate(0); opacity: 1; }
    95% { transform: translate(3px, 0); opacity: 0.8; }
    97% { transform: translate(-3px, 0); opacity: 0.8; }
}
@keyframes glitch-2 {
    0%,93%,100% { transform: translate(0); opacity: 1; }
    95% { transform: translate(-3px, 0); opacity: 0.8; }
    97% { transform: translate(3px, 0); opacity: 0.8; }
}

/* ── Header ───────────────────────────────────────── */
.main-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 68px;
    background: rgba(5, 5, 10, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 2px 20px rgba(0,0,0,0.6);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--light);
    letter-spacing: 1px;
}
.logo-text span { color: var(--bbx-gold); }

/* ── Desktop Nav ──────────────────────────────────── */
.desktop-nav {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.nav-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.75);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.nav-tab:hover {
    background: var(--glass);
    border-color: var(--bbx-red);
    color: var(--light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,45,85,0.2);
}
.nav-tab.active {
    background: linear-gradient(135deg, var(--bbx-red), #cc0020);
    border-color: var(--bbx-red);
    color: #fff;
    box-shadow: 0 4px 16px rgba(255,45,85,0.35);
}

/* ── User Section ─────────────────────────────────── */
.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.username-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--light);
    letter-spacing: 1px;
}
.role-badge {
    padding: 0.25rem 0.65rem;
    background: linear-gradient(135deg, rgba(0,255,65,0.15), rgba(0,255,65,0.05));
    border: 1px solid rgba(0,255,65,0.3);
    border-radius: 20px;
    font-size: 0.65rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.profile-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--light);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.profile-btn:hover {
    background: var(--glass-hover);
    border-color: var(--bbx-gold);
    color: var(--bbx-gold);
    transform: scale(1.08);
}

/* ── Mobile Nav ───────────────────────────────────── */
.mobile-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 70px;
    background: rgba(5, 5, 10, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.25rem;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.5);
}
.mobile-nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0.5rem 0.75rem;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    font-size: 0.6rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    min-width: 52px;
    text-align: center;
}
.mobile-nav-tab i { font-size: 1.2rem; }
.mobile-nav-tab.active {
    color: var(--bbx-red);
    background: rgba(255,45,85,0.08);
    text-shadow: 0 0 10px rgba(255,45,85,0.5);
}
.mobile-nav-tab:hover { color: rgba(255,255,255,0.8); }

/* ── Main Content ─────────────────────────────────── */
.main-content {
    margin-top: 88px;
    padding: 0 1rem 1.5rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Cards ────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border-bright), transparent);
    opacity: 0.6;
}
.card:hover { border-color: rgba(0,255,65,0.28); }

.card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--light);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: 0.5px;
}
.card-title i { color: var(--bbx-gold); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    background: linear-gradient(135deg, var(--bbx-red), #cc0020);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
}
.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,45,85,0.35); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-secondary {
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
}
.btn-secondary:hover { border-color: var(--bbx-blue); color: var(--bbx-blue); box-shadow: 0 4px 14px rgba(0,212,255,0.2); }

.btn-small {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 7px;
}
.btn-large {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
    border-radius: var(--radius-sm);
}
.btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    border-radius: 8px;
}
.btn:disabled, .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Form Elements ────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.45rem;
}
.form-group label i { margin-right: 0.3rem; color: var(--bbx-gold); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    color: var(--light);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--bbx-gold);
    box-shadow: 0 0 0 3px rgba(255,204,0,0.1);
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.25); }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff80' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* Checkbox style */
.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}
.checkbox-option:hover { border-color: var(--bbx-gold); background: rgba(255,204,0,0.04); }
.checkbox-option input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--bbx-gold);
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── Grid ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
@media (max-width: 600px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Stat Cards ───────────────────────────────────── */
.stat-card {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--glass-border-bright); }
.stat-card-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--bbx-gold);
    line-height: 1;
    margin-bottom: 0.3rem;
}
.stat-card-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* ── Modals ───────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(6px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.active { display: flex; }
.modal-content {
    background: linear-gradient(135deg, #0c0c14, #08080f);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,255,65,0.05);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}
.modal-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-header h3 i { color: var(--bbx-gold); }
.close-btn {
    width: 30px; height: 30px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}
.close-btn:hover { background: rgba(255,45,85,0.2); color: var(--bbx-red); border-color: var(--bbx-red); }

/* ── Tables ───────────────────────────────────────── */
.table-responsive { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: rgba(0,255,65,0.06);
    border-bottom: 1px solid var(--glass-border);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--bbx-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}
td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.85);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,255,65,0.03); }

/* ── Badges / Status ──────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-success { background: rgba(0,255,65,0.12); border: 1px solid rgba(0,255,65,0.3); color: var(--success); }
.badge-danger  { background: rgba(255,45,85,0.12); border: 1px solid rgba(255,45,85,0.3); color: var(--danger); }
.badge-warning { background: rgba(255,204,0,0.12); border: 1px solid rgba(255,204,0,0.3); color: var(--warning); }
.badge-info    { background: rgba(0,212,255,0.12); border: 1px solid rgba(0,212,255,0.3); color: var(--info); }
.badge-gold    { background: rgba(255,204,0,0.12); border: 1px solid rgba(255,204,0,0.3); color: var(--bbx-gold); }

.status-message { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; }
.status-message.success { background: rgba(0,255,65,0.1); border: 1px solid rgba(0,255,65,0.25); color: var(--success); }
.status-message.error   { background: rgba(255,45,85,0.1); border: 1px solid rgba(255,45,85,0.25); color: var(--danger); }
.status-message.info    { background: rgba(0,212,255,0.1); border: 1px solid rgba(0,212,255,0.25); color: var(--info); }

/* ── Tabs ─────────────────────────────────────────── */
.judge-tabs, .organizer-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.3);
    padding: 0.4rem;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    overflow-x: auto;
}
.judge-tab, .organizer-tab {
    flex: 1;
    padding: 0.7rem 1rem;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-weight: 700;
    font-size: 0.75rem;
    font-family: 'Rajdhani', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    text-align: center;
    min-width: max-content;
}
.judge-tab:hover, .organizer-tab:hover { color: var(--light); background: var(--glass); }
.judge-tab.active, .organizer-tab.active {
    background: linear-gradient(135deg, var(--bbx-red), #cc0020);
    color: #fff;
    box-shadow: 0 3px 12px rgba(255,45,85,0.35);
}
.judge-content, .organizer-content { display: none; }
.judge-content.active, .organizer-content.active { display: block; }

/* ── Scoring Interface ────────────────────────────── */
.finish-buttons-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.finish-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border: 2px solid;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    text-align: center;
    min-height: 70px;
}
.finish-btn i { font-size: 1.3rem; }
.finish-btn span { font-size: 0.75rem; line-height: 1.1; text-transform: uppercase; letter-spacing: 0.5px; }
.finish-btn small { font-size: 0.65rem; opacity: 0.7; }
.finish-btn:active { transform: scale(0.95); }

.finish-btn.spin    { border-color: var(--bbx-blue); color: var(--bbx-blue); }
.finish-btn.burst   { border-color: var(--bbx-red);  color: var(--bbx-red); }
.finish-btn.over    { border-color: var(--success);  color: var(--success); }
.finish-btn.extreme { border-color: var(--bbx-gold); color: var(--bbx-gold); }
.finish-btn.spin:hover    { background: rgba(0,212,255,0.12); box-shadow: 0 0 16px rgba(0,212,255,0.25); }
.finish-btn.burst:hover   { background: rgba(255,45,85,0.12);  box-shadow: 0 0 16px rgba(255,45,85,0.25); }
.finish-btn.over:hover    { background: rgba(0,255,65,0.12);  box-shadow: 0 0 16px rgba(0,255,65,0.25); }
.finish-btn.extreme:hover { background: rgba(255,204,0,0.12); box-shadow: 0 0 16px rgba(255,204,0,0.25); }

/* ── Coin Flip ────────────────────────────────────── */
.coin-flip-section { text-align: center; padding: 1.5rem 0; }
.coin-container { margin: 1.5rem auto; width: 100px; height: 100px; perspective: 600px; }
.coin-2d {
    width: 100px; height: 100px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
    position: relative;
    transition: all 0.3s;
}
.coin-2d.side-x {
    background: radial-gradient(circle, #330000, #1a0000);
    border: 3px solid var(--bbx-red);
    box-shadow: 0 0 20px rgba(255,45,85,0.5), inset 0 0 15px rgba(255,45,85,0.1);
}
.coin-2d.side-b {
    background: radial-gradient(circle, #001a33, #000d1a);
    border: 3px solid var(--bbx-blue);
    box-shadow: 0 0 20px rgba(0,212,255,0.5), inset 0 0 15px rgba(0,212,255,0.1);
}
.coin-letter {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
}
.coin-2d.side-x .coin-letter { color: var(--bbx-red); text-shadow: 0 0 15px var(--bbx-red); }
.coin-2d.side-b .coin-letter { color: var(--bbx-blue); text-shadow: 0 0 15px var(--bbx-blue); }
.coin-2d.flipping { animation: coinFlipAnim 2.5s ease-in-out forwards; }
@keyframes coinFlipAnim {
    0%   { transform: rotateY(0deg) scale(1); }
    50%  { transform: rotateY(900deg) scale(1.1); }
    100% { transform: rotateY(1800deg) scale(1); }
}

.side-selection { display: flex; gap: 1rem; justify-content: center; }
.side-btn {
    flex: 1; max-width: 140px;
    padding: 1rem;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    color: var(--light);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}
.side-btn:hover, .side-btn.selected { border-color: var(--bbx-gold); background: rgba(255,204,0,0.08); }

/* ── Score Display ────────────────────────────────── */
.scoring-section { padding: 1rem 0; }
.score-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.player-score-card {
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: border-color 0.2s;
}
.player-score-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.player-score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--bbx-gold);
    line-height: 1;
}
.player-finish-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

/* ── Winner Announcement ──────────────────────────── */
.winner-announcement {
    text-align: center;
    padding: 2rem 1rem;
}
.winner-announcement h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 1rem;
    color: var(--light);
    text-shadow: 0 0 20px rgba(255,204,0,0.3);
}
.winner-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--bbx-gold);
    text-shadow: 0 0 20px rgba(255,204,0,0.5);
    margin-bottom: 0.5rem;
}
.final-score {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 1.5rem;
}

/* ── Combo Slots ──────────────────────────────────── */
.combo-slots { display: flex; flex-direction: column; gap: 0.5rem; }
.combo-slot {
    background: rgba(0,0,0,0.3);
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex; align-items: center; gap: 0.75rem;
    transition: all 0.2s;
    min-height: 52px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.4);
}
.combo-slot:hover { border-color: var(--bbx-gold); color: var(--bbx-gold); background: rgba(255,204,0,0.04); }
.combo-slot.filled { border-style: solid; border-color: rgba(0,255,65,0.3); color: var(--light); background: rgba(0,255,65,0.04); }
.combo-slot-number {
    width: 24px; height: 24px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

/* ── Combo Entry ──────────────────────────────────── */
.combo-entry-section {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1rem;
    display: none;
}
.combo-entry-section.visible { display: block; }
.player-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 600px) { .player-inputs { grid-template-columns: 1fr; } }

/* ── Judge Tags ───────────────────────────────────── */
.judge-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: rgba(0,212,255,0.1);
    border: 1px solid rgba(0,212,255,0.25);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bbx-blue);
    margin: 0.2rem;
}
.judge-tag button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 0.7rem;
    opacity: 0.6;
    line-height: 1;
    min-height: unset;
}
.judge-tag button:hover { opacity: 1; color: var(--bbx-red); }

/* ── Search Results ───────────────────────────────── */
.search-results {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}
.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
    gap: 0.75rem;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--glass); }

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bbx-red), #7700cc);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ── Match Scoreboard ─────────────────────────────── */
.match-scoreboard {
    display: none;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,204,0,0.2);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.scoreboard-names {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
}
.scoreboard-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--bbx-gold);
    letter-spacing: 2px;
}

/* ── Error/Success Messages ───────────────────────── */
.error-msg   { color: var(--danger);  font-size: 0.88rem; margin-top: 0.5rem; min-height: 1.2rem; }
.success-msg { color: var(--success); font-size: 0.88rem; margin-top: 0.5rem; min-height: 1.2rem; }

/* ── Countdown ────────────────────────────────────── */
.countdown-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    text-align: center;
    color: var(--bbx-gold);
    text-shadow: 0 0 20px rgba(255,204,0,0.5);
    padding: 1rem;
}

/* ── Progress / Meter ─────────────────────────────── */
.progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--bbx-red), var(--bbx-gold));
    transition: width 0.4s ease;
}

/* ── Dividers ─────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--glass-border); margin: 1.5rem 0; }

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(0,255,65,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,255,65,0.35); }

/* ── Utility ──────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-gold   { color: var(--bbx-gold); }
.text-red    { color: var(--bbx-red); }
.text-blue   { color: var(--bbx-blue); }
.text-green  { color: var(--success); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.hidden { display: none !important; }
code {
    background: rgba(0,255,65,0.08);
    border: 1px solid rgba(0,255,65,0.15);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.85em;
    color: var(--bbx-gold);
    font-family: 'Courier New', monospace;
}

/* ── Floating Tools ───────────────────────────────── */
.floating-tools {
    position: fixed;
    bottom: 85px;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 900;
}
.float-btn {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bbx-red), #990010);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(255,45,85,0.4);
    transition: all 0.2s;
}
.float-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(255,45,85,0.55); }

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .desktop-nav { display: none; }
    .mobile-nav  { display: flex; }
    .main-content { margin-top: 80px; padding: 0 0.75rem 1.5rem; }
    .card { padding: 1.25rem; }
    .finish-buttons-row { grid-template-columns: repeat(2, 1fr); }
    .score-header-row { grid-template-columns: 1fr auto 1fr; gap: 0.5rem; }
    .player-score-value { font-size: 2.8rem; }
    .winner-name { font-size: 1.5rem; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    body { padding-bottom: 80px; }
    .main-header { padding: 0 0.75rem; }
    .logo-text { font-size: 1.1rem; }
    .card { padding: 1rem; border-radius: var(--radius-sm); }
    .card-title { font-size: 1rem; }
    .btn { padding: 0.6rem 1.1rem; font-size: 0.9rem; }
    .btn-large { padding: 0.8rem 1.5rem; font-size: 0.95rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .finish-buttons-row { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
    .finish-btn { min-height: 64px; padding: 0.6rem 0.3rem; }
    .player-score-value { font-size: 2.5rem; }
    .winner-name { font-size: 1.3rem; }
}

/* ══════════════════════════════════════════════════
   iOS / SAFARI FIXES
   ══════════════════════════════════════════════════ */

@supports (-webkit-touch-callout: none) {
    .main-header {
        background: rgba(5,5,10,0.97) !important;
        -webkit-backdrop-filter: blur(24px) !important;
        backdrop-filter: blur(24px) !important;
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 0 !important;
    }
    .mobile-nav {
        background: rgba(5,5,10,0.97) !important;
        -webkit-backdrop-filter: blur(24px) !important;
        backdrop-filter: blur(24px) !important;
        position: -webkit-sticky !important;
        position: sticky !important;
        bottom: 0 !important;
    }
    .modal-content {
        background: #0c0c14 !important;
        -webkit-backdrop-filter: blur(20px) !important;
        max-height: 88vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    button, .btn, [class*="btn"] {
        -webkit-appearance: none;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-height: 44px;
        cursor: pointer;
    }
    .profile-btn, .close-btn { min-height: unset !important; }
    input, select, textarea {
        -webkit-appearance: none;
        background-color: rgba(0,0,0,0.4) !important;
        color: #fff !important;
        font-size: max(16px, 1rem) !important;
        -webkit-box-shadow: none !important;
        box-shadow: none !important;
    }
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff80' d='M6 8L0 0h12z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 12px center !important;
        padding-right: 36px !important;
    }
    .fullscreen-camera-overlay {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        z-index: 9999 !important;
        background: #000 !important;
    }
    .fullscreen-camera-video {
        width: 100% !important; height: 100% !important;
        max-width: 100vw !important; max-height: 100dvh !important;
        object-fit: cover !important;
        background: #000 !important;
    }
    .fullscreen-camera-controls {
        position: absolute !important;
        bottom: 0 !important; left: 0 !important; right: 0 !important;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)) !important;
        background: linear-gradient(transparent, rgba(0,0,0,0.8)) !important;
        z-index: 10001 !important;
    }
    .record-btn {
        min-width: 70px !important; min-height: 70px !important;
        width: 70px !important; height: 70px !important;
        border-radius: 50% !important;
    }
    ::-webkit-scrollbar { display: none; }
    * { scrollbar-width: none; }
}

@media (max-width: 430px) and (-webkit-min-device-pixel-ratio: 2) {
    button, .btn, input, select, a.btn { min-height: 44px; }
    .profile-btn, .close-btn { min-height: unset !important; height: 30px !important; width: 30px !important; }
    .modal-content { width: 95vw !important; max-height: 85dvh !important; }
}

/* ══════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.1ms !important; }
    .beyblade-x, .energy-line, .glitch-x { animation: none !important; }
}

/* ── JS-injected mobile class (set by app-init.js) ── */
/* Overrides breakpoint-only detection for mobile browsers */
body.is-mobile .desktop-nav { display: none !important; }
body.is-mobile .mobile-nav  { display: flex !important; }
body.is-mobile .main-content {
    margin-top: 75px;
    padding: 0 0.75rem 1.5rem;
}
body.is-mobile .card { padding: 1rem; }
body.is-mobile .grid-2 { grid-template-columns: 1fr !important; }
body.is-mobile .grid-3 { grid-template-columns: repeat(2,1fr) !important; }
body.is-mobile .grid-4 { grid-template-columns: repeat(2,1fr) !important; }
body.is-mobile .finish-buttons-row { grid-template-columns: repeat(2,1fr) !important; }
body.is-mobile .player-inputs { grid-template-columns: 1fr !important; }
body.is-mobile .judge-tabs, body.is-mobile .organizer-tabs { flex-wrap: wrap; }
body.is-mobile .judge-tab, body.is-mobile .organizer-tab {
    flex: 1 1 calc(50% - 0.4rem);
    font-size: 0.7rem;
    padding: 0.6rem 0.4rem;
}
body.is-mobile .btn-large { width: 100%; justify-content: center; }
body.is-mobile .modal-content { width: 96vw !important; max-height: 88vh !important; }
body.is-mobile .player-score-value { font-size: 2.8rem; }
body.is-mobile .stat-card-value { font-size: 1.6rem; }
.tournament-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s, transform 0.2s;
}
.tournament-card:hover { border-color: var(--bbx-gold); transform: translateY(-2px); }
.tournament-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--light);
    margin-bottom: 0.4rem;
}
.tournament-meta {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    color: rgba(255,255,255,0.55);
    font-size: 0.82rem;
    margin-bottom: 0.85rem;
    align-items: center;
}
.tournament-meta span { display: flex; align-items: center; gap: 0.3rem; }
.t-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.t-badge.pending  { background: rgba(255,204,0,0.12);  border: 1px solid rgba(255,204,0,0.3);  color: var(--warning); }
.t-badge.active   { background: rgba(0,255,65,0.12);   border: 1px solid rgba(0,255,65,0.3);   color: var(--success); }
.t-badge.complete { background: rgba(128,128,128,0.12);border: 1px solid rgba(128,128,128,0.25);color: #999; }
.t-badge.format   { background: rgba(255,204,0,0.10);  border: 1px solid rgba(255,204,0,0.2);  color: var(--bbx-gold); }
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: rgba(255,255,255,0.35);
}
.empty-state i { font-size: 2.8rem; display: block; margin-bottom: 0.75rem; color: var(--bbx-gold); }
.empty-state h3 { font-family: 'Orbitron', sans-serif; font-size: 1rem; margin-bottom: 0.5rem; color: rgba(255,255,255,0.5); }
.empty-state p  { font-size: 0.85rem; }

/* ── Organizer Page ───────────────────────────────── */
.organizer-tabs { flex-wrap: wrap; }

/* ══════════════════════════════════════════════════
   PORTRAIT MOBILE OPTIMIZATIONS
   Force optimal layout when on a mobile device
   in portrait orientation
   ══════════════════════════════════════════════════ */

/* Detect mobile portrait — primary target layout */
@media (max-width: 768px) and (orientation: portrait) {
    body { padding-bottom: 80px; }

    .main-content {
        margin-top: 75px;
        padding: 0 0.75rem 1.5rem;
    }

    /* Stack all grids to single column in portrait */
    .grid-2, .grid-3, .grid-4,
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }

    /* Finish buttons — 2 per row in portrait */
    .finish-buttons-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }

    /* Score header — keep side by side but tighter */
    .score-header-row {
        gap: 0.4rem;
    }
    .player-score-value { font-size: 2.8rem; }

    /* Cards — full width, tighter padding */
    .card { padding: 1rem; }
    .card-title { font-size: 1rem; }

    /* Tabs — allow wrapping in portrait */
    .judge-tabs, .organizer-tabs {
        flex-wrap: wrap;
        gap: 0.35rem;
    }
    .judge-tab, .organizer-tab {
        flex: 1 1 calc(50% - 0.35rem);
        min-width: 0;
        font-size: 0.7rem;
        padding: 0.6rem 0.5rem;
    }

    /* Buttons — full width in portrait where appropriate */
    .video-review-actions .btn { width: 100%; }
    .btn-large { padding: 0.8rem 1.2rem; font-size: 0.95rem; }

    /* Video review — taller in portrait */
    #reviewVideo {
        max-height: 45vh !important;
        width: 100% !important;
    }

    /* Coin flip — scale down for portrait */
    .coin-container { width: 80px; height: 80px; }
    .coin-2d { width: 80px; height: 80px; }
    .coin-letter { font-size: 2rem; }

    /* Side selection — stack vertically */
    .side-selection { flex-direction: column; align-items: center; }
    .side-btn { max-width: 100%; width: 100%; }

    /* Player inputs — always single column */
    .player-inputs { grid-template-columns: 1fr !important; }

    /* Modal — near full screen in portrait */
    .modal-content {
        width: 96vw !important;
        max-height: 88vh !important;
        margin: 0 auto;
    }

    /* Search results — constrain height */
    .search-results { max-height: 200px; }

    /* Stat cards — 2 per row */
    .stats-grid, [class*="stats-grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tournament cards — full width */
    .tournament-card { margin-bottom: 0.6rem; }
    .tournament-meta { gap: 0.5rem; font-size: 0.78rem; }
}

/* Landscape on mobile — warn user to rotate */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
    .portrait-only-warning {
        display: flex !important;
    }
}

.portrait-only-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
}
.portrait-only-warning i {
    font-size: 3rem;
    color: var(--bbx-gold);
    animation: rotateHint 2s ease-in-out infinite;
}
.portrait-only-warning p {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    letter-spacing: 1px;
    max-width: 280px;
}
@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    30%       { transform: rotate(-90deg); }
    70%       { transform: rotate(-90deg); }
}
