/* Blader Network - Main Styles */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Smooth scrolling and performance */
html { scroll-behavior: smooth; }
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Touch optimization for mobile */
* { touch-action: manipulation; }
button, a, input, select, textarea { touch-action: manipulation; -webkit-touch-callout: none; }

/* Prevent text selection on interactive elements */
button, .btn, .nav-tab, .mobile-nav-tab { 
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
}

:root {
    --primary: #00ff41;
    --secondary: #00ff88;
    --accent: #ffffff;
    --dark: #000000;
    --light: #ffffff;
    --success: #00ff41;
    --danger: #ff0000;
    --warning: #ffff00;
    --info: #00ffff;
    --glass: rgba(0,255,65,0.08);
    --glass-border: rgba(0,255,65,0.2);
    --purple: #bf5af2;
    --premium: #ffd700;
    --bbx-red: #ff0000;
    --bbx-blue: #00ffff;
    --bbx-gold: #ffff00;
    --bbx-dark: #000000;
    --electric-green: #00ff41;
    --electric-cyan: #00ffff;
    
    /* iPhone Safari fixes - explicit color definitions */
    --safari-red: #ff0000;
    --safari-blue: #00d4ff;
    --safari-gold: #ffd700;
    --safari-green: #00ff41;
}

body { 
    font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif; 
    background: linear-gradient(135deg, #000000 0%, #0a0a0a 50%, #000000 100%); 
    min-height: 100vh; 
    color: var(--light); 
    overflow-x: hidden;
    position: relative;
    padding-bottom: 80px;
}

/* Beyblade X Background Animation */
.bg-animation { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: -1; 
    overflow: hidden; 
}

.beyblade-x { 
    position: absolute; 
    width: 60px; 
    height: 60px; 
    border: 3px solid var(--bbx-red);
    border-radius: 50%; 
    opacity: 0.15;
    animation: spinX 6s linear infinite, floatX 10s ease-in-out infinite;
    will-change: transform;
}

.beyblade-x::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30px; height: 30px;
    border: 2px 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: 14px;
    font-weight: 900;
    color: var(--bbx-red);
    text-shadow: 0 0 10px var(--bbx-red), 0 0 20px var(--bbx-red);
}

.beyblade-x:nth-child(odd) { border-color: var(--bbx-red); }
.beyblade-x:nth-child(even) { border-color: var(--bbx-red); }

@keyframes spinX { 
    from { transform: rotate(0deg); } 
    to { transform: rotate(360deg); } 
}

@keyframes floatX { 
    0%,100% { transform: translateY(0) translateX(0); } 
    25% { transform: translateY(-30px) translateX(20px); } 
    50% { transform: translateY(-20px) translateX(-20px); } 
    75% { transform: translateY(-40px) translateX(10px); } 
}

/* Energy Lines */
.energy-line {
    position: absolute;
    width: 2px;
    height: 100px;
    background: linear-gradient(to bottom, transparent, var(--bbx-gold), transparent);
    opacity: 0.3;
    animation: energyPulse 1s ease-in-out infinite;
    will-change: opacity, height;
}

@keyframes energyPulse { 
    0%,100% { opacity: 0.1; height: 80px; } 
    50% { opacity: 0.4; height: 120px; } 
}

/* Glitching X Logo - ALL RED */
.glitch-x {
    display: inline-block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: #ff0000;
    text-shadow: 
        0 0 10px #ff0000, 
        0 0 20px #ff0000,
        0 0 30px #ff0000,
        2px 0 #ff0000, 
        -2px 0 #ff0000;
    animation: glitch 4s infinite;
    position: relative;
}

.glitch-x::before,
.glitch-x::after {
    content: 'X';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-x::before {
    color: #ff0000;
    text-shadow: 0 0 10px #ff0000;
    animation: glitch-1 4s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch-x::after {
    color: #ff0000;
    text-shadow: 0 0 10px #ff0000;
    animation: glitch-2 4s infinite linear alternate-reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch {
    0%, 95%, 100% { transform: translate(0); }
    96% { transform: translate(-2px, 2px); }
    97% { transform: translate(-2px, -2px); }
    98% { transform: translate(2px, 2px); }
    99% { transform: translate(2px, -2px); }
}

@keyframes glitch-1 {
    0%, 95%, 100% { transform: translate(0); }
    96% { transform: translate(3px, 0); }
    97% { transform: translate(-3px, 0); }
    98% { transform: translate(3px, 0); }
    99% { transform: translate(-3px, 0); }
}

@keyframes glitch-2 {
    0%, 95%, 100% { transform: translate(0); }
    96% { transform: translate(-3px, 0); }
    97% { transform: translate(3px, 0); }
    98% { transform: translate(-3px, 0); }
    99% { transform: translate(3px, 0); }
}

/* Header Navigation */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 2px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--light);
    text-shadow: 0 0 20px rgba(255,45,85,0.5);
}

.logo-text span {
    color: var(--bbx-gold);
}

/* Desktop Navigation */
.desktop-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-tab {
    padding: 0.6rem 1.2rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    color: var(--light);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.nav-tab:hover {
    background: var(--glass);
    border-color: var(--bbx-red);
    transform: translateY(-2px);
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--bbx-red), #cc0022);
    border-color: var(--bbx-red);
    box-shadow: 0 4px 15px rgba(255,45,85,0.4);
}

/* User Section */
.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
    white-space: nowrap;
}

.role-badge {
    padding: 0.4rem 0.8rem;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #0088cc);
    border: 2px solid var(--glass-border);
    color: black;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.profile-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--primary);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(10, 10, 26, 0.98);
    backdrop-filter: blur(20px);
    border-top: 2px solid var(--glass-border);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0.5rem;
}

.mobile-nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.6);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.mobile-nav-tab i {
    font-size: 1.3rem;
}

.mobile-nav-tab.active {
    color: var(--bbx-red);
}

.mobile-nav-tab.active i {
    text-shadow: 0 0 10px rgba(255,45,85,0.5);
}

/* Main Content */
.main-content {
    margin-top: 70px;
    padding: 1.5rem 2rem;
    min-height: calc(100vh - 70px);
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

/* Cards */
.card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--bbx-red), var(--bbx-gold), var(--bbx-blue));
}

.card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    color: var(--bbx-gold);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.8rem;
    background: linear-gradient(135deg, var(--bbx-red), #cc0022);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    text-decoration: none;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 20px rgba(255,45,85,0.3);
    min-height: 48px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px rgba(255,45,85,0.5);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.05s;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--bbx-blue), #0088cc);
    box-shadow: 0 4px 20px rgba(0,168,232,0.3);
}

.btn-secondary:hover {
    box-shadow: 0 8px 30px rgba(0,168,232,0.5);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00cc6a);
    box-shadow: 0 4px 20px rgba(0,255,136,0.3);
}

.btn-success:hover {
    box-shadow: 0 8px 30px rgba(0,255,136,0.5);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #cc7700);
    box-shadow: 0 4px 20px rgba(255,149,0,0.3);
}

.btn-gold {
    background: linear-gradient(135deg, var(--bbx-gold), #cc9400);
    color: var(--dark);
    box-shadow: 0 4px 20px rgba(255,184,0,0.3);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 1.2rem 2rem;
    font-size: 1.1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--bbx-gold);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--light);
    font-size: 0.95rem;
    transition: all 0.3s;
    font-family: 'Rajdhani', sans-serif;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--bbx-red);
    box-shadow: 0 0 15px rgba(255,45,85,0.2);
}

select option {
    background: #1a0a2e;
    color: var(--light);
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Floating Tools */
.floating-tools {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 999;
    transition: all 0.3s;
}

.floating-tools.scrolled {
    position: fixed;
    right: 20px;
    top: auto;
    bottom: 100px;
    transform: none;
}

.tool-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    color: var(--light);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--bbx-red);
    border-color: var(--bbx-red);
    transform: scale(1.1);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, #1a0a2e, #0a0a1a);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--bbx-red), var(--bbx-gold));
    border-radius: 20px 20px 0 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    color: var(--bbx-gold);
    font-family: 'Orbitron', sans-serif;
}

.close-btn {
    background: none;
    border: none;
    color: var(--light);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.close-btn:hover {
    color: var(--bbx-red);
    transform: rotate(90deg);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    color: var(--bbx-gold);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

tr:hover {
    background: var(--glass);
}

/* Status Badges */
.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pending { background: rgba(255,149,0,0.2); color: var(--warning); }
.status-active { background: rgba(0,255,136,0.2); color: var(--success); }
.status-ended { background: rgba(255,59,48,0.2); color: var(--danger); }
.status-upcoming { background: rgba(0,212,255,0.2); color: var(--info); }

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    font-size: 3rem;
    font-family: 'Orbitron', sans-serif;
}

.score-player {
    text-align: center;
}

.score-name {
    font-size: 1rem;
    color: var(--bbx-gold);
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 900;
    color: var(--light);
    text-shadow: 0 0 20px rgba(255,255,255,0.3);
}

.score-divider {
    color: var(--bbx-red);
    font-size: 2rem;
}

/* Coin Flip Animation */
.coin-container {
    width: 150px;
    height: 150px;
    margin: 2rem auto;
    position: relative;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: coinFlip 2s ease-in-out;
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    border: 4px solid var(--bbx-gold);
}

.coin-front {
    background: linear-gradient(135deg, var(--bbx-red), #cc0022);
    color: white;
}

.coin-back {
    background: linear-gradient(135deg, var(--bbx-blue), #0088cc);
    color: white;
    transform: rotateY(180deg);
}

@keyframes coinFlip {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(1800deg); }
}

/* Side Selection */
.side-selection {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 2rem 0;
}

.side-btn {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    background: var(--glass);
    border: 3px solid var(--glass-border);
    color: var(--light);
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.side-btn:hover {
    border-color: var(--bbx-gold);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255,184,0,0.3);
}

.side-btn.selected {
    background: linear-gradient(135deg, var(--bbx-gold), #cc9400);
    border-color: var(--bbx-gold);
    color: var(--dark);
}

.side-label {
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Combo Display */
.combo-display {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.combo-part {
    width: 100px;
    height: 100px;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.combo-part:hover {
    border-color: var(--bbx-red);
    transform: translateY(-5px);
}

.part-name {
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    padding: 0 0.5rem;
}

.part-type {
    font-size: 0.65rem;
    color: var(--bbx-gold);
    text-transform: uppercase;
}

/* Stats Display */
.stats-bar {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0;
}

.stat-item {
    text-align: center;
    padding: 0.5rem 1rem;
    background: var(--glass);
    border-radius: 10px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--bbx-gold);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--glass-border);
    padding-bottom: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.admin-tabs::-webkit-scrollbar {
    height: 4px;
}

.admin-tabs::-webkit-scrollbar-thumb {
    background: var(--bbx-blue);
    border-radius: 2px;
}

.admin-tab {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--light);
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    white-space: nowrap;
    flex-shrink: 0;
}

.admin-tab:hover {
    background: var(--glass);
}

.admin-tab.active {
    background: linear-gradient(135deg, var(--bbx-red), #ff1a1a);
    color: white;
}

.admin-content {
    display: none;
}

.admin-content.active {
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    .desktop-nav {
        display: none;
    }
    
    .mobile-nav {
        display: flex;
    }
    
    .main-content {
        margin-top: 46px;
        padding: 1.25rem 1.5rem;
        padding-bottom: 60px;
        max-width: 900px;
    }
    
    .floating-tools {
        display: none;
    }
    
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    /* ── Header: compact ── */
    .main-header { padding: 0 0.5rem; height: 46px; }
    .logo-section { gap: 0.2rem; }
    .logo-text { font-size: 0.8rem; }
    .glitch-x { font-size: 0.95rem; }
    .username-display { display: none; }
    .role-badge { font-size: 0.5rem; padding: 0.1rem 0.35rem; }
    .user-section { gap: 0.35rem; }
    .profile-btn { width: 30px; height: 30px; min-height: 30px !important; font-size: 0.9rem; padding: 0 !important; border-radius: 50% !important; flex-shrink: 0; }

    /* ── Bottom nav: icon-only, thin ── */
    .mobile-nav { height: 52px; padding: 0.15rem 0; }
    .mobile-nav-tab { font-size: 0.6rem; gap: 0.1rem; padding: 0.25rem 0.2rem; }
    .mobile-nav-tab i { font-size: 1.15rem; }
    .mobile-nav-tab span { font-size: 0.55rem; }

    /* ── Layout ── */
    body { padding-bottom: 56px; }
    .main-content { padding: 0.75rem 1rem; margin-top: 46px; min-height: calc(100vh - 46px); width: 100%; max-width: 100%; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* ── Cards: tight ── */
    .card { padding: 0.65rem; margin-bottom: 0.5rem; margin-left: 0; margin-right: 0; width: 100%; max-width: 100%; border-radius: 12px; }
    .card-title { font-size: 1rem; margin-bottom: 0.5rem; }

    /* ── Forms: compact ── */
    .form-group { margin-bottom: 0.5rem; }
    .form-group label { font-size: 0.8rem; margin-bottom: 0.2rem; }
    input, select, textarea { padding: 0.55rem 0.7rem; font-size: 16px; min-height: 42px; }

    /* ── Buttons: 44px touch target ── */
    .btn { padding: 0.6rem 0.9rem; font-size: 0.85rem; min-height: 44px; }
    .btn-large { padding: 0.7rem 1.2rem; font-size: 0.95rem; }
    .btn-small { padding: 0.4rem 0.7rem; font-size: 0.75rem; min-height: 36px; }

    /* ── Stats ── */
    .stat-value { font-size: 1.2rem; }

    /* ── Score display ── */
    .score-display { flex-direction: row; gap: 0.4rem; }
    .side-selection { flex-direction: column; align-items: center; }

    /* ── Player score cards ── */
    .player-score-card { padding: 0.6rem; min-width: 0; min-height: 70px; }
    .player-score-name { font-size: 0.8rem; }
    .player-score-value { font-size: 2.2rem; }
    .set-score { font-size: 0.75rem; }

    /* ── Point/finish buttons ── */
    .point-buttons-container { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .point-btn { padding: 0.6rem 0.4rem; font-size: 0.85rem; min-height: 56px; border-radius: 10px; }
    .point-btn span:first-child { font-size: 0.8rem; }
    .point-value { font-size: 0.9rem; }

    /* ── Combo ── */
    .combo-visual { flex-direction: column; gap: 0.4rem; }
    .combo-part-visual { padding: 0.6rem; }

    /* ── Part selector ── */
    .part-selector { grid-template-columns: 1fr; }

    /* ── Camera ── */
    .camera-container { max-width: 100%; }

    /* ── Modals: compact ── */
    .modal-content { max-width: 100%; width: 100%; margin: 0; max-height: 95vh; border-radius: 14px; padding: 0.75rem; }
    .modal-header { padding: 0.6rem 0.75rem; }
    .modal-header h3 { font-size: 1rem; }

    /* ── Tables ── */
    .data-table { font-size: 0.75rem; }
    .data-table th, .data-table td { padding: 0.4rem; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bbx-red);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bbx-gold);
}

/* Tournament Bracket */
.bracket {
    display: flex;
    gap: 2rem;
    overflow-x: auto;
    padding: 1rem;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 200px;
}

.bracket-match {
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem;
}

.bracket-player {
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.85rem;
}

.bracket-player.winner {
    background: rgba(0,255,136,0.2);
    color: var(--success);
}

/* Deck Lock Display */
.deck-lock-display {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.deck-combo {
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    padding: 1rem;
    text-align: center;
}

.deck-combo.locked {
    border-color: var(--success);
    box-shadow: 0 0 15px rgba(0,212,255,0.3);
}

/* Payment Methods */
.payment-methods {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.payment-method {
    width: 80px;
    height: 80px;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.payment-method:hover {
    border-color: var(--bbx-gold);
    transform: scale(1.05);
}

.payment-method.selected {
    background: linear-gradient(135deg, var(--bbx-gold), #cc9400);
    border-color: var(--bbx-gold);
    color: var(--dark);
}

/* Video Player */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 15px;
    background: #000;
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.premium-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.premium-overlay i {
    font-size: 3rem;
    color: var(--premium);
}

/* Notification */
.notification {
    position: fixed;
    top: 90px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    z-index: 3000;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification.success { border-color: var(--success); }
.notification.error { border-color: var(--danger); }
.notification.warning { border-color: var(--warning); }

/* Recaptcha container */
.g-recaptcha {
    margin: 1rem 0;
}

/* Image upload */
.image-upload {
    border: 2px dashed var(--glass-border);
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.image-upload:hover {
    border-color: var(--bbx-red);
    background: var(--glass);
}

.image-upload img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
}

/* ============================================
   IPHONE / SAFARI SPECIFIC FIXES
   ============================================ */

/* Force dark mode on iPhone Safari */
@supports (-webkit-touch-callout: none) {
    /* CSS specific to iOS devices */
    body {
        background: #000000 !important;
        background-color: #000000 !important;
        -webkit-text-size-adjust: 100%;
    }
    
    /* Fix for iPhone Safari color rendering */
    .glitch-x {
        color: #ff0000 !important;
        text-shadow: 
            0 0 10px #ff0000, 
            0 0 20px #ff0000,
            0 0 30px #ff0000 !important;
    }
    
    /* Fix button colors on iPhone */
    .btn {
        -webkit-appearance: none;
        appearance: none;
        background: linear-gradient(135deg, #ff0000, #cc0022) !important;
    }
    
    .btn-secondary {
        background: linear-gradient(135deg, #00d4ff, #0088cc) !important;
    }
    
    .btn-success {
        background: linear-gradient(135deg, #00ff41, #00cc6a) !important;
    }
    
    .btn-gold {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000000 !important;
    }
    
    /* Fix form elements on iPhone */
    input, select, textarea {
        -webkit-appearance: none;
        appearance: none;
        background-color: rgba(0,0,0,0.3) !important;
        color: #ffffff !important;
        border-radius: 10px;
    }
    
    /* Fix select dropdown on iPhone */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 35px;
    }
    
    /* Fix card backgrounds on iPhone */
    .card {
        background: rgba(0,255,65,0.08) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }
    
    /* Fix header on iPhone */
    .main-header {
        background: rgba(10, 10, 26, 0.98) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }
    
    /* Fix mobile nav on iPhone */
    .mobile-nav {
        background: rgba(10, 10, 26, 0.98) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    /* Fix modal on iPhone */
    .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix stat cards on iPhone */
    .stat-card {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix combo parts on iPhone */
    .combo-part {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix point buttons on iPhone */
    .point-btn {
        -webkit-appearance: none;
        appearance: none;
    }
    
    .point-btn.spin {
        background: linear-gradient(135deg, #00d4ff, #0088cc) !important;
    }
    
    .point-btn.burst {
        background: linear-gradient(135deg, #ff0000, #cc0044) !important;
    }
    
    .point-btn.over {
        background: linear-gradient(135deg, #00ff41, #00aa44) !important;
    }
    
    .point-btn.extreme {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000000 !important;
    }
    
    /* Fix player score cards on iPhone */
    .player-score-card {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix combo slots on iPhone */
    .combo-slot {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .combo-slot.filled {
        background: rgba(0,255,65,0.05) !important;
    }
    
    /* Fix tool buttons on iPhone */
    .tool-btn {
        background: rgba(0,255,65,0.08) !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Fix tournament cards on iPhone */
    .tournament-card {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix phase sections on iPhone */
    .phase-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix config sections on iPhone */
    .config-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix payment methods on iPhone */
    .payment-method {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix deck slots on iPhone */
    .deck-slot {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix combo cards on iPhone */
    .combo-card {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix part groups on iPhone */
    .part-group {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix combo preview on iPhone */
    .combo-preview {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix stat boxes on iPhone */
    .stat-box {
        background: rgba(0,0,0,0.3) !important;
    }
    
    /* Fix camera section on iPhone */
    .camera-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix video preview section on iPhone */
    .video-preview-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix recording items on iPhone */
    .recording-item {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix match items on iPhone */
    .match-item {
        background: rgba(0,0,0,0.2) !important;
    }
    
    /* Fix set history on iPhone */
    .set-history {
        background: rgba(0,0,0,0.3) !important;
    }
    
    /* Fix winner announcement on iPhone */
    .winner-announcement {
        background: linear-gradient(135deg, rgba(255,184,0,0.2), rgba(255,45,85,0.2)) !important;
    }
    
    /* Fix coin flip section on iPhone */
    .coin-flip-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix coin on iPhone */
    .coin-2d.side-x {
        background: linear-gradient(135deg, #ffd700, #ffaa00, #cc8800) !important;
    }
    .coin-2d.side-b {
        background: linear-gradient(135deg, #cc8800, #ffaa00, #ffd700) !important;
    }
    
    /* Fix side buttons on iPhone */
    .side-btn {
        background: rgba(0,255,65,0.08) !important;
    }
    
    .side-btn.selected {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000000 !important;
    }
    
    /* Fix player input groups on iPhone */
    .player-input-group {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix setting groups on iPhone */
    .setting-group {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix checkbox options on iPhone */
    .checkbox-option {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix combo entry section on iPhone */
    .combo-entry-section {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix tools sidebar on iPhone */
    .tools-sidebar {
        background: transparent !important;
    }
    
    /* Fix tool content on iPhone */
    .tool-content {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix player items on iPhone */
    .player-item {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix transaction items on iPhone */
    .transaction-item {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix payment method items on iPhone */
    .payment-method-item {
        background: rgba(0,0,0,0.2) !important;
    }
    
    /* Fix premium features on iPhone */
    .premium-feature {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix deck combos on iPhone */
    .deck-combo {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix bracket match on iPhone */
    .bracket-match {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix notification on iPhone */
    .notification {
        background: rgba(0,255,65,0.08) !important;
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    /* Fix API key display on iPhone */
    .api-key-display {
        background: rgba(0,0,0,0.3) !important;
    }
    
    /* Fix image upload on iPhone */
    .image-upload {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix danger zone on iPhone */
    .danger-zone {
        background: rgba(255,59,48,0.05) !important;
    }
    
    /* Fix approval notice on iPhone */
    .approval-notice {
        background: rgba(255,149,0,0.1) !important;
    }
    
    /* Fix guest notice on iPhone */
    .guest-notice {
        background: rgba(255,184,0,0.1) !important;
    }
    
    /* Fix video required notice on iPhone */
    #videoRequiredNotice {
        background: rgba(255,149,0,0.1) !important;
    }
    
    /* Fix video submitted notice on iPhone */
    #videoSubmittedNotice {
        background: rgba(0,255,65,0.1) !important;
    }
    
    /* Fix login box on iPhone */
    .login-box {
        background: rgba(0,255,65,0.08) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }
    
    /* Fix X logo on iPhone */
    .x-logo {
        background: linear-gradient(135deg, #ff0000, #00d4ff) !important;
    }
    
    /* Fix tab switcher on iPhone */
    .tab-switcher {
        background: rgba(0,0,0,0.3) !important;
    }
    
    /* Fix tab buttons on iPhone */
    .tab-btn {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .tab-btn.active {
        background: linear-gradient(135deg, #ff0000, #ff1a1a) !important;
    }
    
    /* Fix org tabs on iPhone */
    .org-tabs {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .org-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .org-tab.active {
        background: linear-gradient(135deg, #ff0000, #ff1a1a) !important;
    }
    
    /* Fix judge tabs on iPhone */
    .judge-tabs {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .judge-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .judge-tab.active {
        background: linear-gradient(135deg, #ff0000, #ff1a1a) !important;
    }
    
    /* Fix play tabs on iPhone */
    .play-tabs {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .play-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .play-tab.active {
        background: linear-gradient(135deg, #ff0000, #ff1a1a) !important;
    }
    
    /* Fix combo type tabs on iPhone */
    .combo-type-tabs {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .combo-type-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .combo-type-tab.active {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000000 !important;
    }
    
    /* Fix admin tabs on iPhone */
    .admin-tabs {
        background: rgba(0,0,0,0.3) !important;
    }
    
    .admin-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .admin-tab.active {
        background: linear-gradient(135deg, #ff0000, #ff1a1a) !important;
    }
    
    /* Fix nav tabs on iPhone */
    .nav-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .nav-tab.active {
        background: linear-gradient(135deg, #ff0000, #cc0022) !important;
    }
    
    /* Fix mobile nav tabs on iPhone */
    .mobile-nav-tab {
        -webkit-appearance: none;
        appearance: none;
        background: transparent !important;
    }
    
    .mobile-nav-tab.active {
        color: #ff0000 !important;
    }
    
    /* Fix floating tools on iPhone */
    #floatingJudgeTools {
        background: rgba(0,255,65,0.08) !important;
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    /* Fix floating tools toggle on iPhone */
    #floatingToolsToggle {
        background: linear-gradient(135deg, #ff0000, #cc0022) !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Fix countdown overlay on iPhone */
    .countdown-overlay {
        background: rgba(0,0,0,0.95) !important;
    }
    
    /* Fix set editor overlay on iPhone */
    .set-editor-overlay {
        background: rgba(0,0,0,0.9) !important;
    }
    
    .set-editor-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix combo selector modal on iPhone */
    #comboSelectorModal .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix profile modal on iPhone */
    #profileModal .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix tournament modal on iPhone */
    #tournamentModal .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix forgot password modal on iPhone */
    #forgotPasswordModal .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix combo modal on iPhone */
    #comboModal .modal-content {
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
    }
    
    /* Fix record button on iPhone */
    .record-btn {
        -webkit-appearance: none;
        appearance: none;
        background: #ff0000 !important;
    }
    
    .record-btn.recording {
        background: #333333 !important;
    }
    
    /* Fix download button on iPhone */
    .download-btn {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Fix close button on iPhone */
    .close-btn {
        -webkit-appearance: none;
        appearance: none;
        background: none !important;
    }
    
    /* Fix password toggle on iPhone */
    .password-toggle {
        -webkit-appearance: none;
        appearance: none;
        background: none !important;
    }
    
    /* Fix profile button on iPhone */
    .profile-btn {
        background: linear-gradient(135deg, #00ff41, #0088cc) !important;
        -webkit-appearance: none;
        appearance: none;
        width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
        border-radius: 50% !important;
    }
    
    /* Fix role badge on iPhone */
    .role-badge {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix stat item on iPhone */
    .stat-item {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix status badges on iPhone */
    .status-badge {
        background: rgba(0,255,65,0.08) !important;
    }
    
    .status-pending {
        background: rgba(255,149,0,0.2) !important;
    }
    
    .status-active {
        background: rgba(0,255,65,0.2) !important;
    }
    
    .status-ended {
        background: rgba(255,59,48,0.2) !important;
    }
    
    .status-upcoming {
        background: rgba(0,212,255,0.2) !important;
    }
    
    /* Fix combo type badges on iPhone */
    .combo-type-badge.standard {
        background: linear-gradient(135deg, #00d4ff, #0088cc) !important;
    }
    
    .combo-type-badge.cx {
        background: linear-gradient(135deg, #ff0000, #cc0044) !important;
    }
    
    .combo-type-badge.cxe {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000000 !important;
    }
    
    /* Fix tournament status badges on iPhone */
    .tournament-status-badge.registered {
        background: #00ff41 !important;
        color: #000000 !important;
    }
    
    .tournament-status-badge.waitlist {
        background: #ffd700 !important;
        color: #000000 !important;
    }
    
    .tournament-status-badge.judging {
        background: #00d4ff !important;
        color: #ffffff !important;
    }
    
    /* Fix tournament type badge on iPhone */
    .tournament-type-badge {
        background: rgba(255,184,0,0.2) !important;
    }
    
    /* Fix ELO badge on iPhone */
    .elo-badge {
        background: rgba(0,255,65,0.08) !important;
    }
    
    /* Fix player ELO display on iPhone */
    .player-elo-display {
        color: #ffd700 !important;
    }
    
    /* Fix scroll behavior on iPhone */
    .table-container {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix animation performance on iPhone */
    .beyblade-x {
        will-change: transform;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Fix energy lines on iPhone */
    .energy-line {
        will-change: opacity, height;
    }
    
    /* Fix coin animation on iPhone */
    .coin-2d {
        will-change: transform;
    }
    
    /* Fix smooth scrolling on iPhone */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix touch action on iPhone */
    body {
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection in inputs on iPhone */
    input, textarea, select {
        -webkit-user-select: auto;
        user-select: auto;
    }
    
    /* Fix font rendering on iPhone */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Fix viewport height on iPhone with notches */
    .main-header {
        padding-top: env(safe-area-inset-top, 0);
    }
    
    .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
    }
    
    /* Fix bottom nav on iPhone with home indicator */
    .mobile-nav {
        height: calc(70px + env(safe-area-inset-bottom, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* Additional iPhone SE / small screen fixes */
@media only screen and (max-width: 375px) and (-webkit-device-pixel-ratio: 2) {
    .logo-text {
        font-size: 0.8rem !important;
    }
    
    .glitch-x {
        font-size: 1rem !important;
    }
    
    .card {
        padding: 0.75rem !important;
    }
    
    .card-title {
        font-size: 1rem !important;
    }
    
    .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    .player-score-value {
        font-size: 1.5rem !important;
    }
    
    .point-btn {
        padding: 0.4rem 0.1rem !important;
        font-size: 0.6rem !important;
        min-height: 40px !important;
    }
}

/* iPhone 12/13/14 Pro Max specific fixes */
@media only screen and (min-width: 428px) and (-webkit-device-pixel-ratio: 3) {
    .mobile-nav {
        height: calc(80px + env(safe-area-inset-bottom, 0));
    }
    
    .main-content {
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0));
    }
}

/* iPad specific fixes */
@media only screen and (min-width: 768px) and (max-width: 1024px) {
    .mobile-nav {
        display: none !important;
    }
    
    .desktop-nav {
        display: flex !important;
    }
    
    .main-content {
        padding-bottom: 1.5rem;
    }
}

/* ============================================================
   ANDROID CHROME / CHROMIUM BROWSER FIXES
   ============================================================ */

/* Android viewport — use dvh to account for URL bar */
@supports (height: 100dvh) {
    body {
        min-height: 100dvh;
    }
    
    .fullscreen-camera-overlay {
        height: 100dvh !important;
    }
    
    .countdown-overlay {
        height: 100dvh !important;
    }
}

/* Android Chromium - general fixes */
@media screen and (hover: none) and (pointer: coarse) {
    /* Fix touch targets for Android Chrome */
    .btn, .nav-tab, .mobile-nav-tab, button {
        min-height: 44px;
    }
    /* Circle buttons must stay circular on Android too */
    .profile-btn,
    .match-scoreboard-edit,
    .close-btn {
        min-height: unset !important;
        height: 30px !important;
        width: 30px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        flex-shrink: 0 !important;
    }
    /* Except on larger screens where profile-btn is 40px */
    @media (min-width: 769px) {
        .profile-btn {
            height: 40px !important;
            width: 40px !important;
        }
    }

    /* Better scrolling on Android */
    .table-container,
    .combo-selector-grid,
    .existing-parts-grid {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    /* Fix Android Chrome input zoom prevention */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Fix Android camera overlay — full screen accounting for URL bar */
    .fullscreen-camera-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        height: 100dvh;
        width: 100%;
        width: 100dvw;
    }
    
    .fullscreen-camera-video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Fix mobile nav for Android with gesture navigation */
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }
    
    /* Fix main content bottom padding for Android */
    .main-content {
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }
    
    /* Fix coin on Android */
    .coin-2d {
        will-change: transform;
    }
}

/* Android Chrome specific — no -webkit-device-pixel-ratio filter */
@media screen and (max-width: 480px) and (hover: none) and (pointer: coarse) {
    .logo-text { font-size: 0.75rem; }
    .glitch-x { font-size: 0.9rem; }
    .main-header { height: 42px; padding: 0 0.4rem; }
    .main-content { margin-top: 42px; padding: 0.35rem 0.75rem; }
    .mobile-nav { height: 48px; }
    .mobile-nav-tab span { display: none; }
    .mobile-nav-tab i { font-size: 1.2rem; }
    body { padding-bottom: 50px; }
    .card { padding: 0.5rem; }
    .card-title { font-size: 0.9rem; margin-bottom: 0.35rem; }
    .player-score-value { font-size: 1.8rem; }
    .player-score-card { padding: 0.4rem; min-height: 60px; }
    .point-btn { padding: 0.4rem 0.2rem; font-size: 0.75rem; min-height: 48px; }
    .btn { padding: 0.5rem 0.7rem; font-size: 0.8rem; min-height: 40px; }
    .btn-small { padding: 0.3rem 0.5rem; font-size: 0.7rem; min-height: 34px; }
    .form-group { margin-bottom: 0.35rem; }
    input, select, textarea { padding: 0.45rem 0.6rem; min-height: 38px; }
}

/* ============================================================
   iOS SAFARI ENHANCED FIXES
   ============================================================ */
@supports (-webkit-touch-callout: none) {
    /* Use dvh for all full-screen elements on iOS Safari */
    body {
        min-height: 100dvh;
        min-height: -webkit-fill-available;
    }
    
    html {
        height: -webkit-fill-available;
    }
    
    /* Camera overlay: account for Safari URL bar with dvh */
    .fullscreen-camera-overlay {
        height: 100dvh !important;
        height: -webkit-fill-available !important;
    }
    
    .fullscreen-camera-container {
        flex: 1;
        min-height: 0;
    }
    
    .fullscreen-camera-video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Countdown overlay — fill viewport properly */
    .countdown-overlay {
        height: 100dvh !important;
        height: -webkit-fill-available !important;
    }
    
    /* Modal — fit within Safari's actual viewport */
    .modal {
        height: 100dvh;
        height: -webkit-fill-available;
    }
    
    /* Bottom nav accounts for home indicator */
    .mobile-nav {
        height: calc(52px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    /* Main content accounts for header + bottom nav + safe areas */
    .main-content {
        margin-top: calc(46px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
    
    /* Header accounts for notch */
    .main-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(46px + env(safe-area-inset-top, 0px));
    }
}

/* ═══════════════════════════════════════════════════════════════════
   iOS SAFARI & WEBKIT DEEP-FIX LAYER
   Targets: iPhone, iPad, Safari on Mac
   @supports (-webkit-touch-callout: none) = iOS Safari only
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. GLOBAL WEBKIT PREFIXES (all Safari/WebKit) ── */
@media not all and (min-resolution: .001dpcm) {
    @supports (-webkit-appearance: none) {

        /* Ensure backdrop-filter always has webkit prefix */
        .card, .modal-content, .main-header, .mobile-nav,
        .glass, [class*="glass"], .login-box,
        .notification, #floatingJudgeTools, .set-editor-content,
        .fullscreen-camera-overlay, .countdown-overlay {
            -webkit-backdrop-filter: blur(20px) saturate(180%);
            backdrop-filter: blur(20px) saturate(180%);
        }

        /* Flex gap fallback — Safari 14 and below doesn't support gap in flex */
        .btn + .btn { margin-left: 0.4rem; }

        /* Fix gradient renders on Safari (forces GPU layer) */
        .btn, .card, .stat-card, .modal-content {
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
            will-change: auto;
        }
    }
}

/* ── 2. iOS-ONLY DEEP FIXES ── */
@supports (-webkit-touch-callout: none) {

    /* Safe area padding for notched iPhones */
    .main-header {
        padding-top: env(safe-area-inset-top, 0px);
        padding-left:  env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom, 20px);
        padding-left:   env(safe-area-inset-left, 0px);
        padding-right:  env(safe-area-inset-right, 0px);
    }
    body {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Fix iOS overscroll bounce and text resize */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    body {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix scrollable containers on iOS */
    .modal-content, .admin-content, .organizer-content,
    .judge-content, .play-content, .mod-content,
    [class*="-scroll"], [class*="scroll-"] {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    /* ── BOXES / CARDS ── */
    /* iOS Safari sometimes renders rgba backgrounds as transparent — force solid fallback */
    .card {
        background-color: #0d1a0d !important;
        background: rgba(0, 255, 65, 0.07) !important;
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        border: 1px solid rgba(0, 255, 65, 0.15) !important;
        /* Force the box to have its own compositing layer */
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }

    /* Stats boxes */
    .stat-card, .stat-box {
        background-color: #0a150a !important;
        background: rgba(0, 255, 65, 0.07) !important;
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    /* Glass panels */
    .glass, [class*="glass"] {
        background-color: rgba(255, 255, 255, 0.04) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }

    /* Modals */
    .modal-overlay { background: rgba(0,0,0,0.85) !important; }
    .modal-content {
        background: #0f0a1e !important;
        background: linear-gradient(135deg, #1a0a2e, #0a0a1a) !important;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        max-height: 88vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Prevent content being hidden behind the notch */
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }

    /* ── BUTTONS ── */
    button, .btn, [class*="btn"] {
        /* Remove iOS default button styling */
        -webkit-appearance: none;
        appearance: none;
        /* Prevent double-tap zoom delay */
        touch-action: manipulation;
        /* Fix tap highlight */
        -webkit-tap-highlight-color: transparent;
        /* Ensure minimum tap target (Apple HIG: 44pt) */
        min-height: 44px;
        cursor: pointer;
    }

    /* Circle buttons must not get min-height or they become ovals */
    .profile-btn,
    .match-scoreboard-edit,
    .close-btn {
        min-height: unset !important;
    }

    .btn {
        background: linear-gradient(135deg, #ff2d55, #cc001c) !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    .btn-secondary {
        background: linear-gradient(135deg, #00d4ff, #0088cc) !important;
        color: #000 !important;
    }
    .btn-success, .btn-green {
        background: linear-gradient(135deg, #00ff41, #00cc34) !important;
        color: #000 !important;
    }
    .btn-gold {
        background: linear-gradient(135deg, #ffd700, #cc9400) !important;
        color: #000 !important;
    }
    .btn-warning {
        background: linear-gradient(135deg, #ff9500, #cc6a00) !important;
    }

    /* Point scoring buttons */
    .point-btn { -webkit-appearance: none; appearance: none; min-height: 44px; }
    .point-btn.spin    { background: linear-gradient(135deg, #00d4ff, #0088cc) !important; }
    .point-btn.burst   { background: linear-gradient(135deg, #ff2d55, #cc001c) !important; }
    .point-btn.over    { background: linear-gradient(135deg, #00ff41, #00cc34) !important; color: #000 !important; }
    .point-btn.extreme { background: linear-gradient(135deg, #ffd700, #cc9400) !important; color: #000 !important; }

    /* ── FORM INPUTS ── */
    input, select, textarea {
        -webkit-appearance: none;
        appearance: none;
        background-color: rgba(0,0,0,0.4) !important;
        color: #fff !important;
        border-radius: 10px !important;
        border: 1px solid rgba(255,255,255,0.15) !important;
        /* Prevent iOS zoom on focus (font-size must be >= 16px) */
        font-size: max(16px, 1rem) !important;
        /* Remove iOS inner shadow on inputs */
        -webkit-box-shadow: none !important;
        box-shadow: none !important;
    }

    /* Custom select arrow */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 12px center !important;
        padding-right: 36px !important;
    }

    /* ── CAMERA / VIDEO ── */
    /* fullscreen camera overlay — must fill entire screen on iOS */
    .fullscreen-camera-overlay {
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        /* Use dvh when supported (handles Safari address bar) */
        height: 100dvh !important;
        z-index: 9999 !important;
        background: #000 !important;
        -webkit-overflow-scrolling: touch;
        overflow: hidden;
    }

    .fullscreen-camera-container {
        width: 100% !important;
        height: 100% !important;
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        background: #000 !important;
    }

    /* The <video> element must have these attributes on iOS */
    .fullscreen-camera-video {
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        object-fit: cover !important;
        /* Critical: without these iOS won't show the video */
        -webkit-playsinline: 1;
        background: #000 !important;
    }

    /* Camera controls — bump up tap targets on small screens */
    .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;
    }

    .control-btn {
        min-height: 44px !important;
        padding: 12px 20px !important;
    }

    /* Review video */
    #reviewVideo, #recordingPlaybackVideo {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        -webkit-playsinline: 1;
    }

    /* ── LAYOUT FIXES ── */
    /* iOS Safari <15 flex gap workaround */
    .organizer-content .card + .card { margin-top: 1rem; }

    /* Fix position: sticky on iOS */
    .main-header, .mobile-nav {
        position: -webkit-sticky !important;
        position: sticky !important;
    }
    .main-header { top: 0 !important; }
    .mobile-nav  { bottom: 0 !important; }

    /* Fix for organizer stats row on small screens */
    .stats-row, [class*="stats-row"] {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-wrap: wrap !important;
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
    }

    /* Fix player score cards stacking */
    .player-score-card {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-direction: column;
        flex-direction: column;
        background: rgba(0,255,65,0.07) !important;
    }

    /* Fix match items */
    .match-item {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-wrap: wrap !important;
        flex-wrap: wrap !important;
        background: rgba(0,0,0,0.25) !important;
    }

    /* ── TEXT & RENDERING ── */
    h1, h2, h3, h4, h5, .glitch-x {
        -webkit-font-smoothing: antialiased;
        font-smooth: always;
    }
    /* Disable heavy text-shadow animations on iOS (perf) */
    @media (prefers-reduced-motion: no-preference) {
        .glitch-x {
            text-shadow: 0 0 10px #ff2d55, 0 0 20px #ff2d55 !important;
        }
    }

    /* ── HEADER / NAV ── */
    .main-header {
        background: rgba(10, 10, 26, 0.97) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        backdrop-filter: blur(20px) !important;
    }
    .mobile-nav {
        background: rgba(10, 10, 26, 0.97) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        backdrop-filter: blur(20px) !important;
    }

    /* ── SCROLLBAR (hide on iOS, it's auto-hidden anyway) ── */
    ::-webkit-scrollbar { display: none; }
    * { scrollbar-width: none; }
}

/* ── 3. SMALL SCREEN TOUCH ADJUSTMENTS (iPhone SE and up) ── */
@media (max-width: 430px) and (-webkit-min-device-pixel-ratio: 2) {

    /* Ensure all interactive elements meet 44pt minimum */
    button, .btn, input, select, a.btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    /* Circle buttons stay circular on iPhone SE too */
    .profile-btn,
    .match-scoreboard-edit,
    .close-btn {
        min-height: unset !important;
        height: 30px !important;
        width: 30px !important;
        padding: 0 !important;
        border-radius: 50% !important;
    }

    /* Camera controls stack better on small screens */
    .fullscreen-camera-controls {
        -webkit-flex-direction: column !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
    }

    /* Ensure modal doesn't overflow */
    .modal-content {
        width: 95vw !important;
        max-height: 85dvh !important;
        border-radius: 16px !important;
    }

    /* Fix organizer stats cards on small phones */
    .stat-card {
        min-width: 80px;
        padding: 0.75rem 0.5rem;
    }
}
