:root {
    --primary: #007AFF;
    --bg: #F2F2F7;
    --card-bg: #FFFFFF;
    --text: #1C1C1E;
    --text-sec: #8E8E93;
    --border: #C6C6C8;
    --danger: #FF3B30;
    --success: #34C759;
    --warning: #FF9500;
    --header-height: 150px;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding-top: calc(var(--header-height) + var(--safe-top));
    padding-bottom: calc(80px + var(--safe-bottom));
}

/* Header & Nav */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    padding-top: var(--safe-top);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.header-icon { height: 32px; width: auto; border-radius: 6px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; color: var(--text); }

.icon-btn {
    background: none; border: none; font-size: 24px; cursor: pointer; padding: 5px;
}

/* Search */
.search-container { padding: 0 16px 10px; }
#search-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #E3E3E8;
    font-size: 16px; /* Evita zoom en iOS */
}

/* Filters */
.filters-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filters-scroll::-webkit-scrollbar { display: none; }

select {
    appearance: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px 24px 6px 12px;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007AFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
}

/* Cards */
.match-list { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.card-header {
    display: flex; justify-content: space-between; margin-bottom: 8px;
    font-size: 12px; color: var(--text-sec); font-weight: 600; text-transform: uppercase;
}
.match-teams {
    font-size: 18px; font-weight: 700; margin-bottom: 4px; text-align: center;
}
.match-meta {
    text-align: center; font-size: 13px; color: var(--text-sec); margin-bottom: 12px;
}
.match-actions {
    display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 8px;
}

button {
    border: none; border-radius: 8px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-stream { background: #E5E5EA; color: var(--primary); }
.btn-stream:disabled { opacity: 0.5; color: var(--text-sec); }
.btn-map { background: #E5E5EA; color: var(--success); }
.btn-plan { background: var(--primary); color: white; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #E5E5EA; color: var(--text); }
.full-width { width: 100%; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; justify-content: center; align-items: flex-end; /* Bottom sheet on mobile */
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--card-bg);
    width: 100%; max-width: 600px;
    border-radius: 20px 20px 0 0;
    max-height: 90dvh;
    display: flex; flex-direction: column;
    animation: slideUp 0.3s ease-out;
}
@media(min-width: 600px) {
    .modal-overlay { align-items: center; }
    .modal-content { border-radius: 20px; }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
    padding: 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.close-modal {
    background: #E5E5EA; color: #8E8E93;
    width: 30px; height: 30px; border-radius: 50%;
    font-size: 20px; line-height: 1; padding: 0;
}
.modal-body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Helpers */
.help-list { list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.5; }
.help-list li { margin-bottom: 10px; }
.brand-sub { font-size: 12px; color: var(--text-sec); margin-bottom: 15px; font-style: italic; }
.tip-box { background: #fff3cd; padding: 10px; border-radius: 8px; font-size: 13px; color: #856404; margin-top: 15px;}

/* Timeline Styles */
.timeline-item {
    position: relative; padding-left: 20px; margin-bottom: 20px; border-left: 2px solid var(--border);
}
.timeline-item.travel { border-left: 2px dashed var(--border); margin-bottom: 10px; }
.t-time { font-size: 12px; font-weight: bold; color: var(--primary); }
.t-info { font-size: 14px; }
.tag-ok { color: var(--success); font-weight: bold; font-size: 12px; }
.tag-tight { color: var(--warning); font-weight: bold; font-size: 12px; }
.tag-imp { color: var(--danger); font-weight: bold; font-size: 12px; }

/* Fab */
.fab-prefs {
    position: fixed; bottom: calc(20px + var(--safe-bottom)); right: 20px;
    width: 50px; height: 50px; border-radius: 25px;
    background: var(--text); color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 24px; z-index: 900;
}

/* Form */
form label { display: block; margin-bottom: 15px; font-weight: 600; font-size: 14px; }
form input, form select { width: 100%; margin-top: 5px; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #f9f9f9; }

.hidden { display: none !important; }
