:root {
    --bg: #071812;
    --bg-elevated: #0f2a20;
    --bg-card: #123528;
    --accent: #00d47e;
    --accent-dark: #00a861;
    --gold: #f5c542;
    --text: #f4fbf7;
    --muted: #9bb8ad;
    --danger: #ff6b6b;
    --success: #4ade80;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    --nav-height: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top, #134832 0%, var(--bg) 45%);
    color: var(--text);
    font-family: 'Outfit', system-ui, sans-serif;
    min-height: 100%;
}

body {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 8px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
    background: rgba(7, 24, 18, 0.85);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.company-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px;
}

.company-logo-preview {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
    display: block;
}

.eyebrow {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
}

.app-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.app-main {
    padding: 8px 16px 24px;
}

.page-intro h2,
.auth-card h2,
.profile-header h2 {
    margin: 0 0 8px;
    font-size: 1.5rem;
}

.muted {
    color: var(--muted);
    margin: 0;
}

.flash {
    margin: 8px 16px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
}

.flash-success {
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.35);
}

.flash-error {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.35);
}

.flash-toast {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0;
    border-radius: 0;
    animation: flash-toast-in 0.2s ease-out;
}

.flash-toast-hide {
    opacity: 0;
    transition: opacity 0.3s ease;
}

@keyframes flash-toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.js-async-form.is-submitting {
    opacity: 0.7;
    pointer-events: none;
}

.auth-card,
.card {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.auth-card {
    margin-top: 24px;
}

.auth-page .header-brand .company-logo {
    display: none;
}

.auth-page .app-header {
    justify-content: center;
}

.auth-page .header-brand {
    justify-content: center;
}

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px 8px;
}

.auth-logo-large {
    max-width: min(280px, 80vw);
    max-height: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    padding: 16px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.hero-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(245, 197, 66, 0.15);
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 16px;
}

.stack-form {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="file"] {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

input[type="number"] {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.phone-input-group {
    display: flex;
    align-items: stretch;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
}

.phone-prefix {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border);
    font-weight: 700;
    white-space: nowrap;
    color: var(--text);
    font-size: 1rem;
}

.phone-prefix img {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.phone-input-group input[type="tel"] {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 18px;
    border-radius: 12px;
    border: none;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #042015;
}

.btn-pending {
    background: linear-gradient(135deg, var(--gold), #d4a017);
    color: #2a1f00;
    box-shadow: 0 4px 16px rgba(245, 197, 66, 0.25);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #e04545);
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.25);
}

.btn-danger:hover {
    filter: brightness(1.05);
}

.btn-update {
    background: linear-gradient(135deg, #ff9f43, #e67e22);
    color: #2a1400;
    box-shadow: 0 4px 16px rgba(255, 159, 67, 0.25);
}

.btn-update:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.text-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--accent);
    text-decoration: none;
}

.points-info {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.points-info h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.points-info ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.phone-display {
    margin-top: 12px;
}

.match-list,
.admin-match-list {
    display: grid;
    gap: 14px;
}

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

.match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--muted);
}

.match-countdown {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(245, 197, 66, 0.12);
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto;
}

.match-countdown-finished {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.match-countdown-live {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger);
}

.countdown-label {
    font-size: 0.85rem;
}

.team-slot-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 36px;
    border-radius: 4px;
    background: rgba(245, 197, 66, 0.15);
    color: var(--gold);
    font-weight: 800;
    font-size: 1.1rem;
}

.knockout-section {
    margin-bottom: 24px;
}

.knockout-section h3 {
    margin-top: 0;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 212, 126, 0.15);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-me {
    background: rgba(245, 197, 66, 0.15);
    color: var(--gold);
}

.badge-success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.badge-muted {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.badge-locked {
    background: rgba(255, 107, 107, 0.15);
    color: #ff8a8a;
}

.match-card-locked {
    border-color: rgba(255, 107, 107, 0.25);
}

.prediction-locked-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.prediction-locked-message {
    margin: 0 0 10px;
    color: #ff8a8a;
    font-size: 0.9rem;
    font-weight: 600;
}

.prediction-locked-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.prediction-locked-score strong {
    font-size: 1.5rem;
}

.match-predictions-list {
    margin-top: 12px;
}

.js-toggle-match-predictions {
    margin-top: 12px;
}

.match-predictions-title {
    margin: 0 0 10px;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
}

.match-predictions-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.match-prediction-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.match-prediction-row.is-me {
    border-color: rgba(245, 197, 66, 0.35);
    background: rgba(245, 197, 66, 0.08);
}

.match-prediction-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.match-prediction-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-prediction-score {
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
}

.match-predictions-empty,
.match-predictions-error {
    margin: 0;
    font-size: 0.85rem;
}

.match-predictions-error {
    color: #ff8a8a;
}

.match-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
}

.match-teams.compact {
    margin-bottom: 10px;
}

.team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.team img {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.vs {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.score-form {
    display: grid;
    gap: 12px;
}

.score-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
}

.score-inputs span {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.saved-hint {
    margin: 10px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.saved-hint-pending {
    color: var(--gold);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
}

.leaderboard {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.leader-row {
    display: grid;
    grid-template-columns: 36px 40px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.leader-row.is-me {
    border-color: rgba(245, 197, 66, 0.5);
    box-shadow: inset 0 0 0 1px rgba(245, 197, 66, 0.2);
}

.rank {
    font-weight: 800;
    color: var(--gold);
}

.leader-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-width: 0;
}

.points,
.points-big {
    font-weight: 800;
    color: var(--accent);
}

.points-big {
    font-size: 1.4rem;
    margin: 8px 0 0;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.08);
    font-weight: 700;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
}

.avatar-lg {
    width: 88px;
    height: 88px;
    font-size: 1.5rem;
}

.avatar-fallback {
    background: linear-gradient(135deg, #1f6b4f, #0d3b2c);
    color: var(--text);
}

.avatar-link {
    text-decoration: none;
}

.profile-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.prediction-history {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.prediction-history li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.prediction-history li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-teams {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 1.2rem;
    font-weight: 700;
}

.history-teams img {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border-radius: 2px;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.prediction-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.prediction-summary-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
}

.prediction-summary-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.1;
}

.prediction-summary-label {
    display: block;
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
}

.prediction-compact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.prediction-compact-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.prediction-compact-row.is-finished {
    border-left: 3px solid var(--accent);
}

.prediction-compact-row.is-pending {
    border-left: 3px solid var(--border);
    opacity: 0.92;
}

.prediction-compact-main {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
}

.prediction-compact-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.7rem;
    color: var(--muted);
}

.prediction-compact-meta time {
    font-weight: 600;
}

.badge-sm {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.prediction-points-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 76px;
    padding: 10px 8px;
    border-left: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.18);
    text-align: center;
}

.prediction-points-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

.prediction-points-label {
    margin-top: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.prediction-points-panel.is-exact {
    background: rgba(245, 197, 66, 0.12);
}

.prediction-points-panel.is-exact .prediction-points-value {
    color: var(--gold);
}

.prediction-points-panel.is-partial {
    background: rgba(74, 222, 128, 0.1);
}

.prediction-points-panel.is-partial .prediction-points-value {
    color: var(--accent);
}

.prediction-points-panel.is-zero .prediction-points-value {
    color: var(--muted);
}

.prediction-points-panel.is-pending .prediction-points-value {
    font-size: 1.4rem;
    color: var(--muted);
}

.prediction-points-panel.is-pending .prediction-points-label {
    font-size: 0.58rem;
    line-height: 1.2;
}

.prediction-compact-match {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}

.prediction-compact-team {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    font-weight: 600;
}

.prediction-compact-team:last-child {
    justify-content: flex-end;
    text-align: right;
}

.prediction-compact-team span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prediction-compact-team img {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.prediction-compact-scores {
    text-align: center;
    font-size: 0.85rem;
    white-space: nowrap;
}

.prediction-compact-result {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.user-admin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.user-admin-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.user-admin-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: grid;
    background: rgba(7, 24, 18, 0.95);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    z-index: 20;
}

.bottom-nav.nav-3 {
    grid-template-columns: repeat(3, 1fr);
}

.bottom-nav.nav-4 {
    grid-template-columns: repeat(4, 1fr);
}

.bottom-nav.nav-5 {
    grid-template-columns: repeat(5, 1fr);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--accent);
}

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

@media (min-width: 481px) {
    .app-shell {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
