:root {
    --bg-color: #0A0F1D;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-secondary: #A0AABF;
    --gold: #D4AF37;
    --gold-glow: rgba(212, 175, 55, 0.5);
    --accent: #F18500;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden; /* App-like feel, no scrolling */
    height: 100vh;
    height: 100dvh; /* For mobile safari */
    /* Background pattern for spiritual feel */
    background-image: radial-gradient(circle at center, #111A30 0%, #05080F 100%);
}

.app-container {
    display: none; /* Hidden until started */
    flex-direction: column;
    height: 100%;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

.content-split {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    flex: 1;
    overflow: hidden;
}

.visual-rosary-container {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    z-index: 1;
    opacity: 0.8;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: transparent;
    z-index: 10;
}

.back-btn, #reset-btn, #share-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.3s;
}

.back-btn:hover, #reset-btn:hover, #share-btn:hover {
    color: var(--gold);
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

#misterio-title {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gold);
    text-align: center;
    flex: 1;
}

/* Main Display */
.display-area {
    grid-column: 1;
    grid-row: 1;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    cursor: pointer; /* Indicates it's tappable */
    /* Prevents text selection while tapping rapidly */
    user-select: none;
    -webkit-user-select: none;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px 20px;
    text-align: center;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: auto;
}

.misterio-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: block;
}

#oracao-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 15px;
}

.oracao-text-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#oracao-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 300;
}

/* Text fade animation class */
.fade-out {
    opacity: 0;
    transform: scale(0.98);
}
.fade-in {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.progress-indicator {
    margin-top: 30px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.touch-hint {
    margin-top: 30px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
}

.pulse {
    animation: pulseHint 2s infinite;
}

@keyframes pulseHint {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Beads Visualizer */
.beads-container {
    height: 100px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 10px;
    cursor: pointer;
    z-index: 2;
}

.nav-btn:hover {
    color: var(--gold);
}

.beads-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    /* Mask to fade edges */
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.beads-track {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 50vw; /* Padding to allow first and last beads to be centered */
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Bead Styles */
.bead {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #b07a51 0%, #73472b 40%, #3d2111 85%, #1c0e07 100%);
    box-shadow: 2px 4px 6px rgba(0,0,0,0.6);
    opacity: 0.6;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* Large beads (Pai Nosso / Mistérios / Cruz) */
.bead.large {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%, #c48a5c 0%, #804d2e 40%, #4a2713 85%, #211007 100%);
    position: relative;
}

/* Cross shape for the first bead */
.bead.cross {
    width: 24px;
    height: 32px;
    border-radius: 4px;
    background: linear-gradient(135deg, #73472b, #3d2111);
    box-shadow: inset 1px 1px 2px rgba(255,255,255,0.2), inset -1px -1px 2px rgba(0,0,0,0.6), 2px 4px 6px rgba(0,0,0,0.6);
    clip-path: polygon(40% 0%, 60% 0%, 60% 30%, 100% 30%, 100% 45%, 60% 45%, 60% 100%, 40% 100%, 40% 45%, 0% 45%, 0% 30%, 40% 30%);
}

.bead.active {
    background: radial-gradient(circle at 30% 30%, #fff1ba 0%, #f2c84b 30%, #b89123 70%, #54410a 100%);
    opacity: 1;
    transform: scale(1.3);
    box-shadow: 0 0 15px var(--gold-glow), 3px 6px 8px rgba(0,0,0,0.8);
}

.bead.completed {
    opacity: 0.9;
}

/* SVG Bead Pulse Animation for Active Step */
@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.6)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 12px rgba(255, 215, 0, 1)); transform: scale(1.4); }
    100% { filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.6)); transform: scale(1); }
}

.bead-pulse {
    transform-origin: center;
    transform-box: fill-box;
    animation: pulseGlow 1.5s infinite ease-in-out;
}

/* Mobile Layout Adjustments */
@media (max-width: 767px) {
    .display-area {
        justify-content: center;
        padding: 0 30px;
    }
    
    .glass-card {
        /* Narrower card to fit cleanly inside the beads */
        padding: 25px 20px;
        margin-top: -80px; /* Pulls it up slightly to clear the centerpiece and cross at the bottom */
        max-width: 310px;
        transform: scale(0.95);
        background: rgba(26, 32, 44, 0.3);
        backdrop-filter: blur(4px);
    }
}

/* Desktop Layout Adjustments */
@media (min-width: 768px) {
    .content-split {
        display: flex;
        flex-direction: row;
    }
    
    .visual-rosary-container {
        flex: 1;
        padding: 20px;
        opacity: 1;
    }
    
    .display-area {
        flex: 1;
        max-width: 500px;
    }
    
    .glass-card {
        padding: 40px 30px;
        min-height: 350px;
    }
    
    #oracao-title {
        font-size: 1.8rem;
        margin-bottom: 25px;
    }
    
    #oracao-text {
        font-size: 1.15rem;
        line-height: 1.6;
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(10, 15, 29, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.4s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex; /* Keep flex but hide via opacity and pointer events */
}

.modal-card {
    max-width: 500px;
    width: 100%;
}

.modal-subtitle {
    margin: 15px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.roulette-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    position: relative;
    width: 100%;
    padding: 0 45px; /* Space for absolute arrows */
}

.roulette-track {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 280px; /* Constrain track width */
    position: relative;
    height: 90px;
}

.roulette-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 5px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    position: absolute;
    width: 130px;
    opacity: 0;
    transform: scale(0.6) translateX(0);
    z-index: 1;
    pointer-events: none;
}

.roulette-item span {
    font-size: 0.9rem;
    font-weight: 600;
}

.roulette-item small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.roulette-item.active {
    opacity: 1;
    transform: scale(1.05) translateX(0);
    z-index: 3;
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--gold);
    color: var(--gold);
    pointer-events: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.roulette-item.prev {
    transform: scale(0.8) translateX(-95px);
    z-index: 2;
    opacity: 0.4;
    pointer-events: auto;
    cursor: pointer;
}

.roulette-item.next {
    transform: scale(0.8) translateX(95px);
    z-index: 2;
    opacity: 0.4;
    pointer-events: auto;
    cursor: pointer;
}

.roulette-item.prev:hover, .roulette-item.next:hover {
    opacity: 0.7;
}

.roulette-nav {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--gold);
    font-size: 1.2rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 5;
    position: absolute;
    top: 50%;
    margin-top: -18px;
}

.roulette-nav:first-child {
    left: 5px;
}

.roulette-nav:last-child {
    right: 5px;
}

.roulette-nav:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold);
    transform: scale(1.1);
}

.misterios-options {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
}

.modal-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-btn small {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
}

.modal-btn.selected {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold);
    color: var(--gold);
}

.misterio-btn {
    flex: 1 1 40%;
    min-width: 120px;
    padding: 10px;
}

.modal-btn.primary {
    background: var(--gold);
    color: #000;
    font-weight: 600;
    width: 100%;
    margin-top: 20px;
}

.modal-btn.primary:hover {
    background: #e5c357;
    box-shadow: 0 0 15px var(--gold-glow);
}

.hidden {
    display: none !important;
}
