/* Global & Reset */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: #FFF9E6;
    font-family: 'Comic Sans MS', 'STKaiti', 'KaiTi', cursive, sans-serif;
    overflow: hidden; /* Prevent body scroll */
    height: 100vh;
    width: 100vw;
}

#app {
    height: 100%;
    width: 100%;
}

.scroll-view {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 600px; /* Limit width on desktop for mobile feel */
    margin: 0 auto;
}

/* Main Card - Flex Column for Full Height */
.main-card {
    background-color: #FFFFFF;
    border: 3px solid #333;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 6px 6px 0 #FFD93D;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow internal content to scroll */
    overflow-x: hidden;
}

/* Mute Button */
.mute-icon-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

.mute-icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    padding: 5px;
    cursor: pointer;
}

/* Title Section */
.title-section {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.main-title {
    font-size: 22px;
    font-weight: bold;
    color: #FF6B6B;
    text-shadow: 2px 2px 0 #FFD93D;
    display: block;
}

.sub-title {
    font-size: 14px;
    color: #666;
    display: block;
    margin-top: 5px;
}

/* Top Action Buttons */
.game-top-btns {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.action-btn {
    padding: 6px 12px;
    border: 2px solid #333;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 2px 2px 0 #333;
    background-color: #fff;
}

.quit-btn { background-color: #FFB6C1; }
.restart-btn { background-color: #98FB98; }

/* Status Bar */
.status-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.status-tags {
    display: flex;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}

.status-item.compact {
    background-color: #FFFFFF;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 4px 10px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
}

.status-rules-btn {
    display: flex;
    justify-content: center;
    margin-top: 5px;
}
.game-rules-btn-small {
    background: #FFFACD;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 4px 12px;
    font-weight: bold;
    font-size: 12px;
}

/* Progress Bars */
.consecutive-progress.compact, .wrong-progress.compact {
    width: 100%;
    background-color: #FFFACD;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 5px 10px;
    margin-bottom: 2px;
}

.wrong-progress.compact { background-color: #FEE2E2; }

.progress-header.compact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-label.compact {
    font-size: 12px;
    font-weight: bold;
    color: #333;
    width: 50px;
    flex-shrink: 0;
}

.progress-track.compact {
    flex: 1;
    height: 8px;
    background-color: #E5E7EB;
    border: 1px solid #333;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #44A08D);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.error-fill { background: linear-gradient(90deg, #EF4444, #F87171); }

/* Cat Container */
.cat-container {
    width: 24vh;
    height: 24vh;
    max-width: 240px;
    max-height: 240px;
    margin: 10px auto;
    position: relative;
    flex-shrink: 0;
}

.cat-image {
    width: 100%;
    height: 100%;
    border: 3px solid #333;
    border-radius: 50% 50% 45% 45%;
    background-color: #FFFFFF;
    object-fit: cover;
}

.cat-shaking {
    animation: shake 0.3s ease-in-out;
}

/* Game Options - Grid Layout */
.game-options {
    display: grid;
    gap: 8px;
    padding: 5px;
    width: 100%;
    margin-top: 5px;
    margin-bottom: 5px;
    align-content: center;
    justify-items: center;
}

/* Specific Grid Columns */
.grid-easy { grid-template-columns: repeat(2, 1fr); }
.grid-medium { grid-template-columns: repeat(2, 1fr); } /* 2x2 */
.grid-hard { grid-template-columns: repeat(3, 1fr); } /* 3x2 */
.grid-hell { grid-template-columns: repeat(4, 1fr); } /* 4x2 */

.grid-medium .option-btn {
    max-width: 100px;
}

.option-btn {
    width: 100%;
    aspect-ratio: 1;
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.option-btn:active {
    transform: scale(0.95);
}

.option-image {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: contain;
    /* Optional: Add a subtle border or background to options */
    /* background: #f0f0f0; border: 1px solid #eee; */
}

/* Hell Mode & Shuffle Animations */
.option-hell {
    animation: hellPulse 1s ease-in-out infinite;
}

.options-shuffling {
    opacity: 0.5;
}

.option-shuffling {
    animation: shuffleMove 1s ease-in-out forwards;
}

/* Settings & Difficulty */
.settings-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.section-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
}

.difficulty-section {
    width: 100%;
}

.difficulty-btns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.difficulty-btn {
    padding: 10px;
    font-size: 14px;
    font-weight: bold;
    border: 3px solid #333;
    border-radius: 15px;
    background-color: #fff;
    transition: all 0.2s;
}

.difficulty-btn.easy { background-color: #98FB98; }
.difficulty-btn.medium { background-color: #FFE4B5; }
.difficulty-btn.hard { background-color: #FFB6C1; }
.difficulty-btn.hell { background-color: #FF6B6B; }

.difficulty-btn.active {
    background-color: #333 !important;
    color: #FFF !important;
    transform: scale(1.05);
}

.difficulty-desc {
    margin-top: 15px;
    background-color: #F0F0F0;
    border: 2px dashed #999;
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* Game Controls (Start, Restart, etc.) */
.game-controls {
    width: 100%;
    margin-top: 10px;
    flex-shrink: 0;
}

.start-btn {
    width: 100%;
    background-color: #4ECDC4;
    border: 3px solid #333;
    border-radius: 30px;
    padding: 12px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #333;
    box-shadow: 4px 4px 0 #333;
}

.start-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #333;
}

.secondary-btns {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.secondary-btn {
    flex: 1;
    background-color: #FFD93D;
    border: 3px solid #333;
    border-radius: 25px;
    padding: 10px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 3px 3px 0 #333;
}

.secondary-btn.secondary { background-color: #D3D3D3; }

/* Win/Fail Stats */
.win-stats {
    text-align: center;
}
.win-stats-title {
    font-size: 16px;
    font-weight: bold;
    color: #FF6B6B;
    margin-bottom: 10px;
}
.title-badge {
    display: inline-block;
    background: #FFD93D;
    padding: 5px 15px;
    border: 2px solid #333;
    border-radius: 20px;
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 15px;
}
.win-stats-card {
    background: #f9f9f9;
    border: 3px solid #333;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 4px 4px 0 #333;
    margin: 0 10px 15px;
}
.stats-qr-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.stats-qr-left {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.stats-qr-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.stats-qr-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.stats-qr-bottom-text {
    font-size: 8px;
    font-weight: bold;
    text-align: center;
}
.stats-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    text-align: center;
}
.stats-achievement {
    font-size: 9px;
    font-weight: bold;
    margin-bottom: 2px;
}
.win-stats-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
}
.win-stats-value {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: #333;
}
.win-stats-label {
    font-size: 8px;
    color: #666;
}

.thanks-section {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.thanks-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9f9f9;
    border: 3px solid #333;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 4px 4px 0 #333;
}
.thanks-icon {
    font-size: 20px;
}
.thanks-label {
    font-weight: bold;
    font-size: 14px;
}
.thanks-desc {
    font-size: 12px;
    color: #555;
}
.footer-message {
    margin-top: 20px;
    text-align: center;
}
.message-text {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

/* Modals */
.rules-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.rules-modal {
    background: #fff;
    border: 4px solid #333;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 15px;
    box-shadow: 8px 8px 0 #FFD93D;
}
.rules-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.rules-modal-title { font-size: 20px; font-weight: bold; }
.rules-modal-close { font-size: 24px; cursor: pointer; }
.rules-modal-content { overflow-y: auto; flex: 1; }
.rules-section-title { font-weight: bold; display: block; margin-top: 10px; }
.rules-section-text { display: block; font-size: 14px; line-height: 1.5; color: #555; }
.rules-modal-footer { margin-top: 15px; }
.rules-start-btn {
    width: 100%;
    background: #4ECDC4;
    border: 3px solid #333;
    border-radius: 20px;
    padding: 10px;
    font-weight: bold;
    font-size: 18px;
}

/* Animations Keyframes */
@keyframes hellPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shuffleMove {
    0% { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
    25% { transform: scale(1.1) rotate(-5deg); opacity: 0.8; filter: blur(1px); }
    50% { transform: scale(0.9) rotate(5deg); opacity: 0.5; filter: blur(2px); }
    75% { transform: scale(1.05) rotate(-3deg); opacity: 0.8; filter: blur(1px); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Shuffle Paw Animation */
.shuffle-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    z-index: 200;
    pointer-events: none;
}
.cat-paw {
    position: absolute;
    width: 60px;
    height: 60px;
    animation: pawMove 0.5s ease-in-out infinite;
}
.paw-left { left: 0; top: 50%; transform: translateY(-50%) rotate(-30deg); }
.paw-right { right: 0; top: 50%; transform: translateY(-50%) rotate(30deg); animation-delay: 0.25s; }
@keyframes pawMove {
    0%, 100% { opacity: 1; transform: translateY(-50%) rotate(var(--paw-rotate)); }
    50% { opacity: 0.7; transform: translateY(-30%) rotate(var(--paw-rotate)); }
}
.paw-left { --paw-rotate: -30deg; }
.paw-right { --paw-rotate: 30deg; }

/* Footer */
.footer {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    margin-top: 5px;
    flex-shrink: 0;
}

.bottom-links {
    margin-top: auto;
    padding-top: 15px;
    border-top: 2px dashed #eee;
}

.win-stats-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.win-stats-btns .start-btn,
.win-stats-btns .secondary-btn {
    padding: 8px;
    font-size: 14px;
}

.qr-section {
    margin-top: 10px;
    text-align: center;
}

.qr-text {
    font-size: 12px;
    font-weight: bold;
    margin-left: 0;
    text-align: left;
}

.qr-image {
    width: 60px;
    height: 60px;
    border: 3px solid #333;
    border-radius: 12px;
}

/* Desktop Overrides */
@media (min-width: 768px) {
    .container { padding: 20px; }
    .main-title { font-size: 36px; }
    .cat-container { width: 400px; height: 400px; }
    .option-btn { max-width: 120px; justify-self: center; }
    .status-item.compact { font-size: 16px; padding: 6px 15px; }
    .action-btn { font-size: 16px; padding: 8px 16px; }
}

/* Correct Feedback Animation */
.correct-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    z-index: 300; /* Higher than normal content */
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cat-paw-center {
    width: 150px;
    height: 150px;
    animation: pawHighFive 0.6s ease-out forwards;
    filter: drop-shadow(0 0 10px rgba(255, 217, 61, 0.8)); /* Glow effect */
}

@keyframes pawHighFive {
    0% {
        transform: scale(0.5) translateY(50px) rotate(10deg);
        opacity: 0;
    }
    40% {
        transform: scale(1.2) translateY(-20px) rotate(-10deg);
        opacity: 1;
    }
    60% {
        transform: scale(1.0) translateY(0) rotate(0deg);
    }
    80% {
        transform: scale(1.0) translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1.1) translateY(-10px) rotate(5deg);
        opacity: 0;
    }
}
