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

:root {
    --bg: #0f172a;
    --card: #1e293b;
    --card-border: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warn: #f59e0b;
    --radius: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    padding-bottom: 40px;
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.app-header {
    background: #0b1120;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.brand-link {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.brand-link:hover {
    color: #93c5fd;
}

.header-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.nav-btn {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid var(--card-border);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.nav-btn:hover {
    border-color: var(--primary);
    color: #fff;
}

.nav-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.nav-btn-admin {
    color: var(--muted);
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.card h2 { font-size: 1.25rem; margin-bottom: 6px; }
.card h3 { font-size: 1.05rem; margin-bottom: 8px; }

.section-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.hero-card p {
    margin-top: 8px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.rules-list li {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.game-rules-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.game-rule-card {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
}

.game-rule-title {
    font-weight: 700;
    font-size: 0.96rem;
    margin-bottom: 4px;
    color: #f8fafc;
}

.card-highlight {
    border-color: var(--warn);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, var(--card) 100%);
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
    background: #0f172a;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.auth-tab {
    padding: 9px 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.auth-tab.active {
    background: var(--primary);
    color: #fff;
}

.player-box {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.player-box-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #93c5fd;
    margin-bottom: 10px;
}

.admin-players-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.admin-player-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 0.84rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 16px;
    border-radius: 10px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.btn-full { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }
.btn-xs { padding: 4px 8px; font-size: 0.76rem; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #334155; color: #fff; }
.btn-ghost { background: transparent; color: #e2e8f0; border: 1px solid var(--card-border); }
.btn-success { background: var(--success); color: #052e16; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

.teams-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
}

.team-slot-card {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.team-slot-info h4 { font-size: 1rem; margin-bottom: 4px; }
.player-pills { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: #1e293b;
    border: 1px solid #334155;
}

.pill-empty { color: var(--muted); border-style: dashed; }

.team-banner-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.badge {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
}

.points-box {
    background: #0f172a;
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 10px 16px;
    text-align: center;
    min-width: 84px;
}

.points-val {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: #60a5fa;
    line-height: 1.1;
}

.points-lbl { font-size: 0.75rem; color: var(--muted); }

.team-banner-actions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
}

.game-btn {
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text);
    border-radius: 12px;
    padding: 13px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    font-size: 0.98rem;
    font-weight: 600;
}

.game-btn:active { transform: scale(0.99); }
.game-btn-left { display: flex; align-items: center; gap: 10px; }
.game-icon { font-size: 1.35rem; }
.game-progress {
    font-size: 0.8rem;
    color: var(--muted);
    background: #1e293b;
    padding: 3px 8px;
    border-radius: 8px;
}
.game-progress.done {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
}

.match-item {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 8px;
}

.match-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.match-actions { display: flex; gap: 8px; margin-top: 10px; }
.match-actions .btn { flex: 1; }

.matrix-game {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
}

.matrix-game:first-child { margin-top: 4px; padding-top: 0; border-top: none; }
.matrix-game-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.opponents-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.opp-chip {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: #0f172a;
}

.opp-chip.done {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
    text-decoration: line-through;
}

.opp-chip.pending {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.admin-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.admin-controls { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.leaderboard-table th, .leaderboard-table td {
    padding: 9px 8px;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
}
.leaderboard-table th { color: var(--muted); font-weight: 600; }
.leaderboard-table td:last-child { font-weight: 800; color: #60a5fa; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 50;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    padding: 18px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.88rem; margin-bottom: 5px; color: #e2e8f0; }

input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: #0f172a;
    color: var(--text);
    font-size: 0.98rem;
}

.radio-cards { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0f172a;
    border: 1px solid var(--card-border);
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
}
.radio-card input { width: 18px; height: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 12px; }
.alert-warn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    border: 1px solid var(--primary);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-width: 90vw;
    text-align: center;
}

.opp-chip.challengeable {
    cursor: pointer;
    border-color: rgba(59, 130, 246, 0.5);
    color: #dbeafe;
    transition: 0.15s;
}

.opp-chip.challengeable:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: var(--primary);
    color: #fff;
}

.opp-chip.challenged {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.55);
    color: #93c5fd;
}

.opp-chip.disabled {
    opacity: 0.55;
}

.team-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--card-border);
    flex-shrink: 0;
    background: #1e293b;
}

.team-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 14px;
}

.team-avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.team-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: var(--muted);
}

.team-slot-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.team-banner-identity {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.team-banner-actions {
    flex-wrap: wrap;
    gap: 10px;
}

.team-photo-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.leaderboard-team-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.team-pig-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 10px;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.team-avatar-lg.team-pig-badge {
    font-size: 1.75rem;
    border-radius: 14px;
}

.team-avatar-sm.team-pig-badge {
    font-size: 0.95rem;
    border-radius: 7px;
}

.opp-chip .team-avatar-xs {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    flex-shrink: 0;
}

.opp-chip-content {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pig-color-1 { background: radial-gradient(circle at 30% 30%, #f472b6, #be185d); }
.pig-color-2 { background: radial-gradient(circle at 30% 30%, #60a5fa, #1d4ed8); }
.pig-color-3 { background: radial-gradient(circle at 30% 30%, #34d399, #047857); }
.pig-color-4 { background: radial-gradient(circle at 30% 30%, #fbbf24, #b45309); }
.pig-color-5 { background: radial-gradient(circle at 30% 30%, #a78bfa, #6d28d9); }
.pig-color-6 { background: radial-gradient(circle at 30% 30%, #22d3ee, #0e7490); }
.pig-color-7 { background: radial-gradient(circle at 30% 30%, #fb7185, #be123c); }
.pig-color-8 { background: radial-gradient(circle at 30% 30%, #a3e635, #4d7c0f); }

.sidequest-card {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
}

.sidequest-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.sidequest-pts-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.45);
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.sidequest-status-done {
    color: #6ee7b7;
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 6px;
}

.sidequest-status-todo {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 6px;
}

.nav-btn-logout {
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.nav-btn-logout:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.16);
    color: #fff;
}

.admin-notif-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.admin-notif-item {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text);
}

.sidequest-action-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sq-proof-preview {
    margin-top: 8px;
    display: block;
    max-width: 100%;
    max-height: 260px;
    width: auto;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    object-fit: contain;
    background: #020617;
}

.sq-proof-thumb {
    margin-top: 8px;
    display: inline-block;
    max-width: 180px;
    max-height: 140px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    object-fit: cover;
}

.sq-hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.admin-sq-approve-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.admin-sq-pts-select {
    width: auto;
    min-width: 118px;
    padding: 7px 10px;
    font-size: 0.85rem;
}

.countdown-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(15, 23, 42, 0.85);
    font-size: 0.9rem;
}

.countdown-label {
    color: var(--muted, #94a3b8);
}

.countdown-value {
    color: var(--primary, #f59e0b);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.countdown-banner.countdown-ended .countdown-value {
    color: #f87171;
}

.gallery-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
}

.gallery-filter-btn {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: var(--surface-2, #1e293b);
    color: var(--text, #f8fafc);
    font-size: 0.85rem;
    cursor: pointer;
}

.gallery-filter-btn.active {
    background: var(--primary, #f59e0b);
    color: #0f172a;
    border-color: var(--primary, #f59e0b);
    font-weight: 600;
}

.gallery-quests-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.gallery-quest-section {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.35);
}

.gallery-quest-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.gallery-item-card {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card-bg, #0f172a);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.gallery-item-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary, #f59e0b);
}

.gallery-thumb-wrap {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #020617;
}

.gallery-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item-meta {
    padding: 8px 10px;
}

.gallery-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.gallery-modal-card {
    max-width: 720px;
    width: 94vw;
}

.gallery-modal-img-wrap {
    margin: 12px 0;
    background: #020617;
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
}

.gallery-modal-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: inline-block;
}
