:root {
    --bg-primary: #0a0e1a;
    --bg-card: rgba(17, 24, 45, 0.85);
    --bg-card-hover: rgba(25, 35, 60, 0.95);
    --bg-input: rgba(10, 14, 30, 0.8);
    --border: rgba(99, 102, 241, 0.18);
    --border-focus: rgba(99, 102, 241, 0.6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;
    --gold: #fbbf24;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

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

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.35;
}

.orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, #6366f1, transparent 70%); top: -150px; left: -100px; }
.orb-2 { width: 450px; height: 450px; background: radial-gradient(circle, #a855f7, transparent 70%); bottom: -100px; right: -100px; }
.orb-3 { width: 350px; height: 350px; background: radial-gradient(circle, #ec4899, transparent 70%); top: 50%; left: 50%; transform: translate(-50%, -50%); }

.grid-bg {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ── Layout ── */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1050px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* ── Header ── */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 24px 28px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.logo { display: flex; align-items: center; gap: 16px; }
.logo-icon { font-size: 40px; filter: drop-shadow(0 0 12px var(--accent-glow)); }
.logo h1 { font-size: 22px; font-weight: 700; background: linear-gradient(135deg, #f1f5f9, #a5b4fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Tournament Header Card ── */
.tournament-header-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.tournament-header-card h1 {
    font-size: 24px;
    font-weight: 800;
    margin: 12px 0;
    color: var(--text-primary);
}

.tournament-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.badge-row { display: flex; gap: 10px; align-items: center; }

/* ── Tournament Cards (Public Grid) ── */
.tournament-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.tournament-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.tournament-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
}

.card-status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tournament-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; line-height: 1.35; }
.tournament-details { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; font-size: 14px; color: var(--text-secondary); }
.detail-item { display: flex; align-items: center; gap: 8px; }

/* ── Sections ── */
.query-section, .list-section, .public-section, .admin-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.section-title.space-between { justify-content: space-between; }
.section-icon { font-size: 22px; }
.section-title h2 { font-size: 18px; font-weight: 600; }

/* ── Forms & Inputs ── */
.input-wrapper { display: flex; gap: 12px; }
.input-wrapper input, .form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}

.form-group select option {
    background: #11182d;
    color: #f1f5f9;
}

.input-wrapper input:focus, .form-group input:focus, .form-group select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.form-row { display: flex; gap: 16px; margin-bottom: 12px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* ── Buttons ── */
.btn-primary {
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.btn-primary:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); transform: translateY(-2px); }

.btn-success {
    padding: 14px 28px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-success:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35); transform: translateY(-2px); }
.btn-success:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
    padding: 12px 24px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    padding: 10px 18px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.btn-secondary-sm {
    padding: 8px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger-outline {
    padding: 10px 18px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.btn-excel {
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #10b981;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.btn-excel-lg {
    padding: 10px 20px;
    background: #10b981;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; font-weight: 600; text-decoration: none; cursor: pointer; border: none; }
.btn-info { background: rgba(59, 130, 246, 0.15); border: 1px solid #3b82f6; color: #3b82f6; }

.btn-query {
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-query.loading .btn-text { display: none; }
.btn-query.loading .btn-spinner { display: block; }
.btn-spinner { display: none; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: white; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-back { display: inline-block; margin-bottom: 16px; color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.btn-back:hover { color: var(--accent); }
.full-width { width: 100%; }
.text-center { text-align: center; }

/* ── Result & Error Cards ── */
.result-card {
    margin-top: 20px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    padding: 24px;
}

.result-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--accent); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.result-item { display: flex; flex-direction: column; gap: 4px; }
.result-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.result-value { font-size: 16px; font-weight: 600; }
.ukd-score { font-size: 24px; font-weight: 800; color: var(--gold); }

/* ── Password Rule Badges ── */
.password-rules-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rule-badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.rule-badge.invalid { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.rule-badge.valid { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }

/* ── Alerts & Warnings ── */
.alert-box {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.alert-box.success { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }
.alert-box.error { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.alert-box.warning { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); margin-top: 20px; }

.error-card { margin-top: 20px; display: flex; gap: 10px; padding: 16px; background: var(--danger-bg); border: 1px solid var(--danger); border-radius: var(--radius-sm); color: var(--danger); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
.player-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.player-table thead th { padding: 12px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border); }
.player-table tbody tr { background: rgba(255, 255, 255, 0.02); }
.player-table tbody tr:hover { background: rgba(99, 102, 241, 0.06); }
.player-table tbody td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.td-ukd { color: var(--gold); font-weight: 700; }

.badge-vize { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-vize.valid { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-vize.invalid { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

.status-badge { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status-active { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid #10b981; }
.status-expired { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid #ef4444; }
.status-past { background: rgba(148,163,184,0.15); color: #94a3b8; border: 1px solid #94a3b8; }
.counter-badge { padding: 4px 12px; background: rgba(99,102,241,0.12); color: var(--accent); border-radius: 20px; font-size: 12px; font-weight: 700; }

/* ── Expired / Active Tournament Card Styles ── */
.tournament-card.card-active {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.08);
}
.tournament-card.card-active:hover {
    border-color: #10b981;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.2);
}

.tournament-card.card-expired {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.04);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.08);
}
.tournament-card.card-expired:hover {
    border-color: #ef4444;
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.2);
}

.btn-primary.btn-expired-card {
    background: linear-gradient(135deg, #64748b, #475569);
}
.btn-primary.btn-expired-card:hover {
    box-shadow: 0 8px 24px rgba(100, 116, 139, 0.35);
}

.tournament-header-card.header-expired {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.04);
}

/* ── Password Eye Toggle Wrapper ── */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.password-wrapper input {
    padding-right: 48px;
}
.btn-toggle-password {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    border-radius: 6px;
    transition: transform 0.2s;
    user-select: none;
}
.btn-toggle-password:hover {
    transform: scale(1.18);
}

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(8px); z-index: 999; display: flex; justify-content: center; align-items: center; padding: 20px; }
.modal-card { background: #11182d; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }
.modal-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ── Admin Login Page ── */
.login-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card { background: var(--bg-card); backdrop-filter: blur(20px); border: 1px solid var(--border); padding: 36px; border-radius: var(--radius); width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-header { text-align: center; margin-bottom: 24px; }
.login-icon { font-size: 44px; }
.login-header h2 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-footer { text-align: center; margin-top: 20px; }
.login-footer a { color: var(--text-muted); font-size: 13px; text-decoration: none; }
.login-footer a:hover { color: var(--accent); }

/* ── Utilities ── */
.hidden { display: none !important; }
.margin-top-10 { margin-top: 10px; }
.margin-top-20 { margin-top: 20px; }
.action-cells { display: flex; gap: 6px; align-items: center; }

@media (max-width: 640px) {
    .app-header { flex-direction: column; gap: 16px; text-align: center; }
    .form-row { flex-direction: column; gap: 0; }
    .result-grid { grid-template-columns: 1fr; }
    .action-cells { flex-direction: column; }
}
