@charset "UTF-8";

/* =========================================
    基本設定
   ========================================= */
:root {
    --bg-deep: #ffffff;
    --text-main: #333;
    --text-highlight: #333;

    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: rgba(0, 0, 0, 0.8);

    --accent-glow: rgba(255, 255, 255, 0.4);
}

html {
    font-size: 16px;
}

@media (max-width: 1000px) { html { font-size: 14px; } }
@media (max-width: 768px) { html { font-size: 11px; } }
@media (max-width: 480px) { html { font-size: 9px; } }

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'DotGothic16', sans-serif;
    margin: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;

    user-select: none;
}

body::before {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    background-image: radial-gradient(rgba(255,255,255,0.2) 1px, transparent 1px);
    background-size: 3rem 3rem;
    opacity: 0.3;
    animation: dust 18s linear infinite;
    z-index: -1;
}

/* =========================================
    レイアウトコンテナ（固定グリッド）
   ========================================= */
.game-container {
    display: grid;
    grid-template-columns: 68% 1fr; 
    grid-template-rows: 8rem 1fr 9rem;
    grid-template-areas:
        "info  menu"
        "char  menu"
        "talk  talk";
    width: 95vw;
    max-width: 64rem;
    max-height: 95vh;
    aspect-ratio: 16/9;
    margin: auto;
    position: relative;
}

/* パネル共通 */
.panel {
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
}

/* =========================================
    1. キャラパネル
   ========================================= */
.char-panel {
    grid-area: char;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    padding-bottom: 0;
}

.main-illustration {
    height: 95%;
    width: auto;
    max-width: 100%;
    padding-bottom: 1rem;
    object-fit: contain;
    object-position: center bottom;
    animation: floatImage 6s ease-in-out infinite;
}

/* =========================================
    2. メニューパネル
   ========================================= */
.menu-panel {
    grid-area: menu;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 0 2rem 1.5rem;
    z-index: 5;
}

ul { list-style: none; padding: 0; margin: 0; width: 100%; }

li {
    padding: 0.6rem 0;
    font-size: 1.5rem;
    opacity: 0.5;
    transition: all 0.2s;
    cursor: pointer;
    color: --text-main;
    white-space: nowrap;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

li:hover {
    opacity: 0.8;
    color: --text-highlight;
}

li.selected {
    opacity: 1;
    color: var(--text-highlight);
    text-shadow: 0 0 0.5rem var(--accent-glow);
    padding-left: 0.5rem;
}

/* =========================================
    3. 会話ウィンドウ（アニメーション修復）
   ========================================= */
.talk-panel {
    grid-area: talk;
    margin: 0 3rem 1rem 3rem;
    padding: 0 2.5rem;

    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    border-radius: 0.5rem;

    display: flex;
    align-items: center;
    z-index: 10;

    height: 100%;
    max-height: 8rem;

    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    opacity: 1;
    transform: translateY(0);
}

.talk-panel.hidden {
    opacity: 0;
    transform: translateY(1.5rem);
    pointer-events: none;
}

#dialogue-text {
    font-size: 1.2rem;
    line-height: 1.6;
    margin: 0;
    width: 100%;
    color: var(--text-main);
}

#next-indicator {
    color: var(--text-highlight);
    animation: blink 1.5s infinite;
    margin-left: 1rem;
}

/* =========================================
    4. 情報パネル
   ========================================= */
.info-panel {
    grid-area: info;
    padding: 1.5rem 2rem;
    color: var(--text-highlight);
    z-index: 5;

    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#info-text {
    border-left: 3px solid var(--text-highlight);
    padding-left: 0.8rem;
    margin: 0;
    line-height: 1.4;
}

/* =========================================
    ポップアップウィンドウ
   ========================================= */
#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
    z-index: 999; display: flex; justify-content: center; align-items: center;
}

.modal-window {
    border: solid var(--glass-border); padding: 2rem;
    background: var(--bg-deep); color: var(--text-highlight);
    text-align: center;
}

.modal-btn {
    display: block; margin: 1rem auto; cursor: pointer; padding: 0.5rem 1.2rem;
    border: #555 solid 1px;;
    background: var(--glass-bg); color: var(--text-main); transition: 0.3s;
}

.modal-btn:hover {
    border-color: #fff; background: #333; color: #fff;
}

.controls-hint {
    position: absolute; bottom: 0.5rem; width: 100%;
    text-align: center; color: #555; font-size: 0.75rem;
}

/* =========================================
    アニメーション定義
   ========================================= */
@keyframes floatImage {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-0.6rem); }
}

@keyframes dust {
    from { background-position: 0 0; }
    to { background-position: 0 -6rem; }
}

@keyframes blink { 
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; } 
}

.volume-control {
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.volume-control:hover {
    opacity: 1;
}

#vol-icon {
    font-size: 1.2rem;
    cursor: pointer;
    width: 1.5rem;
    text-align: center;
}

#vol-slider {
    -webkit-appearance: none;
    width: 6rem;
    height: 4px;
    background: var(--glass-border);
    border-radius: 2px;
    outline: none;
}

#vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--text-highlight);
    border-radius: 50%;
    cursor: pointer;
}


/* =========================================
    文字のアニメーション
   ========================================= */
@keyframes floatText {
    0%, 100% {
        transform: translateY(-5px);
        text-shadow: 0 0 0 transparent;
    }
    50% {
        transform: translateY(5px);
        text-shadow: 0 0 8px var(--accent-glow);
    }
}

li.selected {
    opacity: 1;
    color: var(--text-highlight);
    padding-left: 0.5rem;
    animation: floatText 3s ease-in-out infinite;
}

.floating-char {
    display: inline-block;
    white-space: pre;
    transform-origin: center center;
    animation: smoothFloat 3s ease-in-out infinite alternate;
}

@keyframes smoothFloat {
    0% {
        transform: translateY(-0.4px) rotate(0.2deg);
    }
    100% {
        transform: translateY(0.3px) rotate(-0.2deg);
    }
}

/* =========================================
    モバイル用レスポンシブ設定 (768px以下)
   ========================================= */
@media (max-width: 768px) {

    .game-container {
        width: 100%;
        height: 100dvh;
        max-width: none;
        max-height: none;
        aspect-ratio: unset;
        margin: 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto min-content;
        grid-template-areas:
            "info"
            "char"
            "menu"
            "talk";
        row-gap: 0;
    }

    .info-panel {
        padding: 0.5rem 1rem;
        justify-content: flex-start;
        text-align: right;
    }
    #info-text {
        font-size: 0.9rem;
        border-left: none;
        border-bottom: 1px solid var(--text-highlight);
        display: inline-block;
        padding: 0 0 0.2rem 0;
    }

    .char-panel {
        align-items: center;
        justify-content: flex-end;
        padding-bottom: 0;
        z-index: 1;
        margin-right: 12%;
    }

    .main-illustration {
        width: auto;
        height: auto;
        max-width: 80vw;
        max-height: 45vh;
        padding-bottom: 0;
    }

    .menu-panel {
        padding: 0.5rem 1rem 1rem 1rem;
        justify-content: flex-end;
        align-items: center;
        z-index: 10;
        background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.2));
    }

    #menu-list {
        width: 100%;
        text-align: center;
    }

    li {
        font-size: 1.3rem;
        padding: 0.8rem 0;
        width: 100%;
        text-overflow: clip;
        white-space: normal;
    }
    li.selected {
        padding-left: 0;
        transform: scale(1.05);
        text-shadow: 0 0 10px var(--accent-glow);
    }

    .talk-panel {
        margin: 0 1rem 1.5rem 1rem;
        height: auto;
        min-height: 8rem;
        padding: 1.2rem;
        align-self: end;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(12px);
    }

    #dialogue-text {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .controls-hint {
        display: none;
    }
    .volume-control {
        top: 1rem;
        left: 1rem;
    }
}