/* Ensure mobile viewport is fully utilized without scrolling */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-x: hidden; /* Prevent scrolling horizontally, allow vertical */
    background-color: #f8f4e3; /* Parchment/cream background */
    color: #1f2937;
    font-family: 'Times New Roman', Times, serif; /* Favoring serif for historical context */
}

#app {
    height: auto; /* Allow content to dictate height */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px 10px; /* Add padding for better look in grid */
    max-width: 1200px; /* Setting a sensible max width for the whole app */
    margin: 0 auto;
}

/* Regret Info Box Styles */
#regret-info-box {
    width: 100%;
    max-width: 1000px;
    background-color: #ffffff;
    border: 1px solid #c0c0c0; /* Softer border */
    border-radius: 12px;
    padding: 30px; /* More padding */
    margin-bottom: 30px; /* More space below */
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08); /* Stronger, softer shadow */
}

#regret-info-box h1 {
    font-size: 2.2em; /* Bigger header, adjusted for 'much bigger' request */
    color: #475569; /* Slate blue */
    margin-top: 0;
    border-bottom: 3px double #e0e7ff; /* Double line separator */
    padding-bottom: 15px;
    margin-bottom: 20px;
    font-weight: 700;
}

#regret-info-box p, #regret-info-box li {
    font-size: 1.3em; /* Significantly larger text for readability */
    line-height: 1.7;
    color: #333;
    margin-bottom: 10px;
}

#regret-info-box ul {
    list-style: none;
    padding-left: 0;
}

#regret-info-box li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

#regret-info-box li::before {
    content: "•";
    color: #475569; /* Match header color */
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* New Grammar Exercises Box Styles */
#grammar-exercises-box {
    width: 100%;
    max-width: 1000px;
    background-color: #f0f4f8; /* Light blue/grey to slightly differentiate */
    border: 1px solid #c0c0c0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
}

#grammar-exercises-box h1 {
    font-size: 2.2em;
    color: #8b5cf6; /* Matching section header color */
    margin-top: 0;
    border-bottom: 3px double #c7d2fe;
    padding-bottom: 15px;
    margin-bottom: 20px;
    font-weight: 700;
}

#grammar-exercises-box p {
    font-size: 1.3em;
    line-height: 1.7;
    color: #333;
    margin-bottom: 20px;
}

#regret-exercises {
    list-style: decimal;
    padding-left: 30px;
}

#regret-exercises li {
    font-size: 1.3em;
    line-height: 2;
    margin-bottom: 15px;
}

#regret-exercises li span {
    display: inline-block;
    min-width: 150px;
    height: 1.5em;
    border-bottom: 2px dashed #475569;
    text-align: center;
    font-weight: bold;
    color: #10b981; /* Green color for answers */
    transition: background-color 0.3s, color 0.3s;
}

#show-answers-btn {
    padding: 10px 20px;
    font-size: 1.2em;
    margin-top: 20px;
    background-color: #8b5cf6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

#show-answers-btn:hover {
    background-color: #7c3aed;
}

.answer-shown {
    border-bottom: 2px solid #10b981 !important;
    background-color: #ecfdf5; /* Light green background */
}

/* Add style for section headers */
.grid-section-header {
    width: 100%;
    max-width: 1200px;
    font-size: 1.8em;
    color: #8b5cf6; /* Purple/indigo for section titles */
    margin-top: 40px;
    margin-bottom: 20px;
    text-align: left;
    border-bottom: 2px solid #8b5cf6;
    padding-bottom: 5px;
    font-weight: 600;
}

/* New Grid Layout for portraits */
#portrait-grid {
    /* REMOVED: #portrait-grid was replaced by specific IDs with a shared class in HTML */
}

.portrait-grid-section { /* Use class for both grids */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive grid for portraits */
    gap: 30px;
    width: 100%;
    max-width: 1200px;
}

/* Card styles for flip effect */
.card-container {
    width: 100%;
    max-width: none; /* Allow full grid cell width */
    height: 450px; /* Making portraits slightly taller */
    perspective: 1200px; /* Deeper perspective */
    cursor: pointer;
    touch-action: manipulation;
}

.card {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Smoother, slower transition */
    transform-style: preserve-3d;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); /* Enhanced shadow */
    border-radius: 16px;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* Hide the back of the card when flipped */
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px;
    box-sizing: border-box;
}

/* Front Face: Portrait */
.card-face.front {
    background: #ffffff; /* Pure white front */
    border: 1px solid #e0e0e0;
}

.card-portrait {
    width: 100%;
    height: 85%;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); /* Distinct image shadow */
    margin-bottom: 10px;
}

.card-name {
    height: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35em;
    font-weight: 700;
    color: #475569; /* Slate blue for names */
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    padding: 5px 0;
}

/* Back Face: Regret Sentence */
.card-face.back {
    background: #475569; /* Slate blue background */
    color: white;
    transform: rotateY(180deg);
    padding: 30px; /* Adjusted padding */
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-regret-text {
    font-size: 1.1em;
    line-height: 1.6;
    font-style: italic;
    font-weight: 300;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-regret-text::before {
    content: "“";
    font-family: Georgia, serif;
    font-size: 3em;
    line-height: 0.5;
    display: block;
    margin: 5px 0 10px 0;
    text-align: left;
    color: #fde68a; /* Subtle gold accent */
}

.card-regret-text::after {
    content: "”";
    font-family: Georgia, serif;
    font-size: 3em;
    line-height: 0.5;
    display: block;
    text-align: right;
    margin-top: 10px;
    color: #fde68a; /* Subtle gold accent */
}

.card-face.back .card-name {
    font-size: 1em;
    font-weight: 500;
    color: #cbd5e1; /* Lighter color for attribution */
    padding: 0;
    height: auto;
    margin-top: 10px;
}

@media (max-width: 600px) {
    #portrait-grid {
        /* Removed styles for #portrait-grid in media query */
    }
    
    .portrait-grid-section {
        grid-template-columns: 1fr; /* Single column on very small screens */
        gap: 20px;
    }

    .card-container {
        height: 350px; /* Slightly smaller height on mobile */
    }

    #regret-info-box {
        padding: 20px;
        margin-bottom: 20px;
    }

    .card-name {
        font-size: 1.2em;
    }

    .card-regret-text {
        font-size: 1em;
    }

    #grammar-exercises-box {
        padding: 20px;
    }
    
    #grammar-exercises-box h1 {
        font-size: 1.8em;
    }

    #grammar-exercises-box p, #regret-exercises li {
        font-size: 1.1em;
    }
    
    #regret-exercises {
        padding-left: 20px;
    }

    #regret-exercises li span {
        min-width: 100px;
    }
}

/* Diary Questionnaire Styles */
#diary-questionnaire-box {
    width: 100%;
    max-width: 1000px;
    background-color: #fffff0; /* Very light yellow/cream paper color */
    border: 1px solid #d4c8a9;
    border-radius: 12px;
    padding: 30px;
    margin-top: 40px;
    margin-bottom: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), inset 0 0 10px rgba(0, 0, 0, 0.05); /* Stronger shadow to make it pop like a book */
    position: relative;
    overflow: hidden;
    font-family: 'Times New Roman', Times, serif; /* Using a classic readable font */
    /* Adding subtle ruled lines (30px line height) */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 28px,
        #d4c8a9 28px,
        #d4c8a9 29px /* Line thickness */
    );
    background-size: 100% 30px;
    background-position: 0 45px; /* Adjusting position to start line below h1/h2/p */
}

/* Red Vertical Line (Margin) */
#diary-questionnaire-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 40px; 
    width: 2px;
    height: 100%;
    background-color: #ff5757; /* Light red/pink ink color */
    opacity: 1; /* Make it solid red */
    z-index: 1;
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.1);
}

.diary-title {
    font-size: 3em; /* Increased from 2.5em */
    color: #3f3f46; /* Zinc gray */
    text-align: center;
    margin-bottom: 5px;
    font-weight: 700;
    text-shadow: 1px 1px 0 #fff;
    letter-spacing: 1px; /* Added spacing */
}

.diary-subtitle {
    font-size: 1.8em; /* Increased from 1.5em */
    color: #a1a1aa; /* Gray subtitle */
    text-align: center;
    margin-bottom: 25px; /* Increased margin */
    font-style: italic;
    border-bottom: none; /* Removed border */
    padding-bottom: 0;
}

.diary-instruction {
    font-size: 1.4em; /* Increased from 1.2em */
    text-align: center;
    color: #64748b;
    margin-bottom: 30px;
}

.diary-section {
    margin-bottom: 20px; /* Reduced margin */
    padding: 5px 0; /* Reduced padding */
    position: relative;
    padding-left: 55px; /* Account for the red margin line */
}

.diary-section h3 {
    font-size: 2em; /* Increased from 1.6em */
    color: #475569; /* Slate blue */
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 3px solid #8b5cf6; /* Solid purple line */
    width: auto;
    display: inline-block;
    background-color: #fffff0; /* Match paper background to hide ruling behind header */
    padding-left: 5px;
    padding-right: 10px;
    margin-left: -55px; /* Pull header slightly left past margin line */
    z-index: 2; /* Ensure header is above ruling */
    position: relative;
}

.diary-section label {
    display: block;
    font-size: 1.5em; /* Increased from 1.25em */
    font-weight: 500;
    color: #333;
    margin-top: 10px;
    margin-bottom: 5px;
    line-height: 30px; /* Align to ruling */
}

.question-group p {
    font-size: 1.3em; /* Increased from 1.1em */
    margin: 0px 0 10px 0; /* Tightened vertical rhythm */
    padding-left: 0;
    position: relative;
    line-height: 30px; /* Align to ruling */
}

.diary-input, .diary-textarea {
    border: none;
    border-bottom: 1px solid transparent; /* Remove dashed line for desktop */
    background: transparent;
    font-size: 1.3em; /* Increased from 1.1em */
    font-family: 'Courier New', Courier, monospace; /* Distinctive input font, simulating typewriter */
    color: #1f2937; /* Dark gray/black 'ink' */
    width: calc(100% - 150px); /* Adjust width for text input */
    padding: 0 5px; /* Adjusted padding */
    box-sizing: border-box;
    transition: border-bottom-color 0.3s;
    display: inline;
    vertical-align: middle;
}

.diary-input:focus, .diary-textarea:focus {
    outline: none;
    border-bottom: 1px solid #8b5cf6;
    color: #3b82f6;
}

.diary-textarea {
    display: block;
    width: 100%;
    min-height: 100px;
    resize: vertical;
    border: 1px solid #d4c8a9;
    padding: 10px;
    margin-top: 10px;
    background-color: rgba(255, 255, 255, 0.7); /* Slightly lighter background for textarea */
    color: #1f2937;
    line-height: 1.5;
}

.big-regret-section label {
    margin-top: 25px;
    font-style: italic;
}

/* Reminder box at the end */
.diary-reminder-box {
    margin-top: 40px;
    padding: 20px;
    background-color: #fefce8; /* Very light subtle yellow accent */
    border-left: 8px solid #f97316; /* Warm orange highlight */
    border-radius: 4px;
    margin-left: -10px; /* Pull left to cover margin area */
    padding-left: 65px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.reminder-header {
    font-size: 1.6em; /* Increased from 1.4em */
    color: #f97316; /* Match border color */
    margin-top: 0;
    border-bottom: 1px solid #fed7aa;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.diary-reminder-box ul {
    list-style-type: none;
    padding-left: 0;
}

.diary-reminder-box li {
    font-size: 1.3em; /* Increased from 1.1em */
    line-height: 1.5;
    margin-bottom: 8px;
    color: #475569;
}

/* Mobile adjustments for diary box */
@media (max-width: 600px) {
    #diary-questionnaire-box {
        padding: 20px 10px;
        background-image: none; /* Disable ruling on mobile for cleaner stack */
    }
    
    #diary-questionnaire-box::before {
        left: 20px; /* Smaller margin on mobile */
    }

    .diary-section {
        padding-left: 35px; /* Adjust padding for smaller margin */
    }

    .diary-section h3 {
        margin-left: -35px;
        background-color: #fffff0;
    }
    
    .diary-section label {
        line-height: 1.5; /* Reset line height */
    }

    /* Ensure inputs stack vertically and align with ruling on mobile */
    .question-group p {
        display: flex;
        flex-direction: column;
        line-height: normal; /* Disable fixed line height when stacking */
    }

    .diary-input {
        width: 100%; 
        display: block;
        margin-top: 5px;
        margin-bottom: 5px;
        line-height: 1.5;
        border-bottom: 1px dashed #333; /* Reintroduce dashed line for clarity on mobile stack */
    }
}