/* ==========================================================================
   1. BRAND VARIABLES & MORANDI RETRO THEME TOKENS
   ========================================================================== */
:root {
    /* Premium Morandi Blue Palette Spectrum Muted Low Saturation Colors */
    --morandi-blue-dark: #4A6984;     /* Primary Muted Deep Morandi Slate Blue */
    --morandi-blue-medium: #6B8EAD;   /* Secondary Mid-tone Soft Steel Blue */
    --morandi-blue-light: #A2B9CE;    /* Soft Ice Blue Accents Elements */
    --morandi-blue-pale: #D1DFEC;     /* Muted Light Grey Blue Fill Accents */
    
    /* Organic Oatmeal Parchment Palette Tones */
    --color-oat-bg: #F5F2EB;          /* Low Saturation Warm Oat Wallpaper base */
    --color-cream-card: #FAF8F5;      /* Lighter Paper Scroll Tint blocks layerings */
    --color-text-dark: #222E3A;       /* Deep Charcoal Earth Brown for extreme visibility */
    --color-text-muted: #5A6B7C;      /* Secondary descriptive slate green label lines */
    
    /* Feedback Assertive Tokens */
    --color-danger: #A64B44;          /* Desaturated Muted Crimson Earth Jasper */
    --color-success-moss: #3E5F49;    /* Low Saturation Forest Moss Green */
    --color-accent-gold: #B88358;     /* Warm Amber Antique Gold Ocher Highlights */
    
    /* Spec layout definitions */
    --border-thickness: 4px;
    --text-shadow-soft: 1px 2px 2px rgba(255, 255, 255, 0.95);
}

/* ==========================================================================
   2. CORE UTILITIES & CONTAINER ALIGNMENTS
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Serif TC', Georgia, serif;
    background-color: #D6D0C5; 
    color: var(--color-text-dark);
    min-height: 100vh;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.game-container {
    width: 100%;
    max-width: 1140px;
    background-color: var(--color-oat-bg);
    border: var(--border-thickness) solid var(--morandi-blue-dark);
    box-shadow: 0 24px 60px rgba(34,46,58,0.25), inset 0 0 50px rgba(74,105,132,0.06);
    min-height: 740px;
    position: relative;
    padding: 40px;
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ==========================================================================
   3. HIGH-READABILITY SENIOR OPTIMIZED TYPOGRAPHY
   ========================================================================== */
.main-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--morandi-blue-dark);
    letter-spacing: 0.16em; 
    line-height: 1.2;
    margin-bottom: 10px;
    text-shadow: var(--text-shadow-soft);
}

.english-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--morandi-blue-medium);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    margin-bottom: 25px;
}

.tribal-divider {
    font-size: 2rem;
    color: var(--color-accent-gold);
    margin: 20px 0;
    letter-spacing: 0.5em;
    text-shadow: var(--text-shadow-soft);
}

.welcome-tagline {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-text-muted);
    line-height: 1.6;
    max-width: 820px;
    margin: 0 auto;
}

/* ==========================================================================
   4. TACTILE CLASSIC BUTTON DESIGN ELEMENTS
   ========================================================================== */
.retro-btn {
    font-family: 'Noto Serif TC', Georgia, serif;
    font-size: 1.45rem; /* Extremely Large fonts configured for senior readability scaling */
    font-weight: 900;
    padding: 16px 32px;
    border: var(--border-thickness) solid var(--morandi-blue-dark);
    background-color: var(--color-cream-card);
    color: var(--color-text-dark);
    cursor: pointer;
    box-shadow: 4px 4px 0px var(--morandi-blue-dark);
    transition: all 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.05em;
}

.retro-btn:hover:not(:disabled) {
    background-color: #FFFFFF;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--morandi-blue-dark);
}

.retro-btn:active:not(:disabled) {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px var(--morandi-blue-dark);
}

.retro-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background-color: #E5DFD5;
    border-color: #9A958C;
    box-shadow: 2px 2px 0px #9A958C;
}

.btn-primary {
    background-color: var(--morandi-blue-dark);
    color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) {
    background-color: var(--morandi-blue-medium);
}

.btn-secondary {
    background-color: #E2DDD5;
    color: var(--color-text-dark);
}

.btn-accent {
    background-color: var(--color-accent-gold);
    color: #FFFFFF;
    border-color: var(--color-wood-dark);
    box-shadow: 4px 4px 0px var(--color-wood-dark);
}
.btn-accent:hover:not(:disabled) {
    background-color: #CD9264;
    box-shadow: 6px 6px 0px var(--color-wood-dark);
}

.btn-danger {
    background-color: var(--color-danger);
    color: #FFFFFF;
    border-color: var(--color-text-dark);
}

.btn-small {
    font-size: 1.1rem;
    padding: 8px 16px;
    box-shadow: 2px 2px 0px var(--morandi-blue-dark);
}

.long-btn { width: 100%; max-width: 450px; }

/* ==========================================================================
   5. STAGE VIEWS CONFIGURATIONS
   ========================================================================== */
#stage-welcome {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 640px;
    padding: 20px;
}

.action-wrapper {
    margin-top: 50px;
    width: 100%;
}

/* Gameplay Header Indicator HUD */
.game-hud {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    background-color: rgba(107, 142, 173, 0.12);
    border-bottom: 2px solid var(--morandi-blue-medium);
    padding: 14px 24px;
    margin-bottom: 35px;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--morandi-blue-dark);
}

.game-hud strong {
    font-size: 1.6rem;
    color: var(--color-accent-gold);
}

.pixel-tip {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    opacity: 0.8;
}

/* Audio Player Board */
.audio-control-panel {
    border: 2px solid var(--morandi-blue-medium);
    background-color: var(--color-cream-card);
    padding: 25px;
    margin-bottom: 40px;
    box-shadow: inset 0 0 12px rgba(0,0,0,0.02);
}

.panel-legend {
    font-size: 1.15rem;
    font-weight: 900;
    color: #FFFFFF;
    background-color: var(--morandi-blue-dark);
    padding: 6px 20px;
    border: 2px solid var(--morandi-blue-dark);
    letter-spacing: 0.05em;
}

.audio-instruction {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 15px;
}

.audio-player-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

#melody-audio-engine {
    width: 100%;
    max-width: 700px;
    height: 56px;
}

/* Quiz Option Matrix */
.options-matrix-board {
    margin-bottom: 45px;
}

.quiz-hint-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--morandi-blue-dark);
    margin-bottom: 25px;
    text-shadow: var(--text-shadow-soft);
}

.choices-grid-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* Individual Option Nodes */
.choice-btn-node {
    font-size: 1.4rem !important; 
    padding: 22px 28px !important;
    text-align: left;
    justify-content: flex-start;
    line-height: 1.4;
    border-radius: 0;
    border-color: var(--morandi-blue-dark);
    background-color: var(--color-cream-card);
    transition: transform 0.2s, opacity 0.4s ease-out, background-color 0.2s;
}

.choice-btn-node:hover:not(:disabled) {
    background-color: #FFFDF7;
    border-color: var(--color-accent-gold);
}

.choice-prefix-lbl {
    font-family: 'Outfit', sans-serif;
    color: var(--morandi-blue-medium);
    font-weight: 900;
    font-size: 1.6rem;
    margin-right: 18px;
    display: inline-block;
}

/* Wrong Option Lockouts Fade-out (猜錯懲罰：變透明且禁止再點擊) */
.choice-btn-node.wrong-locked-fade {
    opacity: 0 !important; 
    pointer-events: none !important;
    transform: scale(0.93);
    cursor: default;
}

/* ==========================================================================
   6. VICTORY STAGE:大家一起唱 BANNER & DUAL COLUMN SPLIT LITERATURE
   ========================================================================== */
.sing-together-banner {
    background-color: var(--color-success-moss);
    color: #FFFFFF;
    padding: 18px 30px;
    text-align: center;
    margin-bottom: 35px;
    border: 2px solid var(--color-text-dark);
    box-shadow: 4px 4px 0 var(--color-text-dark);
    animation: bouncePopBlast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.sing-together-banner h2 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

/* 左右等比雙欄文獻排版 50% / 50% */
.cultural-split-layout {
    display: flex;
    flex-direction: row;
    gap: 32px;
    align-items: stretch;
    margin-top: 40px;
    margin-bottom: 45px;
    width: 100%;
    animation: slideUpReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.cultural-column-photo {
    flex: 1;                
    width: 50%;             
    display: flex;
    flex-direction: column;
}

.cultural-column-lyrics {
    flex: 1;                
    width: 50%;             
    display: flex;
    flex-direction: column;
}

.inner-frame {
    border: 2px solid var(--morandi-blue-medium);
    background-color: var(--color-cream-card);
    padding: 26px;
    flex: 1;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.02);
}

.scrollable-frame {
    max-height: 520px;      
    overflow-y: auto;       
}

.column-legend {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--morandi-blue-dark);
    background-color: var(--morandi-blue-pale);
    padding: 4px 14px;
    border: 1px solid var(--morandi-blue-dark);
}

.image-viewport {
    width: 100%;
    height: 100%;
    min-height: 350px;
    max-height: 460px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(34,46,58,0.04);
    border: 1px solid rgba(74,105,132,0.15);
    overflow: hidden;
}

#cultural-document-img {
    width: 100%;
    height: 100%;
    object-fit: cover;      /* Fills fully without any stretching distortion */
    display: block;
}

/* Lyrics & Citations Typography */
.lyrics-text-box h4 {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--morandi-blue-dark);
    margin-bottom: 18px;
    border-left: 6px solid var(--color-accent-gold);
    padding-left: 12px;
}

#lyrics-render-field {
    font-size: 1.5rem;     /* Extra large clean legible lines for elder group learners */
    font-weight: 700;
    color: var(--color-text-dark);
    line-height: 1.8;
    letter-spacing: 0.06em;
    padding: 5px 0;
}

.retro-separator-line {
    border: none;
    border-top: 2px dashed var(--morandi-blue-medium);
    margin: 25px 0;
    opacity: 0.5;
}

.citation-source-box h5 {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--morandi-blue-medium);
    margin-bottom: 10px;
}

#citation-render-field {
    font-size: 1.2rem;     
    font-weight: 600;
    color: var(--color-text-muted);
    line-height: 1.6;
    background-color: rgba(34,46,58,0.03);
    padding: 14px 20px;
    border-left: 5px solid var(--morandi-blue-medium);
    font-style: italic;
}

/* Footer Control Line */
.gameplay-dashboard-footer {
    border-top: 2px dashed rgba(107,142,173,0.3);
    padding-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
}

/* ==========================================================================
   7. MODAL LAYERS MECHANISMS (猜錯了彈窗)
   ========================================================================== */
.game-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(34, 46, 58, 0.8); 
    backdrop-filter: blur(5px);
    z-index: 99999;
    display: flex; justify-content: center; align-items: center; padding: 20px;
}

.wrong-guess-card {
    max-width: 520px;
    border-color: var(--color-text-dark);
}

.alert-icon-avatar { font-size: 4rem; margin-bottom: 15px; }

.wrong-alert-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-danger);
    letter-spacing: 0.05em;
    margin-bottom: 15px;
}

.wrong-alert-body {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text-dark);
    line-height: 1.6;
    margin-bottom: 35px;
}

/* ==========================================================================
   8. MACRO LAYOUT KEYFRAMES
   ========================================================================== */
@keyframes bouncePopBlast {
    0% { transform: scale(0.85); opacity: 0; }
    70% { transform: scale(1.03); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

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

/* ==========================================================================
   9. RESPONSIVE COMPACT BREAKPOINTS
   ========================================================================== */
@media (max-width: 960px) {
    .cultural-split-layout { flex-direction: column; gap: 30px; }
    .cultural-column-photo, .cultural-column-lyrics { width: 100%; }
    .choices-grid-layout { grid-template-columns: 1fr; gap: 16px; }
    .main-title { font-size: 2.5rem; letter-spacing: 0.1em; }
    .game-hud { grid-template-columns: 1fr; gap: 12px; text-align: center; }
    .game-hud .text-right { text-align: center; }
    .image-viewport { min-height: 280px; }
    .game-container { padding: 20px; }
}