/* =========================================
   1. GLOBALA INSTÄLLNINGAR & LAYOUT
   ========================================= */
* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; padding: 20px; text-align: center;
    background-color: #f4f4f4; color: #333;
    transition: background 0.5s ease, color 0.5s ease;
    padding-top: 60px; /* Plats för menyn */
}

h1, h2, h3 { margin-bottom: 15px; color: inherit; }
a { color: #007bff; text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

/* Topplänkar */
.back-link, .admin-link {
    position: fixed; top: 10px; padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9); border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); font-size: 0.9rem;
    z-index: 100; color: #333; transition: transform 0.2s, top 0.5s ease;
}
.back-link { left: 10px; } .admin-link { right: 10px; }
.back-link:hover, .admin-link:hover { transform: scale(1.05); text-decoration: none; }

.container, .quiz-container {
    width: 100%; max-width: 700px; margin: 0 auto;
    background: #fff; padding: 25px; border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* =========================================
   2. KNAPPAR & INPUT
   ========================================= */
button {
    padding: 12px 20px; font-size: 1rem; cursor: pointer;
    border: none; border-radius: 6px; margin-top: 10px; width: 100%;
    transition: transform 0.1s;
}
button:active { transform: scale(0.98); }

.next-btn { background-color: #28a745; color: white; } /* Grön */
.delete-btn { background: #ff4d4d; color: white; width: auto; padding: 5px 10px; font-size: 0.9rem; } /* Röd */
.edit-btn { background: #ffc107; color: #333; width: auto; padding: 5px 10px; font-size: 0.9rem; margin-right: 5px; } /* Gul */

input, select {
    width: 100%; padding: 12px; border: 1px solid #ccc;
    border-radius: 6px; font-size: 1rem; margin-bottom: 15px;
}

/* Admin Tabell */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th, td { border-bottom: 1px solid #eee; padding: 12px; text-align: left; }
th { background: #f8f9fa; }

/* Admin Abuse Knapp (I Adminpanelen) */
.abuse-form {
    background: #ffe6e6; border: 2px solid red; padding: 20px;
    margin-bottom: 30px; border-radius: 8px; box-shadow: 0 4px 10px rgba(255,0,0,0.1);
}
.abuse-btn {
    background: repeating-linear-gradient(45deg, #d90000, #d90000 10px, #b30000 10px, #b30000 20px);
    color: white; font-weight: bold; font-size: 1.2rem; border: 3px solid #fff;
    box-shadow: 0 5px 15px rgba(255, 0, 0, 0.4); padding: 15px;
    text-transform: uppercase; letter-spacing: 1px; animation: pulse-btn 2s infinite;
    width: 100%; cursor: pointer;
}
.abuse-btn:hover { background: #ff0000; box-shadow: 0 5px 20px rgba(255, 0, 0, 0.6); }
@keyframes pulse-btn { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* =========================================
   3. ADMIN ABUSE BANNER (TOPPEN AV SIDAN)
   ========================================= */
#admin-abuse-banner {
    display: none; position: fixed; top: 0; left: 0; width: 100%;
    background: repeating-linear-gradient(45deg, #ff0000, #ff0000 10px, #cc0000 10px, #cc0000 20px);
    color: white; text-align: center; padding: 15px; font-weight: bold; font-size: 1.2rem;
    z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.5); text-shadow: 2px 2px 0 #000;
    animation: pulse-red 1s infinite; min-height: 60px;
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}

/* Justeringar när Abuse är aktivt */
body.admin-abuse-active { padding-top: 150px !important; }
body.admin-abuse-active .back-link,
body.admin-abuse-active .admin-link {
    top: 90px !important; /* Flytta ner knapparna */
}

/* =========================================
   4. MENY & LÄNKAR (STARTSIDAN)
   ========================================= */
.mode-link {
    display: block; background: #fff; color: #333; padding: 20px;
    margin: 15px 0; border-radius: 8px; font-weight: bold; font-size: 1.2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); transition: transform 0.2s; border: 1px solid #eee;
}
.mode-link:hover { transform: translateY(-3px); text-decoration: none; }

/* =========================================
   5. SPEL: FLASHCARDS
   ========================================= */
.card-container { perspective: 1000px; width: 100%; max-width: 450px; height: 280px; margin: 30px auto; }
.card {
    width: 100%; height: 100%; position: relative;
    transform-style: preserve-3d; transition: transform 0.6s; cursor: pointer;
}
.card-front, .card-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; display: flex; justify-content: center; align-items: center;
    font-size: 2rem; border-radius: 20px; padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); background: #fff;
}
.card-back { background-color: #4a90e2; color: white; transform: rotateY(180deg); }
.card.is-flipped { transform: rotateY(180deg); }

/* =========================================
   6. SPEL: MEMORY
   ========================================= */
.memory-board {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    width: 100%; max-width: 500px; margin: 20px auto; perspective: 1000px;
}
.memory-card {
    background-color: transparent; aspect-ratio: 1 / 1; border-radius: 8px;
    cursor: pointer; position: relative; transform-style: preserve-3d; transition: transform 0.5s;
}
.memory-card .card-face {
    position: absolute; width: 100%; height: 100%; top: 0; left: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    display: flex; justify-content: center; align-items: center;
    font-size: 0.9rem; padding: 5px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); word-wrap: break-word;
}
.memory-card .card-front { background: #fff; color: #333; transform: rotateY(180deg); }
.memory-card .card-back { background: #4a90e2; transform: rotateY(0deg); }
.memory-card.is-flipped { transform: rotateY(180deg); }
.memory-card.is-matched { transform: rotateY(180deg); cursor: default; }
.memory-card.is-matched .card-front { background: #d4edda; color: #155724; }

/* =========================================
   7. ÖVRIGA SPEL (Speed, Hangman, Scramble)
   ========================================= */
/* Quiz */
#swedish-word { font-size: 2.2rem; font-weight: bold; margin-bottom: 25px; color: #007bff; }
.correct { color: #28a745; font-weight: bold; }
.incorrect { color: #dc3545; font-weight: bold; }

/* Speed Quiz */
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 20px; }
.option-btn {
    background: #007bff; color: white; font-size: 1.1rem; padding: 20px;
    height: 100%; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer;
}
.option-btn:hover { background: #0056b3; }
.option-btn.correct { background: #28a745 !important; }
.option-btn.wrong { background: #dc3545 !important; opacity: 0.6; }

/* Hangman */
.hangman-word { font-size: 2.5rem; letter-spacing: 10px; font-family: monospace; margin: 30px 0; font-weight: bold; }
.keyboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.key-btn {
    width: 40px; height: 40px; background: #e0e0e0; border-radius: 4px;
    font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.key-btn:hover { background: #d0d0d0; }
.key-btn.used { background: #ccc; color: #888; cursor: default; }
.hangman-lives { font-size: 1.2rem; color: #dc3545; font-weight: bold; }

/* Scramble */
.scramble-box {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 60px;
    padding: 10px; border: 2px dashed #ccc; border-radius: 8px; margin-bottom: 20px;
}
.letter-tile {
    background: #ffc107; color: #333; padding: 10px 15px; font-size: 1.5rem;
    font-weight: bold; border-radius: 4px; cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); user-select: none;
}

/* Resultat */
#summary { display: none; }
#medal-message, #medal-msg { color: #FFD700; font-weight: bold; font-size: 1.4rem; margin-top: 15px; text-shadow: 1px 1px 2px rgba(0,0,0,0.2); }

/* =========================================
   8. BUTIK & CARD PACKS
   ========================================= */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 15px; }
.shop-item { background: #fff; border: 1px solid #ddd; padding: 15px; border-radius: 8px; }
.buy-btn { background-color: #28a745; color: white; }
.use-btn { background-color: #007bff; color: white; }
.active-btn { background-color: #17a2b8; color: white; cursor: default; }
.disabled-btn { background-color: #e2e6ea; color: #6c757d; cursor: not-allowed; }

/* Kortpaket */
.pack-item {
    background: #fff; border: 2px solid #ddd; padding: 20px; border-radius: 12px; 
    transition: transform 0.2s; position: relative; overflow: hidden; color: #333 !important;
}
.pack-item:hover { transform: scale(1.03); border-color: #007bff; }
.pack-icon { font-size: 3rem; display: block; margin-bottom: 10px; }
.pack-item h3, .pack-item p { color: #333 !important; }

/* Rariteter */
.rarity-common { border-color: #a0a0a0; background: #f0f0f0; color: #555 !important; }
.rarity-rare { border-color: #007bff; background: #e6f2ff; color: #0056b3 !important; }
.rarity-epic { border-color: #9b59b6; background: #f5eef8; color: #6c3483 !important; }
.rarity-legendary { 
    border-color: #ffd700; background: linear-gradient(135deg, #fffbe6, #fff4b3); 
    color: #b39500 !important; box-shadow: 0 0 15px #ffd700; animation: legendary-glow 2s infinite;
}
@keyframes legendary-glow { 0% { box-shadow: 0 0 10px #ffd700; } 50% { box-shadow: 0 0 25px #ffea00; } 100% { box-shadow: 0 0 10px #ffd700; } }

/* Overlay & Animation */
#pack-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 2000;
    justify-content: center; align-items: center; flex-direction: column;
}
.shaking-box { font-size: 8rem; cursor: pointer; animation: shake 0.5s infinite; }
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); } 20% { transform: translate(-3px, 0px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); } 100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.revealed-card {
    background: white; padding: 30px; border-radius: 15px; border: 4px solid #333;
    text-align: center; animation: pop-in 0.5s ease-out; width: 250px; color: #333 !important;
}
.revealed-icon { font-size: 5rem; display: block; margin-bottom: 10px; }
.revealed-name { font-size: 1.5rem; font-weight: bold; margin-bottom: 5px; color: #333 !important; }
@keyframes pop-in { 0% { transform: scale(0); opacity: 0; } 80% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }

/* Samling */
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; margin-top: 20px; }
.collection-item {
    background: #fff; border: 2px solid #ddd; border-radius: 8px; padding: 10px; text-align: center; 
    opacity: 0.5; filter: grayscale(1); transition: all 0.3s; color: #333 !important;
}
.collection-item.owned { opacity: 1; filter: grayscale(0); transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.collection-item .count {
    background: #333; color: white; border-radius: 50%; width: 25px; height: 25px;
    display: flex; justify-content: center; align-items: center; font-size: 0.8rem;
    position: absolute; top: -5px; right: -5px;
}
/* =========================================
   9. TEMAN & FONTS
   ========================================= */

/* --- Fonts --- */
/* (Notera: Fonterna laddas nu i header.php för bättre prestanda) */

body.font_pixel { 
    font-family: 'Press Start 2P', cursive; /* Detta namn måste matcha Google Fonts exakt */
    font-size: 0.7rem; 
    line-height: 1.6; 
}

body.font_pixel h1 { 
    text-transform: uppercase; 
    font-size: 1.2rem; 
}

body.font_pixel button, 
body.font_pixel .container { 
    border-radius: 0; 
    border: 2px solid #000; 
    box-shadow: 4px 4px 0 #000; 
}

body.font_hand { 
    font-family: 'Indie Flower', cursive; /* Detta namn måste matcha Google Fonts exakt */
    font-size: 1.3rem; 
    font-weight: bold; 
}

/* --- Bakgrunder --- */

/* Regnbåge */
@keyframes rainbow { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
body.bg_rainbow {
    background: linear-gradient(270deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #8b00ff);
    background-size: 400% 400%; animation: rainbow 10s ease infinite; color: white;
}
body.bg_rainbow .container, body.bg_rainbow .header { background: rgba(255,255,255,0.95); color: #333; }
body.bg_rainbow h1, body.bg_rainbow h2 { color: #333; }

/* Gamla Bakgrunder */
body.bg_default { background-color: #f4f4f4; }
body.bg_forest {
    background: linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.3)), url('https://images.unsplash.com/photo-1448375240586-882707db888b?auto=format&fit=crop&w=1000&q=80');
    background-size: cover; background-attachment: fixed; color: white;
}
body.bg_space {
    background: linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url('https://images.unsplash.com/photo-1454789548928-9efd52dc4031?auto=format&fit=crop&w=1000&q=80');
    background-size: cover; background-attachment: fixed; color: white;
}

/* Fix för mörka teman */
body.bg_forest .container, body.bg_space .container, body.bg_forest form, body.bg_space form {
    background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.2); color: white;
}
body.bg_forest .mode-link, body.bg_space .mode-link, body.bg_forest select, body.bg_space select, body.bg_forest .shop-item, body.bg_space .shop-item {
    background: rgba(255,255,255,0.9); color: #333;
}
body.bg_forest a, body.bg_space a { color: #80d4ff; } 
body.bg_forest a:hover, body.bg_space a:hover { color: #fff; }
body.bg_forest a.back-link, body.bg_space a.back-link, body.bg_forest a.admin-link, body.bg_space a.admin-link {
    background: #fff; color: #333;
}
body.bg_forest .card-front, body.bg_space .card-front { color: #333 !important; }