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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0d0d0d;
    color: #e0e0e0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========== HEADER ========== */
header {
    background: #111;
    padding: 12px 16px;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

header h1 {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.btn-icon {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: #fff;
    background: #222;
}

#btn-refresh {
    background: transparent;
    color: #e74c3c;
    border: 1.5px solid #e74c3c;
    padding: 7px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

#btn-refresh:hover {
    background: #e74c3c;
    color: #fff;
}

#btn-refresh:disabled {
    border-color: #333;
    color: #555;
    cursor: not-allowed;
    background: transparent;
}

/* ========== MAIN ========== */
main {
    padding: 12px;
    max-width: 640px;
    margin: 0 auto;
}

/* ========== LOADING ========== */
.hidden { display: none !important; }

.loading-section {
    text-align: center;
    padding: 80px 20px;
    color: #666;
}

.loading-section p {
    font-size: 0.85rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid #1a1a1a;
    border-top: 2.5px solid #e74c3c;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== AGENDA ========== */
.agenda-header {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 10px;
    text-align: center;
}

.agenda-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ========== MATCH LIST ========== */
.matches-list {
    background: #141414;
    border: 1px solid #1e1e1e;
    border-radius: 14px;
    overflow: hidden;
}

.match-card {
    display: flex;
    align-items: flex-start;
    padding: 14px 14px;
    border-bottom: 1px solid #1a1a1a;
    transition: background 0.15s;
}

.match-card:last-child {
    border-bottom: none;
}

.match-card:active {
    background: #1a1a1a;
}

.match-time {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    min-width: 42px;
    flex-shrink: 0;
    padding-top: 1px;
    font-variant-numeric: tabular-nums;
}

.match-flag {
    flex-shrink: 0;
    margin: 0 10px;
    display: flex;
    align-items: center;
}

.match-flag-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 2px;
}

.match-flag-emoji {
    font-size: 1.2rem;
    line-height: 1;
}

.match-info {
    flex: 1;
    min-width: 0;
}

.match-league {
    color: #777;
    font-size: 0.8rem;
    font-weight: 500;
}

.match-teams {
    color: #f0f0f0;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ========== CHANNEL LINKS ========== */
.match-channels {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.channel-link {
    color: #e74c3c;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: 6px;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.channel-link:hover {
    background: rgba(231, 76, 60, 0.18);
    border-color: rgba(231, 76, 60, 0.4);
}

.channel-link:active {
    background: rgba(231, 76, 60, 0.3);
    transform: scale(0.97);
}

/* ========== SETTINGS PANEL ========== */
.settings-panel {
    background: #111;
    border-bottom: 1px solid #1a1a1a;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { max-height: 0; opacity: 0; }
    to { max-height: 400px; opacity: 1; }
}

.settings-content {
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
}

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

.settings-header h3 {
    font-size: 0.95rem;
    color: #fff;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: #666;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}

.btn-close:hover {
    color: #fff;
    background: #222;
}

.settings-field {
    margin-bottom: 14px;
}

.settings-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 4px;
}

.settings-hint {
    font-size: 0.72rem;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.4;
}

.settings-input-row {
    display: flex;
    gap: 8px;
}

.settings-input-row input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #fff;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.settings-input-row input:focus {
    border-color: #e74c3c;
}

.settings-input-row button {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.settings-input-row button:hover {
    background: #c0392b;
}

.settings-input-row button:disabled {
    background: #333;
    cursor: not-allowed;
}

.settings-current {
    font-size: 0.78rem;
    color: #e74c3c;
    font-family: "SF Mono", "Menlo", monospace;
    word-break: break-all;
}

.settings-status {
    font-size: 0.75rem;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 6px;
}

.settings-status.success {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
}

.settings-status.error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* ========== ERROR ========== */
.error-section {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.error-section p {
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.error-section button {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========== WATCH PAGE ========== */
.back-link {
    color: #e74c3c;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.back-link:active {
    opacity: 0.7;
}

.watch-main {
    padding: 0;
    max-width: 100%;
}

.player-container {
    background: #000;
    aspect-ratio: 16/9;
    position: relative;
    width: 100%;
}

.stream-player {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
}

.error-msg {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.error-msg p {
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ========== RESPONSIVE: TABLET+ ========== */
@media (min-width: 480px) {
    header {
        padding: 14px 20px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    main {
        padding: 16px;
    }

    .match-card {
        padding: 16px 18px;
    }

    .match-time {
        font-size: 0.9rem;
        min-width: 48px;
    }

    .match-flag {
        margin: 0 12px;
    }

    .match-flag-img {
        width: 26px;
        height: 26px;
    }

    .match-teams {
        font-size: 0.92rem;
    }

    .channel-link {
        font-size: 0.78rem;
        padding: 6px 12px;
    }
}

/* ========== RESPONSIVE: DESKTOP ========== */
@media (min-width: 768px) {
    header {
        padding: 16px 24px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    #btn-refresh {
        padding: 8px 18px;
        font-size: 0.82rem;
    }

    main {
        padding: 20px;
        max-width: 700px;
    }

    .agenda-header {
        padding: 14px 24px;
        border-radius: 14px;
    }

    .agenda-header h2 {
        font-size: 1rem;
    }

    .matches-list {
        border-radius: 16px;
    }

    .match-card {
        padding: 18px 22px;
    }

    .match-card:hover {
        background: #181818;
    }

    .match-time {
        font-size: 0.95rem;
        min-width: 52px;
    }

    .match-flag {
        margin: 0 14px;
    }

    .match-flag-img {
        width: 28px;
        height: 28px;
    }

    .match-league {
        font-size: 0.85rem;
    }

    .match-teams {
        font-size: 0.95rem;
    }

    .channel-link {
        font-size: 0.8rem;
        padding: 6px 14px;
    }

    .watch-main {
        max-width: 900px;
        padding: 20px;
        margin: 0 auto;
    }

    .player-container {
        border-radius: 14px;
        overflow: hidden;
    }
}
