/* ============================================
   MINIGOLF TURNIER APP — DESIGN SYSTEM
   Mobile-first, dark mode, glassmorphism
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(22, 33, 62, 0.7);
    --bg-card-hover: rgba(30, 45, 80, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #e8e8f0;
    --text-secondary: #9a9ab8;
    --text-muted: #5a5a78;
    --accent-primary: #7c5cff;
    --accent-secondary: #5cb8ff;
    --accent-gradient: linear-gradient(135deg, #7c5cff 0%, #5cb8ff 100%);
    --gold: #d4af37;
    --gold-light: #f5e6b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(124, 92, 255, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: 80px;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(124, 92, 255, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(92, 184, 255, 0.06) 0%, transparent 60%);
}

/* --- Header --- */
.app-header {
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.header-content h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.status-dot.offline {
    background: var(--danger);
}

/* --- Tab Navigation --- */
.tab-nav {
    display: flex;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 49px;
    z-index: 90;
    max-width: 600px;
    margin: 0 auto;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    width: 60%;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-label {
    letter-spacing: 0.3px;
}

/* --- Container --- */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: fadeInUp 0.3s ease-out;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.flex-grow {
    flex: 1;
}

/* Holes selector */
.holes-selector {
    display: flex;
    gap: 8px;
}

.holes-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.holes-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    box-shadow: 0 0 30px rgba(124, 92, 255, 0.5);
}

.btn-accent {
    background: rgba(124, 92, 255, 0.2);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-accent:hover {
    background: rgba(124, 92, 255, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, #c49b2f 100%);
    color: #1a1a2e;
    font-weight: 700;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-sm:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-lg {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* --- Tab content --- */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

/* --- Tournament list --- */
.tournament-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tournament-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    cursor: pointer;
    transition: var(--transition);
}

.tournament-item:hover,
.tournament-item.selected {
    border-color: var(--accent-primary);
    background: rgba(124, 92, 255, 0.1);
}

.tournament-item.selected {
    box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.3);
}

.tournament-item-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.tournament-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tournament-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 100px;
    font-weight: 600;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-finished {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold);
}

/* --- Player list --- */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    animation: fadeInUp 0.2s ease-out;
}

.player-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.player-delete {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.player-delete:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* --- Scoring --- */
.scoring-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.hole-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hole-indicator {
    font-size: 1.3rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.scoring-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scoring-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.scoring-row.submitted {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.05);
}

.scoring-player-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stroke-selector {
    display: flex;
    gap: 4px;
}

.stroke-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.stroke-btn:active {
    transform: scale(0.9);
}

.stroke-btn.selected {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(124, 92, 255, 0.4);
}

.stroke-btn.s1.selected {
    background: var(--gold);
    border-color: var(--gold);
    color: #1a1a2e;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

.stroke-btn.s2.selected {
    background: var(--success);
    border-color: var(--success);
}

.stroke-btn.s6.selected,
.stroke-btn.s7.selected {
    background: var(--danger);
    border-color: var(--danger);
}

/* --- Leaderboard --- */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.3s ease-out;
}

.leaderboard-row.rank-1 {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.05) 100%);
    border-color: rgba(212, 175, 55, 0.3);
}

.leaderboard-row.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1) 0%, rgba(192, 192, 192, 0.03) 100%);
    border-color: rgba(192, 192, 192, 0.2);
}

.leaderboard-row.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1) 0%, rgba(205, 127, 50, 0.03) 100%);
    border-color: rgba(205, 127, 50, 0.2);
}

.leaderboard-rank {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rank-1 .leaderboard-rank {
    background: linear-gradient(135deg, var(--gold), #c49b2f);
    color: #1a1a2e;
    font-size: 1.1rem;
}

.rank-2 .leaderboard-rank {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a2e;
}

.rank-3 .leaderboard-rank {
    background: linear-gradient(135deg, #cd7f32, #a0652a);
    color: #1a1a2e;
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.leaderboard-score {
    text-align: right;
    flex-shrink: 0;
}

.leaderboard-total {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-secondary);
}

.leaderboard-holes {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- AI Toast --- */
.ai-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 380px;
    width: calc(100% - 32px);
    z-index: 200;
    animation: slideUp 0.4s ease-out, fadeOut 0.4s ease-in 4.5s forwards;
}

.ai-toast.hidden {
    display: none;
}

.ai-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}

.ai-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.ai-toast-content p {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-primary);
    font-style: italic;
}

/* --- Certificates --- */
.certificate-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.certificate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
}

.certificate-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.certificate-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.certificate-rank {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Results --- */
.results-summary {
    text-align: center;
    padding: 20px 0;
}

.results-winner {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 12px 0;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

.mt-16 {
    margin-top: 16px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

/* --- Media Queries --- */
@media (min-width: 480px) {
    .stroke-btn {
        width: 42px;
        height: 42px;
    }
}

/* --- Auth Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.4s ease-out;
}

.auth-error {
    color: var(--danger);
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 12px;
    animation: fadeInUp 0.2s ease-out;
}

input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

input[type="password"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

/* --- Player links --- */
.player-link-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.player-link {
    font-size: 0.7rem;
    color: var(--accent-secondary);
    text-decoration: none;
    opacity: 0.8;
    transition: var(--transition);
}

.player-link:hover {
    opacity: 1;
}

.copy-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
    transition: var(--transition);
}

.copy-btn:hover {
    color: var(--text-primary);
}

/* --- Live Ticker --- */
.ticker-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.ticker-item {
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    animation: slideInRight 0.3s ease-out;
}

.ticker-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ticker-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ticker-player {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.ticker-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.ticker-comment {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-glass);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.4;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}