/* --- Base Styles --- */
* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#game-view {
    position: relative;
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;

    /* Default: PC / Desktop Setting */
    background-image: url('images/bg_classroom.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}

/* --- Character Container --- */
.character-container {
    position: absolute;
    bottom: 0px;
    left: 0;
    right: 0;
    width: 100%;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    z-index: 5;
}

/* --- Mobile Setting (Screens up to 768px) --- */
@media screen and (max-width: 768px) {
    #game-view {
        background-image: url('images/bg_classroom-mo.jpg');
        background-size: cover;
        background-position: center center;
    }

    .character-container {
        height: 88vh;
        bottom: 0vh;
        z-index: 1;
    }

    .ui-bottom-panel {
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
        margin-bottom: 0px;
    }
}

#heroine-img {
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1.0);
    }

    50% {
        transform: scale(1.02);
    }
}

/* --- UI Panel (Dialogue & Menu) --- */
.ui-bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    border-top: 4px solid #4DD0E1;
    padding: 15px 15px 25px 15px;
    z-index: 10;
    width: 100%;
    height: auto;
    min-height: 200px;
}

.dialogue-box {
    text-align: center;
    margin-bottom: 10px;
}

.dialogue-box p {
    color: white;
    font-size: 1.05rem;
    margin: 0 0 10px 0;
    line-height: 1.35;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    max-height: 250px;
    overflow-y: auto;
}

.action-btn {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    background: linear-gradient(180deg, #4FC3F7, #0288D1);
    color: white;
    box-shadow: 0 4px 0 #01579B;
    transition: all 0.1s;
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* --- Overlay Modals --- */
.overlay-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.mode-card {
    background: white;
    width: 92%;
    max-width: 440px;
    max-height: 85vh;
    padding: 30px 20px 20px 20px;
    border-radius: 28px;
    text-align: center;
    border: 4px solid #4DD0E1;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.mode-card h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.5rem;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    overflow-y: auto;
    padding: 5px 10px 20px 5px;
    margin: 10px 0;
    /* Custom Scrollbar for visibility */
    scrollbar-width: thin;
    scrollbar-color: #4DD0E1 #F5F5F5;
}

.mode-grid::-webkit-scrollbar {
    width: 6px;
}

.mode-grid::-webkit-scrollbar-track {
    background: #F5F5F5;
    border-radius: 10px;
}

.mode-grid::-webkit-scrollbar-thumb {
    background: #4DD0E1;
    border-radius: 10px;
}

.mode-btn {
    width: 100%;
    padding: 10px 6px;
    border-radius: 10px;
    border: 2px solid #E0E0E0;
    background: #F5F5F5;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
    color: #333;
}

.mode-btn:active {
    transform: scale(0.96);
}

.mode-btn.highlight {
    background: #E0F7FA;
    border-color: #4DD0E1;
    color: #006064;
}

.mode-btn.cancel {
    border: none;
    background: none;
    color: #757575;
    margin-top: 10px;
    text-decoration: underline;
}

/* --- Story/Unit Grid --- */
.story-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px 10px 30px 5px;
    margin-bottom: 10px;
    border-bottom: 2px dashed #EEE;
    scrollbar-width: thin;
    scrollbar-color: #F06292 #F5F5F5;
}

.story-grid::-webkit-scrollbar {
    width: 6px;
}

.story-grid::-webkit-scrollbar-track {
    background: #F5F5F5;
    border-radius: 10px;
}

.story-grid::-webkit-scrollbar-thumb {
    background: #F06292;
    border-radius: 10px;
}

.story-btn {
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    border: 2px solid #F06292;
    background: white;
    cursor: pointer;
}

.story-btn .num {
    font-size: 1rem;
    font-weight: bold;
}

.story-btn .score {
    font-size: 0.75rem;
    color: #E91E63;
    margin-top: 4px;
}

.story-btn.perfect {
    background: #FFF9C4;
    border-color: #FBC02D;
}

/* --- Shop UI --- */
.shop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    background: #FAFAFA;
    border: 1px solid #EEEEEE;
    margin-bottom: 8px;
}

.shop-item img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.shop-item-info {
    flex: 1;
    text-align: left;
}

.shop-item-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.shop-item-btn {
    background: #4DD0E1;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.shop-item-btn.owned {
    background: #81C784;
}

/* --- Progress Bar --- */
#progress-container {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}