:root {
    --brand-orange: rgb(255, 120, 0);
    --bg-page: #000000;     
    --bg-panel: #000000;    
    --border-color: #1A3655;
    --brand-blue-glow: rgba(26, 54, 85, 0.7); 
    --text-main: #F5F5FA;   
    --text-muted: #B0C4DF;  
}

body { margin: 0; background: var(--bg-page); color: var(--text-main); font-family: system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* === TV-SKJERM (screen.html) === */
.tv-screen { aspect-ratio: 16 / 9; max-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; background: var(--bg-page); }
.tv-logo { width: 45vmin; height: auto; margin-bottom: 2vmin; }
.pin-container { text-align: center; }
.timer-section { text-align: center; margin-bottom: 4vmin; }
#timer-display { font-size: 15vmin; margin: 0; color: #FFFFFF; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 0 15px rgba(255, 255, 255, 0.4); }
#phase-name { font-size: 4vmin; color: var(--brand-orange); font-weight: bold; margin: 0; text-transform: uppercase; letter-spacing: 2px; }

.score-container { display: flex; width: 90%; max-width: 1600px; justify-content: center; gap: 4vmin; margin: 0 auto; transition: opacity 0.3s ease; }
.team { background: var(--bg-panel); border: 2px solid var(--border-color); border-radius: 2vmin; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4vmin 4vmin 6vmin 4vmin; box-shadow: 0 0 35px var(--brand-blue-glow), inset 0 0 20px rgba(26, 54, 85, 0.3); transition: opacity 0.3s ease, transform 0.3s ease; }
.team h2 { font-size: 6vmin; margin: 0 0 2vmin 0; width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.score-val { font-size: 28vmin; font-weight: bold; margin: 0; line-height: 1; display: inline-block; color: var(--text-main); font-variant-numeric: tabular-nums; }

/* === MOBIL-APP / PWA (PORTRETT / STANDARD) === */
.mobile-app { display: flex; flex-direction: column; min-height: 100vh; }
.app-header { background: var(--bg-page); text-align: center; padding: 1.5rem 0 1rem 0; z-index: 10; transition: all 0.3s ease; }
.app-logo { width: 140px; height: auto; display: inline-block; transition: all 0.3s ease; }

#app-content { flex: 1; padding-bottom: calc(75px + env(safe-area-inset-bottom)); width: 100%; }

.view-section { display: none; padding: 1rem 1rem 2rem 1rem; max-width: 1000px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.view-section.active { display: flex; flex-direction: column; align-items: center; }
.view-title { align-self: flex-start; color: var(--text-main); margin-top: 0; margin-bottom: 1rem; font-size: 1.6rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; width: 100%; }

.mobile-timer-section { text-align: center; margin-bottom: 2rem; margin-top: 1rem; transition: all 0.3s ease; }
.mobile-clock { font-size: 5rem; font-weight: bold; color: #FFFFFF; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 0 15px rgba(255, 255, 255, 0.4); margin:0; transition: font-size 0.3s ease; }
.mobile-phase { color: var(--brand-orange); font-size: 1.2rem; font-weight: bold; text-transform: uppercase; margin-top: 0.5rem; letter-spacing: 1px; transition: font-size 0.3s ease; }

.score-container-mobile { display: flex; flex-direction: column; width: 100%; gap: 1.5rem; transition: all 0.3s ease; }
.team-card { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 12px; width: 100%; max-width: 450px; padding: 1.5rem 1.5rem 2.5rem 1.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 0 25px var(--brand-blue-glow), inset 0 0 10px rgba(26, 54, 85, 0.3); box-sizing: border-box; margin: 0 auto; transition: all 0.3s ease, transform 0.3s ease; }
.team-name { font-size: 1.6rem; font-weight: bold; margin-bottom: 0.5rem; color: var(--text-main); word-break: break-word; line-height: 1.2; text-align: center; transition: font-size 0.3s ease; }
.team-score { font-size: 6rem; font-weight: bold; margin: 0; line-height: 1; color: var(--text-main); font-variant-numeric: tabular-nums; transition: font-size 0.3s ease; }

/* === INDIKATORER (Lineær rekke / Skalerbar Em) === */
.team-indicators { 
    display: flex; 
    flex-direction: row; 
    justify-content: center;
    background: #000000; 
    border: 1px solid var(--border-color);
    padding: 0.8em 1.2em; 
    border-radius: 2em; 
    gap: 2em; 
    transition: all 0.3s ease;
}
.stat-group { display: flex; flex-direction: column; align-items: center; gap: 0.6em; }
.stat-label { font-weight: 700; color: var(--text-main); font-size: 1em; text-transform: uppercase; letter-spacing: 1px; }
.stat-dots { display: flex; flex-direction: row; justify-content: center; gap: 0.4em; }
.ind-icon { width: 1.6em; height: 1.6em; object-fit: contain; }

/* Font-size baser for skalering av indicators */
.tv-screen .team-indicators { margin-top: 1.5em; font-size: 2.6vmin; padding: 1.2em 3.5em; gap: 3.5em; }
.mobile-app .team-indicators { margin-top: 1.2em; font-size: 0.85rem; }


/* =========================================================
   RESPONSIV LANDSKAPSMODUS (Mobil & Nettbrett) 
   ========================================================= */
@media (orientation: landscape) {
    .score-container-mobile {
        flex-direction: row;
        justify-content: center;
        gap: 3vmin;
    }

    .team-card {
        max-width: none;
        flex: 1;
        padding: 3vmin 3vmin 4vmin 3vmin;
        border-radius: 2vmin;
    }

    .mobile-timer-section { margin-bottom: 2vmin; margin-top: 0; }
    .mobile-clock { font-size: 14vmin; }
    .mobile-phase { font-size: 3.5vmin; margin-top: 0; }
    .team-name { font-size: 5vmin; margin-bottom: 1vmin; }
    .team-score { font-size: 22vmin; }
    .mobile-app .team-indicators { font-size: 2.2vmin; margin-top: 2vmin; padding: 1em 2.5em; gap: 2.5em; }

    @media (max-height: 600px) {
        .app-header { display: none; }
        .view-section { padding-top: 2vmin; }
    }
}


/* === FELLES ANIMASJONER === */
@keyframes scorePop {
    0% { transform: scale(1); color: inherit; }
    50% { transform: scale(1.3); color: var(--brand-orange); }
    100% { transform: scale(1); color: inherit; }
}
.score-pop { animation: scorePop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.timeout-active { color: #dc3545 !important; text-shadow: 0 0 20px rgba(220, 53, 69, 0.5) !important; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.7; } }

/* Tabeller & Oppsett */
.table-wrapper { width: 100%; overflow-x: auto; margin-bottom: 2rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-panel); }
.schedule-table { width: 100%; border-collapse: collapse; text-align: left; }
.schedule-table th, .schedule-table td { padding: 12px 10px; border-bottom: 1px solid var(--border-color); white-space: nowrap; font-size: 0.95rem; }
.schedule-table thead th { background: rgba(0,0,0,0.3); color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.schedule-table tbody th[scope="row"] { color: var(--brand-orange); font-variant-numeric: tabular-nums; font-weight: bold; background: rgba(0,0,0,0.1); }
.schedule-table tbody tr:last-child th, .schedule-table tbody tr:last-child td { border-bottom: none; }
.schedule-table .row-ongoing { background: rgba(220, 53, 69, 0.15); }
.schedule-table .res-col { font-weight: bold; font-size: 1.1rem; text-align: center; background: rgba(0,0,0,0.2); }

/* Kampreferat Lister */
h2 { align-self: flex-start; color: var(--text-main); margin-top: 1rem; margin-bottom: 1rem; font-size: 1.4rem; width: 100%; }
h3 { color: var(--brand-orange); font-size: 1.1rem; margin-top: 1.5rem; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }

ol.log-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.list-item { background: var(--bg-page); border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; display: flex; justify-content: space-between; align-items: center; }
.list-item-time { color: var(--text-muted); font-weight: normal; font-variant-numeric: tabular-nums; width: 60px; font-size: 0.9rem; }
.list-item-content { flex: 1; display: flex; flex-direction: column; }
.list-item-title { font-size: 1rem; }

.past-matches-details { background: transparent; width: 100%; margin-bottom: 20px; }
.past-matches-details summary { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; font-weight: bold; color: var(--text-main); cursor: pointer; outline: none; list-style: none; display: flex; align-items: center; }
.past-matches-details summary::-webkit-details-marker { display: none; }
.past-matches-details summary::before { content: "▾"; color: var(--brand-orange); font-size: 1.2em; margin-right: 10px; }
.past-matches-details[open] summary::before { content: "▴"; }
.past-matches-details .table-wrapper { margin-top: 10px; margin-bottom: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-top: none; }

.event-goal { border-left: 4px solid #ffc107; }
.event-timeout { border-left: 4px solid var(--text-muted); }
.event-penalty { border-left: 4px solid #dc3545; }
.event-sub { border-left: 4px solid #17a2b8; }
.no-data { text-align: center; color: var(--text-muted); font-size: 1.1rem; margin-top: 3rem; width: 100%; }

.bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; background: rgba(12, 30, 48, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border-color); box-shadow: 0 -4px 20px rgba(0,0,0,0.5); z-index: 1000; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.bottom-nav ul { list-style: none; padding: 0; margin: 0; display: flex; justify-content: space-around; align-items: center; }
.bottom-nav li { flex: 1; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--text-muted); font-size: 0.75rem; font-weight: 500; -webkit-tap-highlight-color: transparent; transition: color 0.2s ease; }
.bottom-nav .nav-icon { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s ease; }
.bottom-nav a[aria-current="page"] { color: var(--brand-orange); }
.bottom-nav a[aria-current="page"] .nav-icon { transform: scale(1.1); stroke-width: 2.5; }

/* --- DOM COURT SWITCHER (PILLE) --- */
.mobile-phase-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}
.court-pill {
    background: var(--bg-panel, #0C1E30);
    color: var(--brand-orange, #ff7800);
    border: 1px solid var(--brand-orange, #ff7800);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.court-pill:hover, .court-pill:focus {
    background: var(--brand-orange, #ff7800);
    color: var(--bg-page, #06111A);
    outline: none;
}
.court-pill svg {
    width: 14px;
    height: 14px;
}

/* Myk overgang for å bytte bane */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
}

/* === ANIMASJON FOR PARINGSSKJERM (PIN-KODE) === */
@keyframes gentlePulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

#pin-display {
    animation: gentlePulse 4s ease-in-out infinite;
    display: inline-block; /* Sikrer at transform-animasjonen fungerer jevnt */
}

/* Overskriver de gamle pill-stilsatte for et mer subtilt, klikkbart design */
.court-pill {
    background: transparent;
    color: var(--text-muted, #B0C4DF);
    border: 1px solid var(--border-color, #1A3655);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: normal; /* Gjør den mindre dominant */
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px; /* Mindre gap siden vi bruker tekstpil */
    box-shadow: none; /* Fjerner skitten skygge på mørk bakgrunn */
}

.court-pill:hover, .court-pill:focus {
    background: rgba(255, 255, 255, 0.05); /* Subtil lysning */
    color: var(--text-main, #F5F5FA);
    border-color: var(--text-muted, #B0C4DF);
    outline: none;
}

/* === SKARPE INDIKATORER (TIME-OUT / BYTTE) === */
.ind-dot {
    width: 1.6em;
    height: 1.6em;
    border-radius: 50%;
    display: inline-block;
}

.ind-dot.empty {
    border: 2px solid var(--border-color); /* Bruker merkets marineblå */
    background: rgba(26, 54, 85, 0.15); /* Svak blå fylling */
    box-sizing: border-box;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.8); /* Dyp innvendig skygge */
}

img.ind-icon {
    /* Får de aktive SVG-ene til å gløde og poppe ut av skjermen */
    width: 1.6em;
    height: 1.6em;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255, 120, 0, 0.6)); 
}

/* --- KAMPOPPSETT CAPTION --- */
.schedule-table caption {
    caption-side: top;
}
.schedule-date-header {
    font-size: 1.25rem;
    color: var(--brand-orange);
    margin: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}
