:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #f43f5e;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --border: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Outfit', sans-serif; }

body {
    background-color: var(--bg);
    color: var(--text-main);
    transition: background 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Navigasjon */
.top-nav {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo { font-weight: 700; font-size: 1.2rem; letter-spacing: -0.5px; }
.icon-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

/* Hovedcontainer */
.app-container {
    flex: 1;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* Skjermhåndtering */
.screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}
.screen.active { display: block; }

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

/* UI Komponenter */
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; letter-spacing: -1px; }
h2 { font-size: 1.8rem; margin-bottom: 1rem; }
.subtext { color: var(--text-sub); margin-bottom: 2rem; }

.settings-grid {
    display: grid;
    gap: 24px;
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

label { font-weight: 500; display: flex; justify-content: space-between; margin-bottom: 12px; }
.badge { background: var(--primary); color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; }

input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }

select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-main);
    font-size: 1rem;
}

/* Segmented Control (Knapperad) */
.segmented-control {
    display: flex;
    background: var(--bg);
    padding: 4px;
    border-radius: 12px;
}
.seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-sub);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.seg-btn.active { background: var(--card-bg); color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Knapper */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    width: 100%;
    cursor: pointer;
    transition: transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); background: var(--primary-dark); }
.btn-secondary {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-sub);
    padding: 12px;
    border-radius: var(--radius);
    width: 100%;
    margin-top: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* KORT ANIMASJON (Viktig del av spillet) */
.card-container { perspective: 1000px; height: 300px; margin-bottom: 20px; cursor: pointer; }
.card {
    position: relative; width: 100%; height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card.flipped { transform: rotateY(180deg); }
.card-front, .card-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius);
    background: var(--card-bg);
    border: 1px solid var(--border);
}
.card-front { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.card-back { transform: rotateY(180deg); color: var(--text-main); padding: 20px; }
.card-icon { font-size: 4rem; margin-bottom: 1rem; animation: bounce 2s infinite; }

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.role-spy { color: var(--accent); font-weight: 800; font-size: 1.5rem; }
.role-word { font-size: 2rem; font-weight: 800; color: var(--primary); margin: 10px 0; }
.secret-label { font-size: 0.8rem; text-transform: uppercase; color: var(--text-sub); letter-spacing: 1px; }

/* Timer SVG */
.timer-container { position: relative; width: 120px; height: 120px; margin: 0 auto 24px; }
.timer-ring { transform: rotate(-90deg); }
.timer-ring-circle { transition: stroke-dashoffset 1s linear; color: var(--primary); }
.timer-ring-circle-bg { color: var(--border); }
.timer-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem; font-weight: 700;
}

/* Gameplay liste */
.game-info { background: var(--card-bg); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.category-tag { background: #e0e7ff; color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; display: inline-block; margin-bottom: 12px; }
[data-theme="dark"] .category-tag { background: rgba(99, 102, 241, 0.2); }
ul { list-style: none; text-align: left; margin-top: 10px; }
li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
li:last-child { border: none; }

/* Resultat */
.result-card { text-align: center; background: var(--card-bg); padding: 30px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid var(--border); }
.reveal-box { margin: 20px 0; padding: 20px; background: var(--bg); border-radius: var(--radius); }
#reveal-word { color: var(--primary); }
.hidden { visibility: hidden; opacity: 0; }

/* Mobil tilpasning */
@media (max-width: 400px) {
    h1 { font-size: 2rem; }
    .card-container { height: 260px; }
}
/* --- LEGG TIL / OPPDATER DISSE I CSS --- */

/* Fiks for Select på iPhone (Må ha tekststørrelse 16px+ for å ikke zoome, og webkit-appearance) */
select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-main);
    font-size: 16px; /* VIKTIG FOR IPHONE */
    -webkit-appearance: none; /* VIKTIG FOR IPHONE */
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Fiks for Slider på iPhone */
input[type="range"] {
    width: 100%;
    cursor: pointer;
    margin: 10px 0;
    -webkit-appearance: none; /* VIKTIG */
    background: transparent; 
}

/* Slider sporet */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: #e0e7ff;
    border-radius: 5px;
}
input[type="range"]::-webkit-slider-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: -8px; /* Juster midtstilling */
    -webkit-appearance: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Fiks for resultatskjermen (Luft rundt spionene) */
.spies-reveal {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.spies-reveal p {
    margin-bottom: 12px; /* Mer luft under teksten "Spionene var:" */
    font-weight: 600;
    color: var(--text-sub);
}

.avatar-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px; /* Luft mellom hver spion-brikke */
}