/* CSS Reset & Variables */
:root {
    --bg-dark: #090d16;
    --bg-card: rgba(20, 28, 47, 0.75);
    --bg-hover: rgba(99, 102, 241, 0.15);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.4);
    
    --color-text: #f1f5f9;
    --color-muted: #94a3b8;
    
    --accent-indigo: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --accent-pink: #f43f5e;
    
    --grad-indigo-purple: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --grad-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --grad-pink: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-primary: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--color-text);
    font-family: var(--font-primary);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-indigo);
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top, rgba(99, 102, 241, 0.15) 0%, rgba(9, 13, 22, 0) 60%);
    position: relative;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    background: rgba(9, 13, 22, 0.8);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.emoji-logo {
    font-size: 28px;
    animation: pulse 2s infinite alternate;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 11px;
    color: var(--color-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    font-size: 14px;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation Tabs */
.main-nav {
    display: flex;
    padding: 8px 16px;
    gap: 8px;
    background: rgba(9, 13, 22, 0.5);
    border-bottom: 1px solid var(--border-color);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-muted);
    font-family: var(--font-primary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    gap: 4px;
}

.nav-btn .icon {
    font-size: 18px;
    transition: transform 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    color: var(--color-text);
    background: var(--bg-hover);
}

.nav-btn:hover:not(:disabled) .icon {
    transform: translateY(-2px);
}

.nav-btn.active {
    color: var(--color-text);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-premium);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--grad-indigo-purple);
    border-radius: 3px 3px 0 0;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--accent-pink);
    color: #ffffff;
    font-size: 8px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 700;
}

/* Content Area */
.app-content {
    flex: 1;
    padding: 20px 16px 40px 16px;
    overflow-y: auto;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-panel.active {
    display: block;
}

.section-info {
    margin-bottom: 20px;
}

.section-info h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.section-info p {
    font-size: 13px;
    color: var(--color-muted);
}

/* Group Stage Grid */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.group-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 16px;
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.group-card:hover {
    border-color: var(--border-focus);
}

.group-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    border-left: 3px solid var(--accent-indigo);
    padding-left: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-card .group-status {
    font-size: 10px;
    color: var(--accent-indigo);
    font-weight: 600;
    text-transform: uppercase;
}

.group-teams-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.team-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.team-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.team-flag {
    font-size: 18px;
}

.team-name {
    font-size: 14px;
    font-weight: 500;
}

.select-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: transparent;
    transition: all 0.2s ease;
}

.team-row.selected {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.team-row.selected .select-indicator {
    border-color: var(--accent-indigo);
    background: var(--accent-indigo);
    color: white;
}

/* Third places section */
.third-places-section {
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-top: 24px;
    backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease;
}

.third-places-section .section-title {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    position: relative;
}

.third-places-section .section-title h3 {
    font-size: 16px;
    font-weight: 700;
}

.third-places-section .section-title p {
    font-size: 12px;
    color: var(--color-muted);
}

.third-places-section .counter {
    position: absolute;
    top: 4px;
    right: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-pink);
    background: rgba(244, 63, 94, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
}

.third-places-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.third-team-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.third-team-card:hover {
    background: rgba(255, 255, 255, 0.06);
}

.third-team-card.selected {
    background: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.3);
}

.third-team-card .team-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Playoff Stages Nav */
.playoff-stages-nav {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.stage-nav-btn {
    flex: 1;
    padding: 8px 2px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-muted);
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.stage-nav-btn:hover:not(:disabled) {
    color: var(--color-text);
}

.stage-nav-btn.active {
    background: var(--accent-indigo);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.stage-nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* Bracket Container */
.bracket-container {
    min-height: 300px;
}

.stage-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.stage-panel.active {
    display: block;
}

.matches-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 600px) {
    .matches-list {
        grid-template-columns: 1fr 1fr;
    }
}

/* Match Card */
.match-card {
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    transition: all 0.2s ease;
}

.match-card:hover {
    border-color: var(--border-focus);
}

.match-card .match-index {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.05);
}

.match-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.match-team:hover {
    background: rgba(255, 255, 255, 0.05);
}

.match-team.winner {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.match-team.winner .team-name {
    font-weight: 700;
    color: #ffffff;
}

.match-team.loser {
    opacity: 0.4;
}

.match-team .winner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.2s ease;
}

.match-team.winner .winner-dot {
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

/* Finals Wrapper */
.finals-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 400px;
    margin: 0 auto;
}

.finals-match-box h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
    text-align: center;
}

.finals-match-box .helper-text {
    font-size: 11px;
    color: var(--color-muted);
    margin-bottom: 8px;
    text-align: center;
}

.finals-match-box .match-card {
    padding: 12px;
}

.finals-match-box.primary-final .match-card {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.1);
}

.finals-match-box.primary-final .match-team.winner {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
}

.finals-match-box.primary-final .match-team.winner .winner-dot {
    background: var(--accent-purple);
    box-shadow: 0 0 8px var(--accent-purple);
}

/* Champion reveal card */
.champion-reveal-card {
    background: linear-gradient(135deg, rgba(20, 28, 47, 0.9) 0%, rgba(99, 102, 241, 0.2) 100%);
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-premium);
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.champion-reveal-card .trophy-anim {
    font-size: 48px;
    margin-bottom: 8px;
    animation: float 2.5s infinite ease-in-out;
}

.champion-reveal-card h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-muted);
    font-weight: 600;
}

.champion-reveal-card .champion-name {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(99, 102, 241, 0.5);
    margin-top: 4px;
}

/* Summary View */
.summary-card {
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    backdrop-filter: blur(10px);
    margin-bottom: 24px;
}

.summary-champion {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.summary-champion .gold-trophy {
    font-size: 36px;
    animation: float 3s infinite ease-in-out;
}

.summary-champion .champ-info {
    display: flex;
    flex-direction: column;
}

.summary-champion .champ-info .label {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-muted);
    letter-spacing: 0.5px;
}

.summary-champion .champ-info .value {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.summary-row .label-inline {
    font-weight: 600;
    color: var(--color-muted);
}

.summary-row .value-inline {
    font-weight: 700;
    color: #ffffff;
    max-width: 70%;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.action-container {
    margin-top: 10px;
}

.btn {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
    border: none;
    outline: none;
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-save {
    background: var(--grad-indigo-purple);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.6);
}

.btn-save:active {
    transform: translateY(0);
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0px); }
}
