/* ═══════════════════════════════════════════════════════════════════════
   Kodknackaren — Mysteriet pa Kryptomuseet
   Komplett CSS — Dark futuristisk museumstema
   ═══════════════════════════════════════════════════════════════════════ */

/* ── CSS-variabler / Design tokens ──────────────────────────────────── */
:root {
    /* Bas */
    --bg-primary:       #0a0a1a;
    --bg-secondary:     #0f0f2a;
    --bg-surface:       rgba(15, 15, 42, 0.85);
    --bg-card:          rgba(255, 255, 255, 0.04);
    --bg-card-hover:    rgba(255, 255, 255, 0.08);
    --border-subtle:    rgba(255, 255, 255, 0.06);
    --border-medium:    rgba(255, 255, 255, 0.12);
    --border-strong:    rgba(255, 255, 255, 0.2);

    /* Typografi */
    --text-primary:     #e2e8f0;
    --text-secondary:   #94a3b8;
    --text-muted:       #64748b;
    --text-dim:         #475569;

    /* Accent */
    --accent-blue:      #3b82f6;
    --accent-purple:    #8b5cf6;
    --accent-cyan:      #22d3ee;
    --accent-green:     #00ff88;
    --accent-gold:      #fbbf24;
    --accent-red:       #ef4444;

    /* Vaningsfarger */
    --floor1-primary:   #d4a46a;
    --floor1-secondary: #8b6914;
    --floor1-bg:        rgba(212, 164, 106, 0.08);
    --floor1-glow:      rgba(212, 164, 106, 0.4);

    --floor2-primary:   #4a6741;
    --floor2-secondary: #5a6572;
    --floor2-bg:        rgba(74, 103, 65, 0.08);
    --floor2-glow:      rgba(74, 103, 65, 0.4);

    --floor3-primary:   #4a90b8;
    --floor3-secondary: #c44040;
    --floor3-bg:        rgba(74, 144, 184, 0.08);
    --floor3-glow:      rgba(74, 144, 184, 0.4);

    --floor4-primary:   #00ff88;
    --floor4-secondary: #1a1a2e;
    --floor4-bg:        rgba(0, 255, 136, 0.06);
    --floor4-glow:      rgba(0, 255, 136, 0.4);

    --floor5-primary:   #a855f7;
    --floor5-secondary: #22d3ee;
    --floor5-bg:        rgba(168, 85, 247, 0.08);
    --floor5-glow:      rgba(168, 85, 247, 0.4);

    /* Storlekar */
    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    16px;
    --radius-xl:    20px;
    --radius-round: 50%;

    /* Glass */
    --glass-bg:     rgba(15, 15, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur:   16px;

    /* Transitions */
    --transition-fast:   0.15s ease;
    --transition-medium: 0.3s ease;
    --transition-slow:   0.5s ease;

    /* Font stacks */
    --font-display: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
    --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}


/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Portal bar offset */
body.has-portal-bar #game-container {
    padding-top: 0;
}

::selection {
    background: rgba(139, 92, 246, 0.3);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}


/* ── Matrix Canvas Bakgrund ─────────────────────────────────────────── */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}


/* ── Game Container ─────────────────────────────────────────────────── */
#game-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


/* ── Skarmar ────────────────────────────────────────────────────────── */
.game-screen {
    display: none;
    flex: 1;
    min-height: 100vh;
    animation: screenFadeIn 0.4s ease-out;
}

.game-screen.active {
    display: flex;
    flex-direction: column;
}

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


/* ═══════════════════════════════════════════════════════════════════════
   STARTSKARM (#screen-menu)
   ═══════════════════════════════════════════════════════════════════════ */
#screen-menu {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.menu-content {
    max-width: 600px;
    width: 100%;
    text-align: center;
}


/* ── Titel (Glitch + Glow) ──────────────────────────────────────────── */
.title-block {
    margin-bottom: 40px;
}

.game-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 6vw, 3.8rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #fff;
    text-shadow:
        0 0 10px rgba(139, 92, 246, 0.5),
        0 0 40px rgba(139, 92, 246, 0.3),
        0 0 80px rgba(139, 92, 246, 0.15);
    position: relative;
    display: inline-block;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0%   { text-shadow: 0 0 10px rgba(139, 92, 246, 0.5), 0 0 40px rgba(139, 92, 246, 0.3), 0 0 80px rgba(139, 92, 246, 0.15); }
    100% { text-shadow: 0 0 20px rgba(59, 130, 246, 0.7), 0 0 60px rgba(59, 130, 246, 0.4), 0 0 100px rgba(34, 211, 238, 0.2); }
}

/* Glitch-effekt */
.glitch-text {
    position: relative;
}
.glitch-text span {
    position: relative;
    z-index: 1;
}
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    opacity: 0.8;
}
.glitch-text::before {
    color: var(--accent-cyan);
    z-index: 0;
    animation: glitchTop 3s ease-in-out infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}
.glitch-text::after {
    color: var(--accent-red);
    z-index: 0;
    animation: glitchBottom 2.5s ease-in-out infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitchTop {
    0%, 90%, 100% { transform: translate(0); }
    92%           { transform: translate(-3px, -1px); }
    94%           { transform: translate(3px, 1px); }
    96%           { transform: translate(-2px, 0); }
    98%           { transform: translate(2px, -1px); }
}
@keyframes glitchBottom {
    0%, 88%, 100% { transform: translate(0); }
    90%           { transform: translate(2px, 1px); }
    93%           { transform: translate(-3px, 0); }
    95%           { transform: translate(1px, -1px); }
    97%           { transform: translate(-1px, 1px); }
}

.game-subtitle {
    font-family: var(--font-display);
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 8px;
}

.title-line {
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-purple), var(--accent-cyan), transparent);
    margin: 16px auto 0;
    border-radius: 1px;
}


/* ── KRYPTO Intro ───────────────────────────────────────────────────── */
.krypto-intro {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 36px;
    text-align: left;
}

/* KRYPTO Robot Avatar */
.krypto-avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    position: relative;
    background: linear-gradient(135deg, #1e3a5f, #0f2440);
    border: 2px solid rgba(59, 130, 246, 0.4);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 15px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: kryptoPulse 4s ease-in-out infinite;
}

.krypto-avatar.small {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.krypto-face {
    position: relative;
    width: 36px;
    height: 28px;
}

.krypto-avatar.small .krypto-face {
    width: 26px;
    height: 20px;
}

.krypto-eye {
    position: absolute;
    top: 4px;
    width: 10px;
    height: 10px;
    background: var(--accent-cyan);
    border-radius: var(--radius-round);
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: kryptoBlink 4s ease-in-out infinite;
}
.krypto-eye.left  { left: 2px; }
.krypto-eye.right { right: 2px; }

.krypto-avatar.small .krypto-eye {
    width: 7px;
    height: 7px;
    top: 2px;
}

.krypto-mouth {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 3px;
    background: rgba(34, 211, 238, 0.5);
    border-radius: 2px;
}

.krypto-avatar.small .krypto-mouth {
    width: 10px;
    height: 2px;
}

.krypto-antenna {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 10px;
    background: rgba(59, 130, 246, 0.6);
}
.krypto-antenna::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -3px;
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: var(--radius-round);
    box-shadow: 0 0 10px var(--accent-blue);
    animation: antennaFlash 2s ease-in-out infinite;
}

@keyframes kryptoPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
    50%      { box-shadow: 0 0 25px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
}

@keyframes kryptoBlink {
    0%, 45%, 55%, 100% { transform: scaleY(1); }
    50%                { transform: scaleY(0.1); }
}

@keyframes antennaFlash {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

.krypto-bubble {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    position: relative;
    backdrop-filter: blur(var(--glass-blur));
    min-height: 80px;
}
.krypto-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 20px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--glass-border);
}

.krypto-name {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}

.typewriter-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    display: inline;
}

.typewriter-cursor {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    animation: cursorBlink 0.8s step-end infinite;
    font-weight: 700;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}


/* ── Menyknappar ────────────────────────────────────────────────────── */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

/* Generell knapp */
.btn {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 28px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    outline: none;
}
.btn:hover {
    transform: translateY(-2px);
}
.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-icon {
    font-size: 1.2em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: #fff;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-accent {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(168, 85, 247, 0.15));
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.25);
}
.btn-accent:hover {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(168, 85, 247, 0.25));
    border-color: rgba(34, 211, 238, 0.4);
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.15);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}
.btn-ghost:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-subtle);
}

.btn-back {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.85rem;
    border: 1px solid var(--border-subtle);
}
.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}
.btn-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* Neon glow-puls pa CTA-knapp */
.btn-glow {
    animation: buttonGlow 2.5s ease-in-out infinite alternate;
}
@keyframes buttonGlow {
    0%   { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3); }
    100% { box-shadow: 0 4px 35px rgba(139, 92, 246, 0.5), 0 0 60px rgba(139, 92, 246, 0.15); }
}


/* ── Agent Rank ─────────────────────────────────────────────────────── */
.agent-rank-display {
    margin-top: 12px;
}

.agent-rank {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    backdrop-filter: blur(var(--glass-blur));
}

.rank-badge {
    font-size: 1.6rem;
}

.rank-info {
    text-align: left;
}

.rank-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.rank-stars {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.star-count {
    color: var(--accent-gold);
    font-weight: 700;
}

.rank-progress-bar {
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.rank-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #f59e0b);
    border-radius: 2px;
    transition: width 0.5s ease;
}


/* ═══════════════════════════════════════════════════════════════════════
   MUSEIKARTAN (#screen-museum)
   ═══════════════════════════════════════════════════════════════════════ */
#screen-museum {
    padding: 0;
}

.museum-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    position: sticky;
    top: 0;
    z-index: 10;
}

body.has-portal-bar .museum-header {
    top: 48px;
}

.museum-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 2px;
    text-transform: uppercase;
    flex: 1;
}

.museum-stats {
    display: flex;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-icon {
    font-size: 1em;
}

.museum-building {
    flex: 1;
    display: flex;
    padding: 24px;
    gap: 24px;
    overflow-y: auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}


/* ── Hiss ────────────────────────────────────────────────────────────── */
.elevator-shaft {
    width: 48px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.elevator-car {
    width: 36px;
    height: 36px;
    margin: 0 auto 6px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
    /* Placera baserat pa --floor (5 vaningar, index 1-5) */
    transform: translateY(calc((5 - var(--floor)) * -100%));
}

.elevator-display {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}


/* ── Vaningar ────────────────────────────────────────────────────────── */
.floors-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.museum-floor {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    transition: all var(--transition-medium);
    position: relative;
}

.museum-floor.locked {
    opacity: 0.4;
    filter: grayscale(0.6);
    pointer-events: none;
}

.museum-floor.locked::after {
    content: 'LAST';
    position: absolute;
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Vanings-tema-farger */
.floor-antiken        { border-color: rgba(212, 164, 106, 0.2); background: var(--floor1-bg); }
.floor-antiken:hover  { border-color: rgba(212, 164, 106, 0.35); box-shadow: 0 0 30px rgba(212, 164, 106, 0.1); }

.floor-krigen         { border-color: rgba(74, 103, 65, 0.2); background: var(--floor2-bg); }
.floor-krigen:hover   { border-color: rgba(74, 103, 65, 0.35); box-shadow: 0 0 30px rgba(74, 103, 65, 0.1); }

.floor-kalla_kriget        { border-color: rgba(74, 144, 184, 0.2); background: var(--floor3-bg); }
.floor-kalla_kriget:hover  { border-color: rgba(74, 144, 184, 0.35); box-shadow: 0 0 30px rgba(74, 144, 184, 0.1); }

.floor-digitala       { border-color: rgba(0, 255, 136, 0.15); background: var(--floor4-bg); }
.floor-digitala:hover { border-color: rgba(0, 255, 136, 0.3); box-shadow: 0 0 30px rgba(0, 255, 136, 0.08); }

.floor-framtiden       { border-color: rgba(168, 85, 247, 0.2); background: var(--floor5-bg); }
.floor-framtiden:hover { border-color: rgba(168, 85, 247, 0.35); box-shadow: 0 0 30px rgba(168, 85, 247, 0.1); }

.floor-label {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    min-width: 32px;
}

.floor-number {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.floor-name {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Tema-specifika florlabel-farger */
.floor-antiken .floor-number,
.floor-antiken .floor-name    { color: var(--floor1-primary); }
.floor-krigen .floor-number,
.floor-krigen .floor-name     { color: var(--floor2-primary); }
.floor-kalla_kriget .floor-number,
.floor-kalla_kriget .floor-name { color: var(--floor3-primary); }
.floor-digitala .floor-number,
.floor-digitala .floor-name   { color: var(--floor4-primary); }
.floor-framtiden .floor-number,
.floor-framtiden .floor-name  { color: var(--floor5-primary); }

.floor-rooms {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}


/* ── Rum-dorrar ─────────────────────────────────────────────────────── */
.room-door {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-medium);
    position: relative;
    text-align: center;
}

.room-door.locked {
    cursor: not-allowed;
    opacity: 0.35;
}

.room-door.available {
    border-color: var(--border-medium);
    animation: doorPulse 3s ease-in-out infinite;
}

.room-door.available:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.room-door.completed {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.05);
}
.room-door.completed:hover {
    transform: translateY(-2px);
    background: rgba(34, 197, 94, 0.08);
}

/* Vaningsspecifika glod pa tillgangliga dorrar */
.floor-antiken .room-door.available        { box-shadow: 0 0 20px var(--floor1-glow); border-color: rgba(212, 164, 106, 0.3); }
.floor-krigen .room-door.available         { box-shadow: 0 0 20px var(--floor2-glow); border-color: rgba(74, 103, 65, 0.3); }
.floor-kalla_kriget .room-door.available   { box-shadow: 0 0 20px var(--floor3-glow); border-color: rgba(74, 144, 184, 0.3); }
.floor-digitala .room-door.available       { box-shadow: 0 0 20px var(--floor4-glow); border-color: rgba(0, 255, 136, 0.25); }
.floor-framtiden .room-door.available      { box-shadow: 0 0 20px var(--floor5-glow); border-color: rgba(168, 85, 247, 0.3); }

@keyframes doorPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(139, 92, 246, 0.1); }
    50%      { box-shadow: 0 0 25px rgba(139, 92, 246, 0.25); }
}

/* Dorr-frame visuell */
.door-frame {
    width: 56px;
    height: 72px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 2px solid var(--border-medium);
    border-radius: 28px 28px 4px 4px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-medium);
}

.room-door.available .door-frame {
    border-color: var(--border-strong);
}
.room-door.completed .door-frame {
    border-color: rgba(34, 197, 94, 0.4);
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.02));
}

.door-status-icon {
    font-size: 1.4rem;
}

.door-panel {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 24px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px 10px 2px 2px;
    background: rgba(255, 255, 255, 0.03);
}

.door-knob {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--text-dim);
    border-radius: var(--radius-round);
}

.room-door.available .door-knob {
    background: var(--accent-gold);
    box-shadow: 0 0 6px var(--accent-gold);
}

.door-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.door-name {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.door-cipher {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}


/* ── Stjarn-rating ──────────────────────────────────────────────────── */
.star-rating {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 4px;
}

.star {
    font-size: 0.9rem;
    transition: all var(--transition-medium);
}

.star.earned {
    color: var(--accent-gold);
    text-shadow: 0 0 6px rgba(251, 191, 36, 0.5);
    animation: starEarned 0.5s ease-out;
}

.star.empty {
    color: var(--text-dim);
    opacity: 0.3;
}

@keyframes starEarned {
    0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
    60%  { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}


/* ═══════════════════════════════════════════════════════════════════════
   RUMSVYN (#screen-room)
   ═══════════════════════════════════════════════════════════════════════ */
#screen-room {
    padding: 0;
}

/* ── Topbar ──────────────────────────────────────────────────────────── */
.room-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    flex-wrap: wrap;
}

.room-title-area {
    flex: 1;
    min-width: 150px;
}

.room-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.room-cipher-type {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.room-timer-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Timer ───────────────────────────────────────────────────────────── */
.timer-bar {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-green), #22c55e);
    border-radius: 3px;
    transition: width 1s linear, background 0.5s ease;
}

/* Farg-forandring nar tiden rinner ut */
.timer-fill.warning {
    background: linear-gradient(90deg, var(--accent-gold), #f59e0b);
}
.timer-fill.danger {
    background: linear-gradient(90deg, var(--accent-red), #dc2626);
    animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.timer-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 45px;
}

.room-star-goals {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.star-goal {
    white-space: nowrap;
}


/* ── Room layout (3-kolumner) ────────────────────────────────────────── */
.room-layout {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

/* ── Vanster panel: Ledtradar ────────────────────────────────────────── */
.room-clues-panel {
    padding: 20px;
    border-right: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
    overflow-y: auto;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clue-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.clue-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.clue-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}

.clue-item .clue-icon {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.clue-item .clue-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}


/* ── Mitten: Chiffer + Svar ──────────────────────────────────────────── */
.room-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    gap: 24px;
    overflow-y: auto;
}


/* ── Chiffer-display (terminal-stil) ─────────────────────────────────── */
.cipher-display {
    width: 100%;
    max-width: 640px;
}

.cipher-screen {
    background: #0c0c14;
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow:
        0 0 30px rgba(0, 255, 136, 0.05),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.cipher-screen-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cipher-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
}
.cipher-dot.red    { background: #ef4444; }
.cipher-dot.yellow { background: #f59e0b; }
.cipher-dot.green  { background: #22c55e; }

.cipher-screen-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-left: auto;
}

.cipher-text {
    font-family: var(--font-mono);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: 700;
    color: var(--accent-green);
    padding: 24px 20px;
    line-height: 1.8;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    min-height: 100px;
    word-break: break-all;
    position: relative;
}

.cipher-cursor {
    color: var(--accent-green);
    animation: cursorBlink 0.8s step-end infinite;
    font-weight: 400;
}


/* ── Svarsinput ──────────────────────────────────────────────────────── */
.answer-area {
    width: 100%;
    max-width: 640px;
}

.answer-input-group {
    display: flex;
    gap: 8px;
}

.answer-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
}
.answer-input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
}
.answer-input:focus {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.05);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}

.btn-check {
    padding: 14px 24px;
    white-space: nowrap;
}

.answer-feedback {
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 24px;
    text-align: center;
}

.answer-feedback.correct {
    color: #22c55e;
    animation: feedbackPop 0.4s ease-out;
}
.answer-feedback.incorrect {
    color: var(--accent-red);
    animation: feedbackShake 0.4s ease;
}

@keyframes feedbackPop {
    0%   { transform: scale(0.8); opacity: 0; }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes feedbackShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-5px); }
    80%      { transform: translateX(5px); }
}


/* ── Hint-trigger ────────────────────────────────────────────────────── */
.hint-trigger-area {
    margin-top: 8px;
}

.btn-hint {
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-gold);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 10px 20px;
    font-size: 0.85rem;
}
.btn-hint:hover {
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.35);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.1);
}

.hint-counter {
    background: rgba(251, 191, 36, 0.25);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-left: 4px;
}


/* ── Hoger panel: KRYPTO ─────────────────────────────────────────────── */
.room-krypto-panel {
    padding: 20px;
    border-left: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
    overflow-y: auto;
}

.krypto-assistant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.krypto-dialog-bubble {
    background: var(--bg-card);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    width: 100%;
}


/* ═══════════════════════════════════════════════════════════════════════
   DAGLIG UTMANING (#screen-daily)
   ═══════════════════════════════════════════════════════════════════════ */
.daily-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
}

.daily-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.daily-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.daily-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    padding: 32px 24px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.daily-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.daily-info {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.daily-leaderboard {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 20px;
}

.daily-leaderboard h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
}


/* ═══════════════════════════════════════════════════════════════════════
   SEGERRUTA (#screen-victory)
   ═══════════════════════════════════════════════════════════════════════ */
#screen-victory {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.victory-content {
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.victory-banner {
    margin-bottom: 36px;
}

.victory-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: victoryBounce 1s ease-out;
}

@keyframes victoryBounce {
    0%   { transform: scale(0) rotate(-20deg); }
    50%  { transform: scale(1.2) rotate(5deg); }
    70%  { transform: scale(0.95) rotate(-2deg); }
    100% { transform: scale(1) rotate(0); }
}

.victory-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 900;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
    letter-spacing: 2px;
}

.victory-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.victory-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.victory-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 12px;
}

.victory-stat-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.victory-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.victory-floor-summary {
    margin-bottom: 32px;
    text-align: left;
}

.victory-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}


/* ═══════════════════════════════════════════════════════════════════════
   DIALOG-OVERLAY (KRYPTO / CIPHER)
   ═══════════════════════════════════════════════════════════════════════ */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}
.dialog-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dialog-box {
    max-width: 560px;
    width: 92%;
    background: linear-gradient(145deg, #141430, #0d0d22);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(139, 92, 246, 0.1);
    animation: dialogSlideUp 0.4s ease-out;
}

@keyframes dialogSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-portrait {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

/* KRYPTO portrtt */
.dialog-portrait.krypto {
    background: linear-gradient(135deg, #1e3a5f, #0f2440);
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* CIPHER portrtt */
.dialog-portrait.cipher {
    background: linear-gradient(135deg, #3a0a0a, #1a0000);
    border: 2px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.dialog-content {
    text-align: center;
    width: 100%;
}

.dialog-speaker {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 10px;
}

.dialog-speaker.krypto { color: var(--accent-cyan); }
.dialog-speaker.cipher { color: var(--accent-red); }

.dialog-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.btn-dialog-continue {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    padding: 10px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
}
.btn-dialog-continue:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-strong);
}


/* ═══════════════════════════════════════════════════════════════════════
   HINT-PANEL (Slide-in fran hoger)
   ═══════════════════════════════════════════════════════════════════════ */
.hint-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    max-width: 90vw;
    background: linear-gradient(180deg, #12122a, #0a0a1a);
    border-left: 1px solid var(--border-medium);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    transform: translateX(0);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.hint-panel.hidden {
    transform: translateX(100%);
}

body.has-portal-bar .hint-panel {
    top: 48px;
}

.hint-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.hint-panel-header h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hint-panel-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hint-item {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-medium);
}

.hint-item.locked .hint-content {
    display: none;
}

.hint-item.revealed {
    border-color: rgba(251, 191, 36, 0.2);
    background: rgba(251, 191, 36, 0.03);
}

.hint-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.hint-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.hint-number {
    width: 24px;
    height: 24px;
    background: rgba(251, 191, 36, 0.12);
    border-radius: var(--radius-round);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-gold);
    flex-shrink: 0;
}

.hint-label {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.hint-cost {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.hint-content {
    padding: 0 14px 14px;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
}


/* ═══════════════════════════════════════════════════════════════════════
   VERKTYGSLADA (#toolbox)
   ═══════════════════════════════════════════════════════════════════════ */
.toolbox {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, #12122e, #0a0a1a);
    border-top: 1px solid var(--border-medium);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.toolbox.collapsed .toolbox-tray {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

.toolbox-tray {
    max-height: 200px;
    padding: 16px 20px;
    overflow-x: auto;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.toolbox-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}
.toolbox-handle:hover {
    background: rgba(255, 255, 255, 0.04);
}

.toolbox-icon {
    font-size: 1.1rem;
}

.toolbox-label {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.toolbox-chevron {
    font-size: 0.7rem;
    color: var(--text-dim);
    transition: transform 0.3s ease;
}

.toolbox.collapsed .toolbox-chevron {
    transform: rotate(180deg);
}

.tool-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}


/* ── Verktygskort ────────────────────────────────────────────────────── */
.tool-card {
    flex-shrink: 0;
    width: 130px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-medium);
    position: relative;
    overflow: hidden;
}

.tool-card.unlocked:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.tool-card.locked {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.tool-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.tool-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tool-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.tool-lock {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.8rem;
    opacity: 0.6;
}


/* ═══════════════════════════════════════════════════════════════════════
   VERKTYGS-MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.tool-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
    animation: fadeIn 0.2s ease;
}
.tool-modal.hidden { display: none; }

.tool-modal-content {
    width: 92%;
    max-width: 600px;
    max-height: 80vh;
    background: linear-gradient(145deg, #151530, #0d0d22);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.tool-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.tool-modal-header h3 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tool-modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}


/* ═══════════════════════════════════════════════════════════════════════
   NOTIFIKATIONER (#notification-toast)
   ═══════════════════════════════════════════════════════════════════════ */
.notification-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 400px;
}

.notification-toast.hidden {
    display: flex;
}

.notification-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.toast-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-gold);
}

.toast-message {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════
   TOPPLISTA-MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.leaderboard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 800;
    animation: fadeIn 0.2s ease;
}
.leaderboard-modal.hidden { display: none; }

.leaderboard-modal-content {
    width: 92%;
    max-width: 500px;
    max-height: 80vh;
    background: linear-gradient(145deg, #151530, #0d0d22);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.leaderboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-modal-header h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

.leaderboard-modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}


/* ═══════════════════════════════════════════════════════════════════════
   SPECIELLA EFFEKTER & ANIMATIONER
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Neon Glow ───────────────────────────────────────────────────────── */
.neon-glow {
    box-shadow:
        0 0 5px currentColor,
        0 0 15px currentColor,
        0 0 30px currentColor;
}

/* ── Framgangs-animation ─────────────────────────────────────────────── */
.success-animation {
    animation: successBurst 0.6s ease-out;
}

@keyframes successBurst {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.15); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ── Upplasnings-animation ───────────────────────────────────────────── */
.unlock-animation {
    animation: unlockShake 0.6s ease-out;
}

@keyframes unlockShake {
    0%         { transform: rotate(0); }
    15%, 45%   { transform: rotate(-8deg); }
    30%, 60%   { transform: rotate(8deg); }
    75%        { transform: rotate(-3deg); }
    100%       { transform: rotate(0); }
}

/* ── Dorr-oppning ────────────────────────────────────────────────────── */
.door-opening {
    animation: doorOpen 0.6s ease-out forwards;
}

@keyframes doorOpen {
    0%   { transform: perspective(400px) rotateY(0); }
    100% { transform: perspective(400px) rotateY(-90deg); opacity: 0; }
}

/* ── Confetti-liknande burst ─────────────────────────────────────────── */
@keyframes confettiFall {
    0%   { transform: translateY(-100px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Scan-line effekt (CRT terminal) ─────────────────────────────────── */
.cipher-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* ── Pulsande border ─────────────────────────────────────────────────── */
@keyframes borderPulse {
    0%, 100% { border-color: rgba(139, 92, 246, 0.2); }
    50%      { border-color: rgba(139, 92, 246, 0.5); }
}


/* ═══════════════════════════════════════════════════════════════════════
   UTILITY-KLASSER
   ═══════════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

.text-center { text-align: center; }
.text-left   { text-align: left; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 32px; }

.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 32px; }


/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIV DESIGN
   ═══════════════════════════════════════════════════════════════════════ */

/* Tablettar (1024px och nedot) */
@media (max-width: 1024px) {
    .room-layout {
        grid-template-columns: 1fr;
    }

    .room-clues-panel,
    .room-krypto-panel {
        border: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .room-clues-panel {
        order: 2;
    }
    .room-main {
        order: 1;
    }
    .room-krypto-panel {
        order: 3;
    }

    .daily-content {
        grid-template-columns: 1fr;
    }

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

/* Mindre skarmar (768px) */
@media (max-width: 768px) {
    .museum-building {
        flex-direction: column;
    }

    .elevator-shaft {
        display: none;
    }

    .museum-floor {
        flex-direction: column;
        gap: 12px;
    }

    .floor-label {
        writing-mode: horizontal-tb;
        transform: none;
        flex-direction: row;
    }

    .room-topbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .room-star-goals {
        display: none;
    }

    .victory-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .hint-panel {
        width: 100%;
        max-width: 100vw;
    }

    .floor-rooms {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .room-door {
        padding: 10px 8px;
    }

    .door-frame {
        width: 44px;
        height: 56px;
    }

    .door-name {
        font-size: 0.65rem;
    }

    .door-cipher {
        display: none;
    }
}

/* Mycket sma skarmar (480px) */
@media (max-width: 480px) {
    .game-title {
        letter-spacing: 1px;
    }

    .game-subtitle {
        letter-spacing: 1px;
        font-size: 0.75rem;
    }

    .menu-buttons {
        padding: 0 8px;
    }

    .floor-rooms {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }

    .door-frame {
        width: 36px;
        height: 48px;
    }

    .door-name {
        font-size: 0.6rem;
    }

    .tool-cards {
        gap: 8px;
    }

    .tool-card {
        width: 100px;
        padding: 10px;
    }

    .tool-icon {
        font-size: 1.4rem;
    }

    .tool-name {
        font-size: 0.65rem;
    }

    .tool-desc {
        display: none;
    }

    .cipher-text {
        font-size: 0.9rem;
        padding: 16px 14px;
        letter-spacing: 1px;
    }
}


/* ═══════════════════════════════════════════════════════════════════════
   EXTRA POLISH — Subtila detaljer for AAA-kansla
   ═══════════════════════════════════════════════════════════════════════ */

/* Laddnings-skeleton */
@keyframes shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* Focus-ringar for tillganglighet */
:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

/* Reducerad rorelse for tillganglighet */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    #matrix-bg {
        display: none;
    }
}

/* Printing — dolj allt overflidigt */
@media print {
    #matrix-bg,
    .toolbox,
    .hint-panel,
    .dialog-overlay,
    .notification-toast,
    .tool-modal,
    .leaderboard-modal,
    .portal-bar {
        display: none !important;
    }
}
