/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --parchment: #f4e4c1;
    --parchment-dark: #d4c4a1;
    --ink: #2c1810;
    --gold: #c9a84c;
    --gold-light: #e8d48b;
    --blood: #8b1a1a;
    --blood-light: #c0392b;
    --forest: #2d5016;
    --magic: #6c3483;
    --magic-light: #a569bd;
    --shadow: rgba(0, 0, 0, 0.7);
    --glass-bg: rgba(44, 24, 16, 0.7);
    --glass-border: rgba(201, 168, 76, 0.4);
    --panel-border: #c9a84c;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    background: #0a0a0a;
    color: var(--parchment);
    line-height: 1.7;
    font-size: 18px;
}

/* === PARTICLES === */
#particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--gold);
    border-radius: 50%;
    opacity: 0;
    animation: float-up 6s ease-in infinite;
}

@keyframes float-up {
    0% { opacity: 0; transform: translateY(0) scale(0); }
    20% { opacity: 0.8; }
    100% { opacity: 0; transform: translateY(-100vh) scale(1); }
}

/* === SCREENS === */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.8s ease;
}

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

/* === TITLE SCREEN === */
#title-screen {
    background:
        radial-gradient(ellipse at center, rgba(13, 27, 42, 0.4) 0%, rgba(0,0,0,0.92) 70%),
        linear-gradient(180deg, #060d18 0%, #0a1628 40%, #0d1b2a 60%, #060d18 100%);
}

.title-content {
    text-align: center;
    animation: fadeIn 2s ease;
}

.title-ornament {
    font-size: 2.5rem;
    color: var(--gold);
    margin: 0.5rem 0;
    filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.5));
}

.title-content h1 {
    font-family: 'MedievalSharp', cursive;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--gold);
    text-shadow:
        0 0 20px rgba(201, 168, 76, 0.4),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 3px;
}

.subtitle {
    font-style: italic;
    font-size: 1.3rem;
    color: var(--parchment-dark);
    margin: 0.5rem 0 2rem;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

/* === BUTTONS === */
.btn-medieval {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.2rem;
    padding: 12px 36px;
    background: linear-gradient(180deg, var(--gold) 0%, #a07830 100%);
    color: var(--ink);
    border: 2px solid var(--gold-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-medieval:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
}

.btn-medieval:active {
    transform: translateY(0);
}

.btn-medieval:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-medieval.secondary {
    background: linear-gradient(180deg, rgba(201, 168, 76, 0.12) 0%, rgba(160, 120, 48, 0.08) 100%);
    border-color: rgba(201, 168, 76, 0.45);
    color: var(--parchment);
    text-shadow: none;
}

.btn-medieval.secondary:hover {
    background: linear-gradient(180deg, rgba(201, 168, 76, 0.22) 0%, rgba(201, 168, 76, 0.12) 100%);
    border-color: var(--gold);
    color: var(--parchment);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* === CHARACTER SCREEN === */
#character-screen {
    background: linear-gradient(180deg, #1a0a00 0%, #0d0d2b 50%, #1a0a00 100%);
    overflow-y: auto;
    padding: 2rem;
}

#character-screen .panel {
    max-width: 800px;
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-family: 'MedievalSharp', cursive;
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 16px;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    background: rgba(244, 228, 193, 0.1);
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--parchment);
    outline: none;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    border-color: var(--gold-light);
    box-shadow: 0 0 10px rgba(201, 168, 76, 0.3);
}

.class-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.class-card {
    background: rgba(244, 228, 193, 0.05);
    border: 2px solid rgba(201, 168, 76, 0.3);
    border-radius: 8px;
    padding: 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.class-card:hover {
    border-color: var(--gold);
    background: rgba(244, 228, 193, 0.1);
    transform: translateY(-3px);
}

.class-card.selected {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.15);
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.2);
}

.class-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.class-card h3 {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    margin-bottom: 0.3rem;
}

.class-card p {
    font-size: 0.9rem;
    color: var(--parchment-dark);
    margin-bottom: 0.5rem;
}

.class-stats {
    font-size: 0.8rem;
    color: var(--gold-light);
    font-weight: 600;
}

/* === STORY SELECTION === */
#story-selection-screen {
    background: linear-gradient(180deg, #1a0a00 0%, #0d0d2b 50%, #1a0a00 100%);
    padding: 2rem;
    overflow-y: auto;
}

.selection-panel {
    max-width: 1000px;
    width: 100%;
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.story-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    cursor: default;
}

.story-thumb {
    height: 180px;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--glass-border);
}

.story-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    flex: 1;
}

.story-info h3 {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 1.4rem;
}

.story-info p {
    font-size: 0.95rem;
    color: var(--parchment-dark);
    line-height: 1.5;
    flex: 1;
}

.select-story-btn {
    align-self: flex-start;
    padding: 8px 24px;
    font-size: 1rem;
}

/* === CHAPTER SELECTION === */
.chapter-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.chapter-card {
    display: flex;
    align-items: center;
    padding: 1.5rem 2rem;
    cursor: default;
}

.chapter-card.locked {
    opacity: 0.5;
}

.chapter-info {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
}

.chapter-number {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 1.3rem;
    white-space: nowrap;
    min-width: 120px;
}

.chapter-subtitle {
    color: var(--parchment-dark);
    font-size: 1rem;
    font-style: italic;
    flex: 1;
}

.chapter-locked {
    color: var(--parchment-dark);
    font-style: italic;
    font-size: 0.9rem;
}

.select-chapter-btn {
    padding: 8px 24px;
    font-size: 1rem;
}

/* === PROFILES & SAVES === */
.profile-list, .save-slots {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.profile-item, .save-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.profile-item:hover, .save-slot:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.profile-info, .save-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.profile-info h4, .save-info h4 {
    margin: 0;
    color: var(--gold);
}

.profile-info span, .save-info span {
    font-size: 0.85rem;
    color: var(--parchment-dark);
}

.profile-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.profile-actions input {
    flex: 1;
}

.hud-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.auth-box {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.auth-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.error-text {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.success-text {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    padding: 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.loading-text {
    color: var(--parchment-dark);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* === USER INDICATOR (titre) === */
.user-indicator {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 10;
}

.user-badge {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.35);
    border-radius: 20px;
    padding: 4px 12px;
    white-space: nowrap;
}

/* === PROFILE SCREEN === */
#profile-screen {
    background: linear-gradient(180deg, #1a0a00 0%, #0d0d2b 50%, #1a0a00 100%);
    padding: 2rem;
    overflow-y: auto;
}

.profile-header {
    text-align: center;
    border-bottom: 1px solid rgba(201, 168, 76, 0.3);
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
}

.profile-header h2 {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 1.8rem;
}

.profile-subtitle {
    color: var(--parchment-dark);
    font-style: italic;
    font-size: 1rem;
    margin-top: 0.3rem;
}

.profile-footer {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(201, 168, 76, 0.2);
}

/* === ADMIN SCREEN === */
#admin-screen {
    background: linear-gradient(180deg, #1a0a00 0%, #0d0d2b 50%, #1a0a00 100%);
    padding: 2rem;
    overflow-y: auto;
}

.admin-panel {
    max-width: 800px;
    width: 100%;
}

.admin-users {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 1.5rem 0;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 0.3rem;
}

.admin-user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 8px;
    gap: 1rem;
    transition: background 0.2s;
}

.admin-user-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-family: 'MedievalSharp', cursive;
    color: var(--parchment);
    font-size: 1rem;
}

.admin-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(201, 168, 76, 0.2);
    border: 1px solid var(--gold);
    border-radius: 10px;
    color: var(--gold);
    white-space: nowrap;
}

.admin-user-saves {
    font-size: 0.82rem;
    color: var(--parchment-dark);
    font-style: italic;
}

.admin-user-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-medieval.danger {
    background: linear-gradient(180deg, rgba(139, 26, 26, 0.3) 0%, rgba(100, 10, 10, 0.2) 100%);
    border-color: rgba(192, 57, 43, 0.5);
    color: #e8a09a;
}

.btn-medieval.danger:hover {
    background: linear-gradient(180deg, rgba(192, 57, 43, 0.4) 0%, rgba(139, 26, 26, 0.3) 100%);
    border-color: var(--blood-light);
    color: #f5b7b1;
}

/* === MODAL ACTIONS === */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* === GAME NOTIFICATION === */
.game-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20, 8, 4, 0.95);
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 0.8rem 1.5rem;
    color: var(--gold);
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.game-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.game-notification.error {
    border-color: var(--blood-light);
    color: var(--blood-light);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* === PANELS === */
.panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.panel:hover {
    border-color: var(--gold);
    box-shadow: 
        0 12px 48px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* === GAME SCREEN === */
#game-screen {
    background: linear-gradient(180deg, #1a0a00 0%, #0d0d2b 50%, #1a0a00 100%);
}

.game-layout {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

/* === STATS PANEL === */
#stats-panel {
    width: 260px;
    min-width: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.char-header {
    text-align: center;
    border-bottom: 1px solid rgba(201, 168, 76, 0.3);
    padding-bottom: 0.8rem;
}

.char-header h3 {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.4rem;
    color: var(--gold);
}

.badge {
    display: inline-block;
    font-size: 0.8rem;
    padding: 2px 10px;
    background: rgba(201, 168, 76, 0.2);
    border: 1px solid var(--gold);
    border-radius: 12px;
    color: var(--gold-light);
    margin-top: 0.3rem;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.stat-label {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 0.95rem;
    min-width: 40px;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--parchment);
}

.hp-bar-container {
    flex: 1;
    margin-left: 0.5rem;
    height: 22px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 11px;
    border: 1px solid rgba(201, 168, 76, 0.3);
    position: relative;
    overflow: hidden;
}

.hp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blood), #c0392b);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.hp-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.inventory h4, .quest-log h4 {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    margin-bottom: 0.4rem;
    font-size: 1rem;
}

.inventory ul {
    list-style: none;
    font-size: 0.9rem;
}

.inventory li {
    padding: 3px 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.1);
}

.inventory li.empty {
    color: rgba(244, 228, 193, 0.4);
    font-style: italic;
}

.quest-log p {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--parchment-dark);
}

/* === NARRATIVE AREA === */
.narrative-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 1rem;
}

.scene-image {
    height: 200px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--panel-border);
    display: none;
    position: relative;
    overflow: hidden;
}

.scene-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, var(--panel-bg) 100%);
}

.narrative-panel {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.story-text {
    flex: 1;
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.story-text p {
    margin-bottom: 0.8rem;
    opacity: 0;
    animation: textAppear 0.5s ease forwards;
}

.story-text p:nth-child(1) { animation-delay: 0.1s; }
.story-text p:nth-child(2) { animation-delay: 0.4s; }
.story-text p:nth-child(3) { animation-delay: 0.7s; }
.story-text p:nth-child(4) { animation-delay: 1.0s; }
.story-text p:nth-child(5) { animation-delay: 1.3s; }

@keyframes textAppear {
    from { opacity: 0; transform: translateY(15px) scale(0.98); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.story-text .highlight {
    color: var(--gold);
    font-weight: 600;
}

.story-text .danger {
    color: var(--blood-light);
    font-weight: 600;
}

.story-text .magic {
    color: var(--magic-light);
    font-weight: 600;
}

/* === CHOICES === */
.choices {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.choice-btn {
    font-family: 'Crimson Text', serif;
    font-size: 1.05rem;
    padding: 12px 20px;
    background: rgba(201, 168, 76, 0.08);
    border: 1px solid rgba(201, 168, 76, 0.4);
    border-radius: 6px;
    color: var(--parchment);
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.choice-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.choice-btn:hover {
    background: rgba(201, 168, 76, 0.15);
    border-color: var(--gold);
    transform: translateX(4px);
}

.choice-btn:hover::before {
    transform: scaleY(1);
}

.choice-btn .choice-tag {
    font-size: 0.75rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 2px;
}

.choice-btn .dice-tag {
    float: right;
    font-size: 0.75rem;
    color: var(--magic-light);
    background: rgba(108, 52, 131, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

/* === DICE MODAL === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: rgba(20, 8, 4, 0.97);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 2rem 3rem;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 0 60px rgba(201, 168, 76, 0.2);
}

.modal-content h2, .modal-content h3 {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    margin-bottom: 1rem;
}

.dice-container {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.dice {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #3d2914 0%, #2c1810 50%, #1a0f08 100%);
    border: 3px solid var(--gold);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'MedievalSharp', cursive;
    font-size: 2.8rem;
    color: var(--gold);
    box-shadow: 0 0 30px rgba(201, 168, 76, 0.3), inset 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

.dice.rolling {
    animation: diceRoll 0.1s infinite;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(10deg) scale(1.05); }
    50% { transform: rotate(-5deg) scale(0.95); }
    75% { transform: rotate(8deg) scale(1.02); }
    100% { transform: rotate(0deg) scale(1); }
}

.dice.result {
    animation: diceResult 0.5s ease;
}

@keyframes diceResult {
    0% { transform: scale(1.3) rotate(15deg); }
    50% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.dice-detail {
    color: var(--parchment-dark);
    font-size: 0.95rem;
    margin: 0.5rem 0;
}

.dice-result {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.3rem;
    margin: 0.8rem 0;
    min-height: 1.5em;
}

.dice-result.success {
    color: #27ae60;
}

.dice-result.failure {
    color: var(--blood-light);
}

.dice-result.critical-success {
    color: var(--gold);
    text-shadow: 0 0 15px rgba(201, 168, 76, 0.6);
    font-size: 1.5rem;
}

.dice-result.critical-failure {
    color: var(--blood);
    text-shadow: 0 0 15px rgba(139, 26, 26, 0.6);
    font-size: 1.5rem;
}

/* === END MODAL === */
#end-modal .modal-content {
    max-width: 500px;
}

#end-modal h2 {
    font-size: 2rem;
}

#end-modal p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: var(--parchment-dark);
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.6);
}

/* === DAMAGE FLASH === */
.damage-flash {
    animation: damageFlash 0.5s ease;
}

@keyframes damageFlash {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: 0 0 30px rgba(192, 57, 43, 0.6); }
}

.heal-flash {
    animation: healFlash 0.5s ease;
}

@keyframes healFlash {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: 0 0 30px rgba(39, 174, 96, 0.6); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
    }

    #stats-panel {
        width: 100%;
        min-width: 100%;
        max-height: 180px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .char-header {
        width: 100%;
    }

    .stats-grid {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .stat-item {
        width: 48%;
    }

    .inventory, .quest-log {
        display: none;
    }

    .narrative-area {
        min-height: 0;
    }

    .scene-image {
        height: 120px;
    }

    .class-selection {
        grid-template-columns: 1fr 1fr;
    }
}

/* === MOT DE PASSE (ÉNIGMES) === */
.password-container {
    margin-top: 1rem;
    padding: 1.2rem;
    background: rgba(201, 168, 76, 0.05);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 8px;
    animation: fadeIn 0.4s ease;
}

.password-input-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.password-input {
    flex: 1;
    padding: 10px 14px;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    background: rgba(244, 228, 193, 0.08);
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--parchment);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
}

.password-input:focus {
    border-color: var(--gold-light);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.25);
}

.password-input.shake {
    animation: inputShake 0.4s ease;
}

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

.hint-btn {
    margin-top: 0.7rem;
    display: block;
    width: fit-content;
}

.hint-text {
    margin-top: 0.6rem;
    font-style: italic;
    color: var(--magic-light);
    font-size: 0.95rem;
    padding: 0.5rem 0.9rem;
    background: rgba(108, 52, 131, 0.1);
    border-left: 2px solid var(--magic-light);
    border-radius: 0 4px 4px 0;
    animation: fadeIn 0.4s ease;
}

.password-feedback {
    margin-top: 0.6rem;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.95rem;
    min-height: 1.4em;
    transition: color 0.3s;
}

.password-feedback.success { color: #27ae60; }
.password-feedback.failure { color: var(--blood-light); }

/* === MINI-JEU DE SÉQUENCE === */
.sequence-game {
    margin-top: 1rem;
    padding: 1.2rem;
    background: rgba(201, 168, 76, 0.04);
    border: 1px solid rgba(201, 168, 76, 0.18);
    border-radius: 8px;
    animation: fadeIn 0.4s ease;
}

.sequence-instruction {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 0.95rem;
    margin-bottom: 0.9rem;
}

.sequence-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sequence-item-btn {
    position: relative;
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sequence-item-btn.selected {
    background: rgba(201, 168, 76, 0.2);
    border-color: var(--gold);
    color: var(--gold);
    opacity: 0.7;
}

.seq-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    background: var(--gold);
    color: var(--ink);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: bold;
    margin-right: 5px;
}

.sequence-label {
    font-family: 'MedievalSharp', cursive;
    color: var(--gold);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.sequence-selected-area {
    margin-bottom: 0.8rem;
}

.sequence-order {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 32px;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    border: 1px solid rgba(201, 168, 76, 0.12);
}

.seq-order-item {
    font-size: 0.82rem;
    color: var(--parchment-dark);
    padding: 2px 9px;
    background: rgba(201, 168, 76, 0.1);
    border-radius: 3px;
    white-space: nowrap;
}

.sequence-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.sequence-feedback {
    margin-top: 0.7rem;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.95rem;
    min-height: 1.4em;
}

.sequence-feedback.success { color: #27ae60; }
.sequence-feedback.failure { color: var(--blood-light); }

/* === PERSONNAGES PRÉ-GÉNÉRÉS === */
.prebuilt-card {
    cursor: pointer;
    text-align: center;
    position: relative;
    padding: 1.4rem 1rem;
}

.prebuilt-class-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 10px;
    background: rgba(108, 52, 131, 0.2);
    border: 1px solid rgba(165, 105, 189, 0.4);
    border-radius: 12px;
    color: var(--magic-light);
    margin: 0.3rem 0 0.6rem;
}

.prebuilt-lore {
    font-size: 0.82rem;
    color: rgba(244, 228, 193, 0.55);
    font-style: italic;
    line-height: 1.5;
    margin-top: 0.6rem;
    border-top: 1px solid rgba(201, 168, 76, 0.12);
    padding-top: 0.5rem;
}

.prebuilt-special {
    font-size: 0.75rem;
    color: var(--gold);
    margin-top: 0.5rem;
    padding: 3px 0;
    border-top: 1px solid rgba(201, 168, 76, 0.15);
}

.prebuilt-card.selected {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.12);
    box-shadow: 0 0 25px rgba(201, 168, 76, 0.18);
}

/* Story thumb icon (when no image) */
.story-thumb-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 4rem;
    color: rgba(201, 168, 76, 0.4);
    filter: drop-shadow(0 0 15px rgba(41, 128, 185, 0.4));
}

/* === CHOIX DÉJÀ VISITÉ === */
.choice-btn.visited {
    opacity: 0.45;
    border-color: rgba(201, 168, 76, 0.18);
    cursor: default;
    pointer-events: none;
}

.choice-btn.visited::before { display: none; }

.choice-visited-mark {
    color: #27ae60;
    margin-right: 6px;
    font-size: 0.82em;
}
