:root {
    --bg-body: #0b1913;
    --card-bg: #12241c;
    --card-border: #1e382c;
    --accent-gold: #f59e0b;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --nav-height: 62px;
    
    /* Variabel Safe Area untuk iOS & HP Layar Penuh */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Mencegah Overtouch/Bouncing yang Buruk di HP */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Hapus kotak biru saat diketuk */
}

html {
    /* Menghilangkan efek bouncing scroll berlebih di iOS */
    overscroll-behavior-y: none;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Trik full height iOS */
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    /* Mencegah seleksi teks yang tidak sengaja saat di-tap berulang */
    user-select: none;
    -webkit-user-select: none;
}

/* Biarkan elemen teks tertentu tetap bisa diseleksi jika perlu */
p, h1, h2, h3, h4, h5, h6, span, td, input, textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* Header Solid Ringan + Safe Area Support */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #08140f;
    border-bottom: 1px solid var(--card-border);
    padding: calc(12px + var(--safe-area-top)) 16px 12px 16px;
    backdrop-filter: blur(10px); /* Efek blur kaca khas iOS jika header agak transparan */
    -webkit-backdrop-filter: blur(10px);
}

/* Custom Tabs Styling */
.nav-tabs-custom {
    border-bottom: 1px solid var(--card-border);
    display: flex;
    overflow-x: auto; /* Memungkinkan swipe horizontal jika tab banyak */
    scrollbar-width: none; /* Hilangkan scrollbar Firefox */
}

.nav-tabs-custom::-webkit-scrollbar {
    display: none; /* Hilangkan scrollbar Chrome/Safari */
}

.nav-tabs-custom .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 16px;
    background: transparent;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-main);
    border-color: transparent;
}

.nav-tabs-custom .nav-link.active {
    color: var(--accent-gold);
    border-bottom: 2px solid var(--accent-gold);
    background: transparent;
}

/* Card Flat */
.card-custom {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px; /* Dibuat sedikit lebih membulat khas UI HP */
    overflow: hidden;
}

/* Badge Nomor Peringkat */
.num-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 14px;
    flex-shrink: 0;
}

/* Table Styling */
.table-custom {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    border-color: var(--card-border);
    width: 100%;
}

.table-custom th {
    color: var(--accent-gold);
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Bottom Nav Mobile Modern + Safe Area iOS Support */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Sediakan ruang untuk Safe Area / Gestur HP */
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background-color: #08140f;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.nav-link-native {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    gap: 3px;
    width: 25%;
    height: 100%;
    transition: color 0.15s ease, transform 0.1s ease;
}

.nav-link-native i {
    font-size: 20px;
}

/* Feedback sentuhan (Active State) ala App Native */
.nav-link-native:active {
    transform: scale(0.92);
    opacity: 0.8;
}

.nav-link-native.active {
    color: var(--accent-gold);
    font-weight: 700;
}

/* Optimization Input Form untuk HP (Mencegah Auto-Zoom Safari iOS) */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
    font-size: 16px !important; /* Standar cegah auto-zoom iOS */
    border-radius: 10px;
}

.app-footer {
    margin-top: auto;
    background-color: #08140f;
    border-top: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 16px;
}

/* Responsive Visibility & Layout Optimization */
@media (max-width: 767.98px) {
    body { 
        /* Pastikan konten paling bawah tidak tertutup Navigasi Bawah */
        padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px); 
    }
    
    .table-desktop { display: none !important; }
    .mobile-cards { display: block !important; }
    .bottom-nav { display: flex !important; }
    .app-footer { margin-bottom: 0; }
}

@media (min-width: 768px) {
    .table-desktop { display: table !important; } /* Ganti ke display: table agar struktur tabel valid */
    .mobile-cards { display: none !important; }
    .bottom-nav { display: none !important; }
    .main-container { max-width: 900px; margin: 0 auto; padding: 20px; }
}

/* Container Utama Card */
.card-peserta-aktif {
    background: radial-gradient(circle at center, #111b15 0%, #080d0a 100%);
    border: 2px solid #f5a623; /* Border Gold */
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(245, 166, 35, 0.2);
    color: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Badge Panggung Utama */
.badge-panggung {
    border: 1px solid #d9534f;
    background-color: rgba(217, 83, 79, 0.15);
    color: #ff6b6b;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
}

/* Titik Indikator Merah Berkedip */
.dot-live {
    width: 10px;
    height: 10px;
    background-color: #ff3b30;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    box-shadow: 0 0 8px #ff3b30;
    animation: blink 1.2s infinite ease-in-out;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.status-tampil {
    color: #a0aec0;
    font-size: 1rem;
    font-weight: 600;
}

/* Label & Nomor Dada */
.label-nomor-dada {
    color: #a0aec0;
    font-size: 1rem;
    letter-spacing: 2px;
    font-weight: 600;
}

.nomor-dada-glow {
    font-size: 5rem;
    font-weight: 900;
    color: #ffb100;
    text-shadow: 0 0 15px rgba(255, 177, 0, 0.6);
    line-height: 1.1;
    margin: 5px 0 15px 0;
}

/* Nama & Asal Sekolah */
.nama-peserta-aktif {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffffff;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.sekolah-peserta-aktif {
    font-size: 1.1rem;
    color: #e2e8f0;
    font-weight: 500;
}