/* ==========================================================================
   FONTS I VARIABLES GLOBALS
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=IM+Fell+English+SC&family=IM+Fell+English:ital@0;1&family=Cinzel+Decorative:wght@700&family=Kalam:wght@400;700&display=swap');

:root {
    --bg-spring: #d6e8d0;
    --bg-summer: #f0e6c8;
    --bg-autumn: #e8d0b0;
    --bg-winter: #c8d8e8;
    --accent: #2c3e50;
    
    /* Fonts temàtiques: Estil Impremta Antiga i Mapes */
    --font-titles: 'IM Fell English SC', serif;
    --font-display: 'Cinzel Decorative', serif;
    --font-text: 'IM Fell English', serif;
    --font-notes: 'Kalam', cursive;
}

body {
    margin: 0;
    font-family: var(--font-text), 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background 1s ease;
    overflow: hidden;
    color: var(--accent);
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-image: url('img/light-paper-fibers.png');
    background-attachment: fixed;
    transition:
        background 1s ease,
        border-top-color 1s ease,
        filter 0.8s ease;
}

body.season-transition {
    filter: brightness(1.08) saturate(1.08);
}

/* Vignette permanent per immersió */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: radial-gradient(ellipse at center,
        transparent 55%,
        rgba(0,0,0,0.18) 80%,
        rgba(0,0,0,0.38) 100%
    );
}

/* ==========================================================================
   FONS DE PANTALLA AMB LES CARTES D'ESTACIÓ (Marca d'aigua)
   ========================================================================== */

/* 1. Assegurem que el contingut del joc quedi per sobre del fons */
#game-header, #game-container, #zoom-overlay, #discard-modal {
    position: relative;
    z-index: 10;
}

/* 2. Creem una capa virtual només per a la imatge de fons */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* Sota el joc, però sobre el color de fons del body */
    
    /* CONFIGURACIÓ VISUAL: Ajusta l'opacitat al teu gust */
    opacity: 0.15; /* 0.15 és un 15% visible. Puja-ho a 0.3 o 0.4 si ho vols més marcat */
    
    background-size: cover;
    background-position: top;
    background-repeat: no-repeat;
    
    /* Transició súper suau d'1.5 segons quan canvia l'estació */
    transition: background-image 1.5s ease-in-out; 
    
    pointer-events: none; /* Molt important: evita que la imatge bloquegi els clics als botons */
}

/* 3. Assignem la imatge corresponent a cada estació */
/* ATENCIÓ: Revisa que el nom de l'arxiu .jpg sigui exactament el que tens a la teva carpeta img/ */
.season-primavera::before {
    background-image: url('img/primavera.jpg'); 
}
.season-estiu::before {
    background-image: url('img/estiu.jpg');
}
.season-tardor::before {
    background-image: url('img/tardor.jpg');
}
.season-hivern::before {
    background-image: url('img/hivern.jpg');
}

/* Gradients i textures per estació */
.season-primavera { 
    background-color: var(--bg-spring);
    background: linear-gradient(135deg, #d6e8d0 0%, #b0ccaa 100%), url('img/light-paper-fibers.png'); 
    border-top: 20px solid #6a9a5a; 
}
.season-estiu { 
    background-color: var(--bg-summer);
    background: linear-gradient(135deg, #f0e6c8 0%, #d9c89a 100%), url('img/light-paper-fibers.png'); 
    border-top: 20px solid #b8860b; 
}
.season-tardor { 
    background-color: var(--bg-autumn);
    background: linear-gradient(135deg, #e8d0b0 0%, #c8a878 100%), url('img/light-paper-fibers.png'); 
    border-top: 20px solid #a0522d; 
}
.season-hivern { 
    background-color: var(--bg-winter);
    background: linear-gradient(135deg, #c8d8e8 0%, #9ab0c8 100%), url('img/light-paper-fibers.png'); 
    border-top: 20px solid #4a6a8a; 
}

/* ==========================================================================
   CAPÇALERA (Títol de l'Estació i Temps)
   ========================================================================== */
/* ==========================================================================
   CAPÇALERA (Títol de l'Estació i Temps)
   ========================================================================== */
#game-header {
    display: flex;
    justify-content: center; 
    align-items: center;
    padding: 15px 40px; /* Una mica més d'aire a dalt i a baix */
    position: relative; 
}

/* Nou disseny tipus "rètol" per al títol */
#game-header h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin: 0;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 3px;
    
    /* Noves propietats de fons i vora */
    padding: 10px 40px;
    border-radius: 15px;
    border: 3px solid transparent;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    transition: all 1s ease; /* Transició suau de colors al canviar d'estació */
}

/* Colors de fons dinàmics per al títol segons l'estació */
.season-primavera #current-season { 
    background-color: #b0ccaa;
    border-color: #6a9a5a;
}
.season-estiu #current-season { 
    background-color: #d9c89a;
    border-color: #b8860b;
}
.season-tardor #current-season { 
    background-color: #c8a878;
    border-color: #a0522d;
}
.season-hivern #current-season { 
    background-color: #9ab0c8;
    border-color: #4a6a8a;
}

#time-tracker {
    position: absolute;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#time-icons {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 5px;
}

.time-icon {
    font-size: 1.4rem;
    transition: opacity 0.4s ease, transform 0.4s ease, filter 0.4s ease;
    line-height: 1;
}

.time-icon--active {
    opacity: 1;
    transform: scale(1.05);
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.3));
}

.time-icon--empty {
    opacity: 0.4;
    transform: scale(0.95);
    filter: grayscale(60%);
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL DEL JOC
   ========================================================================== */
#game-container {
    display: flex;
    flex: 1; 
    padding: 0 20px 20px 20px;
    box-sizing: border-box;
    position: relative;
}

/* Ornaments als cantons del contenidor de joc */
#game-container::before,
#game-container::after {
    content: '✦';
    position: absolute;
    font-size: 1.4rem;
    color: var(--accent);
    opacity: 0.25;
    pointer-events: none;
}
#game-container::before { bottom: 24px; left: 28px; }
#game-container::after  { bottom: 24px; right: 28px; }

/* ==========================================================================
   PANELL ESQUERRE (Cartes de Decret i Guia)
   ========================================================================== */
/* ==========================================================================
   PANELL DE PUNTUACIÓ (Cartes de Decret)
   ========================================================================== */
#scoring-panel {
    /* Mides i posicionament (mantingues el que tinguessis d'amplada o padding) */
    width: 450px; 
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    
    /* ESBORREM la línia dashed clàssica */
    border-right: none; 
    
    /* 1. Afegim una ombra lateral per donar sensació de profunditat o "capa superior" */
    box-shadow: 10px 0 20px -5px rgba(0, 0, 0, 0.15);
    
    position: relative; /* Necessari per ancorar la nova línia */
    z-index: 10;        /* Assegura que l'ombra es vegi per sobre de la carta central */
}

/* 2. Creem una línia separadora elegant amb un element virtual (::after) */
#scoring-panel::after {
    content: '';
    position: absolute;
    top: 5%;         /* Deixa un xic d'aire a dalt */
    right: 0;        /* Es clava just a la vora dreta del panell */
    width: 4px;      /* Gruix de la línia */
    height: 90%;     /* No toca els extrems de la pantalla per ser més elegant */
    
    /* Degradat: Transparent a dalt -> Color d'accent al mig -> Transparent a baix */
    background: linear-gradient(to bottom, transparent, var(--accent), transparent);
    border-radius: 2px;
    opacity: 0.7;
}

/* GUIA DE PUNTUACIÓ (Resum 4 Estacions) */
#scoring-guide {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
    gap: 8px;
}

.guide-season {
    flex: 1;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.75);
    border: 2px solid transparent; 
    border-radius: 8px;
    padding: 5px 0;
    font-family: var(--font-titles);
    transition: all 0.3s ease;
    box-shadow: 1px 1px 5px rgba(0,0,0,0.1);
}

#guide-0 { border-top: 4px solid #6a9a5a; }
#guide-1 { border-top: 4px solid #b8860b; }
#guide-2 { border-top: 4px solid #a0522d; }
#guide-3 { border-top: 4px solid #4a6a8a; }

.guide-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #555;
    letter-spacing: 0.5px;
}

.guide-letters {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.guide-season.active-guide {
    background-color: white; 
    border-color: var(--accent); 
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
}

/* GRAELLA DE DECRETS 2x2 */
.grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 0;
    width: 100%;
}

.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease, filter 0.5s ease, opacity 0.5s ease;
}

.card-slot .label {
    margin-bottom: 8px;
    font-weight: bold;
}

.card-slot.inactive {
    filter: grayscale(100%) brightness(70%);
    opacity: 0.6;
}

.card-slot.active-decree {
    filter: grayscale(0%) brightness(100%);
    opacity: 1;
    animation: decreeGlow 2.5s ease-in-out infinite;
}

.card-slot img {
    width: 100%;
    border-radius: 10px;
    transition: transform 0.3s ease, filter 0.3s ease, box-shadow 0.3s ease; 
}

.card-slot img:hover {
    transform:
        translateY(-4px)
        rotate(-0.5deg)
        scale(1.04);

    transition: transform 0.25s ease;
}

.card-slot.active-decree img {
    transform: scale(1.03); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.3); 
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6)); 
}


@keyframes decreeGlow {
    0%   { filter: brightness(1); }
    50%  { filter: brightness(1.08); }
    100% { filter: brightness(1); }
}
/* ==========================================================================
   PANELL DRET (Carta d'Exploració i Controls)
   ========================================================================== */
/* ==========================================================================
   PANELL D'EXPLORACIÓ I CONTROLS (Disseny a la dreta)
   ========================================================================== */

/* El panell ara fa servir un disseny en fila (row) en lloc de columna */
#exploration-panel {
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 30px;
    box-sizing: border-box;
}

/* El contenidor de la carta ocupa tot l'espai central disponible */
.exploration-display {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.exploration-display::after {
    content: '';
    position: absolute;
    bottom: -18px;
    width: 55%;
    height: 30px;
    background: radial-gradient(
        ellipse at center,
        rgba(0,0,0,0.35) 0%,
        rgba(0,0,0,0) 70%
    );
    filter: blur(8px);
    z-index: -1;
}


/* Fem la carta molt més gran aprofitant el nou espai! */
#current-exploration-card {
    height: auto;
    max-height: 75vh; /* Pot ocupar fins al 75% de l'alçada de la pantalla */
    max-width: 100%;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

/* Els botons es col·loquen a la dreta, apilats un sota l'altre */
.controls {
    display: flex;
    flex-direction: column; /* Columna vertical */
    gap: 20px; /* Espai entre botons */
    margin-left: 40px; /* Distància respecte la carta */
    min-width: 220px; /* Una amplada base perquè quedin uniformes */
}

/* ==========================================================================
   BOTONS ESTIL "COMPONENTS DE JOC"
   ========================================================================== */
.controls button {
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 5px;
    
    /* Tipografia */
    font-family: var(--font-titles);
    font-size: 1.1rem;
    color: #4a342e; /* Marró fosc tipus tinta antiga */
    text-transform: uppercase;
    letter-spacing: 1px;
    
    /* Fons i Forma (Efecte pergamí/cuir clar) */
    background: linear-gradient(145deg, #fdfbf7, #e6dec9);
    border: 2px solid #8d6e63;
    border-radius: 4px; /* Vores gairebé rectes per semblar més seriós */
    
    /* Ombra per donar volum com si fos una peça física */
    box-shadow: 
        0 4px 0 #8d6e63,             /* Gruix del botó */
        0 6px 10px rgba(0,0,0,0.3);  /* Ombra sobre el tauler */
    
    cursor: pointer;
    transition: all 0.1s ease;
    position: relative;
    overflow: hidden;
}

/* Efecte en passar el ratolí (Hover) */
.controls button:hover {
    background: linear-gradient(145deg, #fffcf5, #ede6d5);
    transform: translateY(-2px); /* S'aixeca una mica */
    box-shadow: 
        0 6px 0 #8d6e63, 
        0 8px 15px rgba(0,0,0,0.4);
    color: #000;
}

/* Efecte en clicar (Click / Active) - Simula que el botó s'enfonsa */
.controls button:active {
    transform: translateY(4px); /* Baixa fins al nivell de la taula */
    box-shadow: 0 0px 0 #8d6e63, 0 2px 5px rgba(0,0,0,0.2);
}

#next-btn {
    background: linear-gradient(145deg, #d7ccc8, #a1887f);
    color: #fff;
    border-color: #5d4037;
    box-shadow: 0 4px 0 #5d4037, 0 6px 10px rgba(0,0,0,0.3);
    animation: nextPulse 2.8s infinite;
}

@keyframes nextPulse {
    0% {
        box-shadow:
            0 4px 0 #5d4037,
            0 0 0 rgba(255,255,255,0);
    }

    50% {
        box-shadow:
            0 4px 0 #5d4037,
            0 0 18px rgba(255,255,255,0.25);
    }

    100% {
        box-shadow:
            0 4px 0 #5d4037,
            0 0 0 rgba(255,255,255,0);
    }
}

#next-btn:hover {
    background: linear-gradient(145deg, #e1d5d2, #b49e95);
    box-shadow: 0 6px 0 #5d4037, 0 8px 15px rgba(0,0,0,0.4);
}

#next-btn:active {
    box-shadow: 0 0px 0 #5d4037, 0 2px 5px rgba(0,0,0,0.2);
}

/* Botó de reiniciar (més discret a baix de tot) */
#restart-btn {
    margin-top: 20px;
    font-size: 0.8rem;
    opacity: 0.8;
}

#ruins-indicator, #monster-indicator {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
    border: 2px solid gold;
    animation: popIn 0.3s ease-out;
}

#monster-indicator {
    border-color: #ff5252;
    color: #ff5252;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.hidden {
    display: none !important;
}



/* ==========================================================================
   FINESTRES MODALS (Zoom i Descart)
   ========================================================================== */
#zoom-overlay, #discard-modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.85); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999; 
    opacity: 1;
    transition: opacity 0.3s ease;
}

#zoom-overlay {
    pointer-events: none; /* El ratolí ignora aquesta capa */
    opacity: 0;
}

#zoom-overlay.active { opacity: 1; pointer-events: auto; cursor: pointer; }
.zoom-hidden, .modal-hidden { opacity: 0 !important; pointer-events: none !important; }

#zoom-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#zoom-overlay.active #zoom-img {
    transform: scale(1);
}

/* Descart Modal */
.modal-content {
    background-color: #fdfbf7; 
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    border: 4px solid var(--accent);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#discard-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

#discard-grid img {
    height: 200px; 
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close-btn {
    background-color: var(--accent);
}

/* SWAL ALERTS */
body.monster-alert {
    background-color: #3a1010 !important;
    border-top: 20px solid #8b1a1a !important;
    transition: background-color 1.2s ease, border-top-color 1.2s ease !important;
    animation: monsterShake 0.45s ease;
}

@keyframes monsterShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

body.monster-alert::after {
    background: radial-gradient(ellipse at center,
        transparent 30%,
        rgba(120, 0, 0, 0.25) 65%,
        rgba(80, 0, 0, 0.55) 100%
    );
}

.swal2-container {
    z-index: 2147483647 !important;
}

.medieval-popup {
    border: 3px solid var(--accent);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.medieval-title {
    font-family: var(--font-titles) !important;
    text-transform: uppercase;
    color: var(--accent);
}

.swal2-title {
    font-family: var(--font-display) !important;
    letter-spacing: 1px;
}

.swal2-html-container {
    font-family: var(--font-text) !important;
    font-size: 1.15rem !important;
}

.swal2-popup {
    border-radius: 18px !important;
    border: 3px solid rgba(44,62,80,0.15) !important;
    box-shadow: 0 25px 60px rgba(0,0,0,0.45) !important;
    width: 850px !important;
    max-width: 90vw !important;
}

.swal2-confirm, .swal2-cancel {
    border-radius: 10px !important;
    font-family: var(--font-titles) !important;
    letter-spacing: 1px;
}

/* ==========================================================================
   MILLORES DE ZOOM (Imatge + Text)
   ========================================================================== */
#zoom-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 40px;
    max-width: 85%;
    background: url('img/light-paper-fibers.png'), #fdfbf7;
    padding: 40px;
    border-radius: 10px;
    border: 8px double var(--accent);
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

#zoom-close-btn {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #a04000;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    z-index: 1;
}
#zoom-close-btn:hover {
    background: rgba(160, 64, 0, 0.12);
    color: #6b2900;
}

#zoom-overlay.active #zoom-content {
    transform: scale(1);
}

#zoom-img {
    height: 70vh; /* La imatge s'ajusta a l'alçada de la pantalla */
    width: auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

#zoom-card-letter {
    font-family: var(--font-titles);
    font-size: 3rem;
    color: #a04000; /* Color granat/marró tipus segell */
    border: 3px solid #a04000;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 10px;
    background-color: rgba(160, 64, 0, 0.1);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    font-weight: bold;
}

/* Ajustem una mica el contingut per donar espai */
#zoom-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Alineat a l'esquerra */
    flex: 1;
    max-width: 400px;
}
#zoom-card-name {
    font-family: var(--font-titles);
    font-size: 2.2rem;
    margin: 0 0 10px 0;
    color: #4e342e;
}

#zoom-card-ambient {
        font-family: var(--font-text);
        font-size: 1.15rem;
        color: #4a5568; 
        font-style: italic;
        margin: 20px 0 0 0; /* 20px d'espai per sobre per separar-ho de les regles */
        line-height: 1.3;
        text-align: center;
        font-style: italic;
}

.divider {
    height: 2px;
    background: linear-gradient(to right, #4e342e, transparent);
    margin-bottom: 20px;
}

#zoom-card-description {
    font-size: 1.4rem;
    line-height: 1.6;
    font-style: italic;
    color: #2c3e50;
}

/* Millora del rètol de l'estació (més profunditat) */
#game-header h1 {
    box-shadow: 0 8px 0 rgba(0,0,0,0.1), inset 0 2px 5px rgba(255,255,255,0.5);
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
}
/* ==========================================================================
   PANTALLA D'INTRODUCCIÓ
   ========================================================================== */
#intro-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        url('img/light-paper-fibers.png'),
        linear-gradient(135deg, #2c1f10 0%, #1a1108 100%);
    transition: opacity 1s ease;
}

#intro-overlay::before {
    content: '';
    position: absolute;
    inset: 0;

    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.05), transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.03), transparent 25%);

    animation: fogMove 18s linear infinite;
}

@keyframes fogMove {
    from { transform: translateX(0); }
    to   { transform: translateX(-40px); }
}


#intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#intro-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 900px;
    width: 90%;
    text-align: center;
    padding: 40px;
    border: 3px double #8d6e3a;
    border-radius: 4px;
    background: rgba(253, 248, 235, 0.07);
    box-shadow: 0 0 60px rgba(0,0,0,0.6), inset 0 0 40px rgba(0,0,0,0.2);
}

#intro-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    color: #d4a84b;
    margin: 0;
    text-shadow: 0 0 30px rgba(212, 168, 75, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 6px;
}

/* ==========================================================================
   IMATGE DEL TÍTOL (Pantalla Inicial)
   ========================================================================== */
#intro-title-img {
    max-width: 550px;  
    max-height: 250px;    /* Limitem l'alçada perquè no tapi la resta del text */
    width: auto;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 10px;
    /* Opcional: Afegeix una mica d'ombra perquè ressalti sobre el fons */
    filter: drop-shadow(0px 8px 10px rgba(0, 0, 0, 0.4));
}

#intro-subtitle {
    font-family: var(--font-titles);
    font-size: 1.5rem;
    color: #1a252f; /* Color més fosc per la textura */
    font-weight: 700;
    margin-bottom: 10px;
    margin-top:0px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0px 0px 2px rgba(255,255,255,0.7); /* Petit halo blanc */
}

#intro-text-box {
    max-width: 850px;
    min-height: 80px;
    padding: 20px 30px;
    background: rgba(0,0,0,0.25);
    border-radius: 4px;
    border: 1px solid rgba(212, 168, 75, 0.3);
}

#intro-text {
    font-family: var(--font-notes);
    font-size: 1.25rem;
    color: #e8d9b0;
    line-height: 1.8;
    margin: 0;
    display: inline;
}

#intro-cursor {
    font-family: var(--font-notes);
    font-size: 1.25rem;
    color: #d4a84b;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Decrets de la intro --- */
#intro-decrees {
    width: 100%;
}

#intro-decrees-title {
    font-family: var(--font-titles);
    font-size: 1.3rem;
    margin-bottom: 10px;
    margin-top:10px;
    color: #1a252f; /* Color més fosc per la textura */
    font-weight: 700;
    text-shadow: 0px 0px 2px rgba(255,255,255,0.7); /* Petit halo blanc */
}

#intro-decrees-title::after {
    content: " (clica per ampliar)";
    font-family: var(--font-notes);
    font-size: 0.9rem;
    /*color: #666;*/
    display: block;
    font-weight: normal;
    margin-top: 5px;
    text-shadow: none;
}

#intro-cards-row {
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Contenidor de la carta amb perspectiva per al flip */
.intro-decree-card {
    width: 100px;
    height: 140px;
    perspective: 1000px;
    cursor: pointer; /* Indica que es pot clicar */
    transition: transform 0.3s ease; /* Transició suau */
}

/* Efecte en passar el ratolí */
.intro-decree-card:hover {
    transform: scale(1.1);
    z-index: 10;
}

.intro-decree-card.card-dropped {
    opacity: 1;
    transform: translateY(0);
}

/* Cara interior que fa el flip */
.intro-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.intro-decree-card.card-flipped .intro-card-inner {
    transform: rotateY(180deg);
}

.intro-card-front,
.intro-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Dors de la carta — estil pergamí fosc */
.intro-card-back {
    background: 
        url('img/light-paper-fibers.png'),
        linear-gradient(145deg, #5a3e28, #3a2010);
    border: 2px solid #8d6e3a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.intro-card-back::after {
    content: '👑';
    font-size: 2.5rem;
    opacity: 0.5;
}

/* Cara de la carta */
.intro-card-front {
    transform: rotateY(180deg);
    background: #fdfbf7;
    border: 2px solid #8d6e3a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    gap: 6px;
    box-sizing: border-box;
}

.intro-card-letter {
    font-family: var(--font-display);
    font-size: 1rem;
    color: #a04000;
    border: 2px solid #a04000;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(160,64,0,0.08);
    flex-shrink: 0;
}

.intro-card-front img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    border-radius: 4px;
    min-height: 0;
}

.intro-card-name {
    font-family: var(--font-titles);
    font-size: 0.65rem;
    color: #4e342e;
    text-align: center;
    line-height: 1.2;
}

/* Botó de començar */
#intro-start-btn {
    font-family: var(--font-display);
    font-size: 1.1rem;
    padding: 14px 40px;
    background: linear-gradient(145deg, #8d6e3a, #5a3e18);
    color: #f5e6c0;
    border: 2px solid #d4a84b;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 2px;
    box-shadow: 0 4px 0 #3a2010, 0 6px 15px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
    animation: fadeInUp 0.6s ease forwards;
}

#intro-start-btn:hover {
    background: linear-gradient(145deg, #a07840, #6a4e28);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #3a2010, 0 8px 20px rgba(0,0,0,0.5);
}

#intro-start-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #3a2010;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE MÒBIL
   ========================================================================== */
@media (max-width: 768px) {

    body {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh;
        scroll-behavior:smooth;
    }

    body::after {
        position: fixed;
    }

    /* --- Header --- */
    #game-header {
        flex-direction: column;
        align-items: center;
        padding: 12px 16px;
        gap: 10px;
    }

    #intro-title-img {
        max-width: 300px;  
    }

    #game-header h1 {
        font-size: 1rem;
        padding: 8px 20px;
        letter-spacing: 2px;
    }

    #time-tracker {
        position: static !important;
        width: 100%;
        align-items: center;
    }

    #time-icons {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .time-icon {
        font-size: 1.3rem;
    }

    /* --- Layout principal: columna --- */
    #game-container {
        flex-direction: column !important;
        gap: 16px;
    }

    #game-container::before,
    #game-container::after {
        display: none;
    }

    /* --- Panell d'exploració --- */
    #exploration-panel {
        flex-direction: column !important;
        align-items: center;
        padding: 0;
        gap: 16px;
        width: 100%;
        order: 1;
    }

    .exploration-display {
        width: 100%;
    }

    #current-exploration-card {
        height: auto;
        max-height: 45vh;
        max-width: 100%;
        width: auto;
        border-radius: 18px;
        border: 3px solid rgba(255,255,255,0.18);
        box-shadow:
            0 25px 40px rgba(0,0,0,0.45),
            0 0 0 1px rgba(255,255,255,0.08),
            inset 0 1px 0 rgba(255,255,255,0.12);
        transition:
            transform 0.3s ease,
            box-shadow 0.3s ease;
    }

    #current-exploration-card:hover {
        transform: translateY(-4px) scale(1.01);
        box-shadow:
            0 35px 50px rgba(0,0,0,0.55),
            0 0 0 1px rgba(255,255,255,0.12),
            inset 0 1px 0 rgba(255,255,255,0.2);
    }

    #ruins-indicator, #monster-indicator {
        font-size: 1rem;
        padding: 8px 14px;
    }

    /* --- Botons en graella 2x2 --- */
    .controls {
        flex-direction: row !important;
        flex-wrap: wrap;
        margin-left: 0 !important;
        min-width: unset !important;
        width: 100%;
        gap: 10px;
        justify-content: center;
    }

    .controls button {
        flex: 1;
        min-width: 0;
        font-size: 0 !important;
        padding: 0px 15px;
    }

    .controls button::before {
        font-size: 1.8rem !important;
        margin-right: 0;
    }
    .controls button {
        display: flex;
        justify-content: center;
        align-items: center;
        padding-left: 0;
        padding-right: 0;
    }
    /* Amaguem NOMÉS el text */
    .controls button .btn-text {
        display: none;
    }
    /* Ens assegurem que la icona es vegi centrada i gran */
    .controls button .btn-icon {
        display: block;
        font-size: 1.5rem;
    }

    #restart-btn {
        margin-top: 0;
    }

    /* --- Panell de decrets: fila horitzontal a baix --- */
    #scoring-panel {
        width: 100% !important;
        order: 2;
        box-shadow: none;
        border-top: 2px solid rgba(44, 62, 80, 0.2);
        padding: 12px 8px;
        backdrop-filter: blur(4px);
        background: rgba(255,255,255,0.08);
        border-radius: 16px;
    }

    #scoring-panel::after {
        display: none;
    }

    #scoring-guide {
        gap: 5px;
        margin-bottom: 12px;
    }

    .guide-name {
        font-size: 0.6rem;
    }

    .guide-letters {
        font-size: 1rem;
    }

    .cards-container.grid-2x2 {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px;
    }

    .card-slot .label {
        font-size: 0.7rem;
        margin-bottom: 4px;
    }

    .card-slot.active-decree img {
        transform: scale(1.02);
    }

    #season-message {
        font-size: 0.85rem;
    }

    /* --- Zoom: adaptat per touch --- */
    #zoom-content {
        flex-direction: column;
        max-width: 92vw;
        padding: 20px;
        gap: 16px;
    }

    #zoom-img {
        height: 35vh;
        width: auto;
    }

    #zoom-info {
        max-width: 100%;
        align-items: center;
        text-align: center;
    }

    #zoom-card-name {
        font-size: 1.5rem;
    }

    #zoom-card-description {
        font-size: 1.1rem;
    }

    .divider {
        width: 100%;
    }

    #zoom-card-ambient {
        font-family: var(--font-text);
        font-size: 1rem;
        color: #4a5568; 
        font-style: italic;
        margin: 20px 0 0 0; /* 20px d'espai per sobre per separar-ho de les regles */
        line-height: 1.3;
        text-align: center;
        font-style: italic;
    }

    /* --- Intro --- */
    #intro-title {
        font-size: 2rem;
        letter-spacing: 3px;
    }

    #intro-subtitle {
        font-size: 0.8rem;
    }

    #intro-container {
        padding: 24px 16px;
        gap: 16px;
    }

    #intro-text-box {
        padding: 14px 16px;
    }

    #intro-text {
        font-size: 1rem;
    }

    #intro-cards-row {
        gap: 10px;
    }

    .intro-decree-card {
        width: 80px;
        height: 115px;
    }

    .intro-card-letter {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }

    .intro-card-name {
        font-size: 0.55rem;
    }

    #intro-start-btn {
        font-size: 0.9rem;
        padding: 12px 24px;
        letter-spacing: 1px;
    }

    /* --- Modal descart --- */
    .modal-content {
        width: 95%;
        padding: 20px 14px;
    }

    #discard-grid img {
        height: 130px;
    }
}

body.ruins-active::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    border: 8px solid rgba(255, 215, 0, 0.6);
    box-shadow: inset 0 0 50px rgba(255, 215, 0, 0.35);
    animation: ruinsPulse 1.5s infinite;
}

@keyframes ruinsPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

#current-exploration-card {
    transform-origin: center center;
}

.card-reveal {
    animation: revealCard 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes revealCard {
    0% {
        opacity: 0;
        transform: scale(0.92) rotate(-2deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

* {
    -webkit-tap-highlight-color: transparent;
}

img {
    user-select: none;
    -webkit-user-drag: none;
}

/* Botons globals per modals i SweetAlert */
button,
.swal2-confirm,
.close-btn {
    padding: 12px 22px;
    font-size: 1rem;
    font-family: var(--font-titles);
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition:
        background-color 0.2s ease,
        transform 0.1s ease,
        box-shadow 0.2s ease;
}

button:hover,
.swal2-confirm:hover,
.close-btn:hover {
    background-color: #1a252f;
}

button:active,
.swal2-confirm:active,
.close-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

button,
img,
.card-slot,
.guide-season {
    will-change: transform;
}