:root {
    --kyoto-red: #8b0000;
    --kyoto-gold: #c5a059;
    --kyoto-sumi: #1a1a1a;
    --kyoto-paper: #f9f4e8;
    --surface-glass: rgba(255, 255, 255, 0.1);
    --border-glass: rgba(255, 255, 255, 0.2);
    --shadow-premium: 0 20px 40px rgba(0,0,0,0.4);
    --accent-red: #d32f2f;
    --text-primary: #333;
    --text-on-dark: #eee;
}

.hidden { display: none !important; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Zen Maru Gothic', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Disable text selection */
    -webkit-user-select: none;
    -ms-user-select: none;
}

body {
    background: var(--kyoto-sumi);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
}

#game-wrapper {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: radial-gradient(circle, #4a3420 0%, #1a1a1a 100%);
}

#game-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-width: 500px; /* Mobile first constrained for better look on desktop */
    background: var(--kyoto-paper);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    z-index: 10;
}

/* ... */

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* UI HEADER */
#ui-header {
    min-height: 60px;
    padding-top: env(safe-area-inset-top, 0); /* Notch support */
    background: var(--kyoto-red);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* タイトル中央寄せの基準 */
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 5px;
    z-index: 100;
    color: white;
    border-bottom: 2px solid var(--kyoto-gold);
    gap: 5px;
}

.header-left { display: flex; align-items: center; gap: 8px; overflow: hidden; }
#btn-back {
    background: rgba(0,0,0,0.3);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

#stage-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}
#stage-display .label { font-size: 0.6rem; color: var(--kyoto-gold); }
#current-stage-num { font-size: 1.2rem; font-weight: 900; font-family: 'Outfit', sans-serif; transition: color 0.5s, text-shadow 0.5s; }

/* 難易度別カラー */
#stage-display.difficulty-intermediate #current-stage-num {
    color: #e0b0ff; /* 明るい紫：中級 */
    text-shadow: 0 0 8px rgba(224, 176, 255, 0.6);
}

.difficulty-select {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 25px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.diff-btn-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.clear-badge {
    position: absolute;
    top: -12px;
    right: -5px;
    background: #FFD700;
    color: #4a3420;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 5;
    pointer-events: none;
    display: none; /* JSで表示制御 */
    animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #fff;
    white-space: nowrap;
}

@keyframes badgePop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.clear-badge.visible {
    display: block;
}

.btn-difficulty {
    flex: 1;
    min-width: 180px;
    white-space: nowrap;
    font-size: 1rem;
    padding: 15px 10px;
}

.btn-purple {
    background: linear-gradient(135deg, #7b1fa2, #4a148c);
    border-color: #9c27b0;
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 31, 162, 0.4);
}
.btn-purple:hover {
    background: linear-gradient(135deg, #9c27b0, #6a1b9a);
    box-shadow: 0 6px 20px rgba(123, 31, 162, 0.6);
}

.btn-gold {
    background: linear-gradient(135deg, #b8860b, #daa520);
    border-color: #ffd700;
    color: #4a3420;
    box-shadow: 0 4px 15px rgba(184, 134, 11, 0.4);
}
.btn-gold:hover {
    background: linear-gradient(135deg, #daa520, #ffd700);
    box-shadow: 0 6px 20px rgba(184, 134, 11, 0.6);
}

.btn-black {
    background: linear-gradient(135deg, #2c2c2c, #000000);
    border-color: #444;
    color: #ffd700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.4);
}
.btn-black:hover {
    background: linear-gradient(135deg, #444, #1a1a1a);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
    transform: translateY(-2px);
}

.btn-difficulty.locked {
    filter: grayscale(1) brightness(0.4) !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    box-shadow: none !important;
    border-color: #333 !important;
    color: #666 !important;
    text-shadow: none !important;
}

.difficulty-intermediate { color: #9c27b0 !important; font-weight: bold; }
.difficulty-advanced { color: #d4af37 !important; font-weight: bold; text-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
.difficulty-super { color: #ff3333 !important; font-weight: 900; text-shadow: 0 0 12px rgba(255, 0, 0, 0.8); }

#stage-display.difficulty-advanced #current-stage-num {
    color: #ffd700; /* 金色：上級 */
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}
#stage-display.difficulty-super #current-stage-num {
    color: #ff1111; /* 深紅：超級 */
    text-shadow: 0 0 15px rgba(255, 0, 0, 1);
    animation: intensity 1s infinite alternate;
}
@keyframes intensity {
    from { filter: brightness(1); }
    to { filter: brightness(1.5) drop-shadow(0 0 5px #f00); }
}


.header-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    z-index: 5; /* 左右のボタンを隠さないように低めに設定 */
    pointer-events: none;
}

.header-center h1 {
    font-family: 'Noto Serif JP', serif;
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: var(--kyoto-gold);
    display: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

@media (min-width: 440px) { .header-center h1 { display: block; } }

#heart-gauge {
    display: flex;
    gap: 2px;
}
.heart { font-size: 1.2rem; filter: grayscale(1); opacity: 0.3; transition: all 0.3s; }
.heart.active { filter: grayscale(0); opacity: 1; text-shadow: 0 0 10px rgba(255,0,0,0.5); }

#deadline-alert {
    position: absolute;
    bottom: -18px; /* 少し下げて重なりを避ける */
    right: 0;
    color: var(--accent-red);
    font-size: 1.1rem; /* 拡大 */
    font-weight: 900;
    letter-spacing: 0.15em; /* ライフの幅に合わせる */
    font-family: 'Outfit', sans-serif;
    animation: flashDanger 0.8s infinite alternate;
    text-shadow: 0 0 10px rgba(211, 47, 47, 0.8);
    pointer-events: none;
    z-index: 10;
}

@keyframes flashDanger {
    from { opacity: 0.4; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1.1); color: #ffeb3b; }
}

/* MAIN VIEW (BG & Char) */
#main-view {
    flex: 1 1 40%; /* さらに柔軟に */
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #000;
}

#bg-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: filter 0.5s ease;
}

#character-layer {
    position: absolute;
    bottom: 8%; /* 少し上に上げる */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 75%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    z-index: 5;
}

#current-char {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* 美しい枠の追加 */
    border: 3px double var(--kyoto-gold);
    padding: 6px;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(2px);
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.4), 0 10px 25px rgba(0,0,0,0.6);
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5));
    transform: scale(1); /* Reset transform to avoid conflicts */
}

/* STAGE SPLASH */
#stage-splash {
    position: absolute;
    inset: 0;
    z-index: 900;
    background: #000; /* 背後を完全に隠す */
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    transition: opacity 0.5s;
}

.splash-content {
    text-align: center;
    color: var(--kyoto-gold);
    animation: splashIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.splash-label { font-size: 1.2rem; font-weight: 900; margin-bottom: 5px; opacity: 0.8; }
.splash-content h2 { font-size: 2.2rem; font-family: 'Noto Serif JP', serif; margin-bottom: 10px; color: #fff; text-shadow: 0 0 10px var(--kyoto-gold); }
.splash-content p { font-size: 1rem; color: #ccc; font-weight: 500; }

@keyframes splashIn {
    0% { transform: scale(0.8) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

#splash-click-hint {
    margin-top: 45px;
    font-size: 1rem;
    color: var(--kyoto-gold);
    opacity: 0.7;
    font-weight: 700;
    letter-spacing: 0.2em;
    animation: hintPulse 2.5s infinite ease-in-out;
    transition: opacity 0.5s;
    text-shadow: 0 0 10px rgba(197, 160, 89, 0.3);
}

.splash-hint-hidden {
    opacity: 0 !important;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

/* SHAKE ANIMATION (FOR MISTAKES) */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.shake-it {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* JUDGE STAMP (DEPRECATED) */
#judge-icon-overlay {
    display: none;
}

/* STAGE CLEAR OVERLAY */
#clear-overlay {
    position: absolute;
    inset: 0;
    z-index: 250;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.clear-content {
    text-align: center;
    animation: clearPop 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* TITLE SCREEN */
#title-screen {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    overflow: hidden;
}

.title-bg-dim {
    position: absolute;
    inset: 0;
    background-image: url('../assets/bg/title_bg.png');
    background-size: cover;
    background-position: center;
    filter: brightness(0.85);
    animation: bgSlowZoom 20s linear infinite alternate;
}

@keyframes bgSlowZoom {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.title-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #fff;
    width: 90%;
}

.title-main {
    margin-bottom: 50px;
    animation: titleFadeIn 2s ease-out forwards;
}

.title-sub {
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    display: block;
    margin-bottom: 10px;
    color: var(--kyoto-gold);
}

.title-logo {
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(2rem, 11vw, 4.2rem);
    font-weight: 900;
    margin: 0;
    background: linear-gradient(to bottom, #ffffff 0%, #d4d4d4 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 20px rgba(0,0,0,0.5);
    max-width: 100%;
    line-height: 1.2;
}

.title-adventure {
    font-size: 1.5rem;
    letter-spacing: 0.8em;
    margin-top: 5px;
    display: block;
    opacity: 0.7;
}

.title-actions {
    animation: titleFadeIn 2s ease-out 1s forwards;
    opacity: 0;
}

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

/* LANGUAGE SELECTOR */
.lang-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    animation: titleFadeIn 2s ease-out 1.2s forwards;
    opacity: 0;
}

.lang-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(197, 160, 89, 0.4);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
    color: var(--kyoto-gold);
}

/* 右上のツールボタン（全画面表示など） */
.title-tool-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(197, 160, 89, 0.4);
    height: 32px;
    width: auto;
    padding: 0 15px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    color: var(--kyoto-gold);
    white-space: nowrap;
}

.title-tool-btn:hover {
    background: rgba(197, 160, 89, 0.2);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.4);
    transform: scale(1.05);
}

.lang-btn:hover {

    transform: scale(1.1);
    background: rgba(197, 160, 89, 0.2);
    border-color: var(--kyoto-gold);
}

.lang-btn.active {
    background: rgba(197, 160, 89, 0.2);
    border-color: var(--kyoto-gold);
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.3);
}



.title-hint {
    margin-top: 20px;
    font-size: 0.9rem;
    opacity: 0.5;
}

.clear-badge {
    color: var(--kyoto-gold);
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: 0.2em;
    margin-bottom: 5px;
    opacity: 0.8;
}

.clear-text {
    font-family: 'Noto Serif JP', serif;
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(to bottom, #fff7ad 0%, #ffa700 50%, #ff8c00 100%);
    background-clip: text; /* Lint fix */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255,167,0,0.6));
    letter-spacing: 0.1em;
}

@keyframes clearPop {
    0% { transform: scale(0.2); opacity: 0; filter: brightness(3); }
    40% { transform: scale(1.1); opacity: 1; filter: brightness(1); }
    80% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.05); opacity: 1; }
}

#dialogue-area {
    position: absolute;
    bottom: 20px;
    left: 10px;
    right: 10px;
    z-index: 50;
}

.name-tag {
    background: var(--kyoto-red);
    color: white;
    display: inline-block;
    padding: 4px 15px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    border-left: 4px solid var(--kyoto-gold);
    margin-bottom: -5px;
    position: relative;
    z-index: 2;
    font-family: 'Noto Serif JP', serif;
}

.message-box {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--kyoto-gold);
    border-radius: 12px;
    padding: 15px 20px;
    min-height: 80px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
    position: relative;
}

#dialogue-arrow {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.8rem;
    color: var(--kyoto-red);
    animation: bounce 1s infinite;
    display: none;
}

.can-click #dialogue-arrow {
    display: block;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

#main-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.6;
    font-family: 'Noto Serif JP', serif;
}

/* CHOICE AREA */
#choice-area {
    padding: 10px 15px;
    padding-bottom: calc(env(safe-area-inset-bottom, 10px) + 5px); /* Indicator support */
    background: #fff;
    border-top: 1px solid #ddd;
    z-index: 40;
    flex: 0 1 auto; /* Grow only if needed, don't shrink below content */
    min-height: 150px;
    display: flex;
    flex-direction: column;
    /* justify-content: center; はスクロールの妨げになるため削除 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.choice-container {
    display: flex;
    flex-direction: column;
    gap: 8px; /* gapを詰めて省スペース化 */
    margin: auto 0; /* centerの代替として、内容が少ない時は中央寄せにする */
    transition: opacity 0.5s, transform 0.5s;
}

.choice-container.fadeIn {
    animation: choiceIn 0.5s ease-out forwards;
}

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

.choice-btn {
    background: linear-gradient(135deg, #ffffff 0%, #fffbf0 100%);
    border: 1px solid var(--kyoto-gold);
    padding: 12px 15px 12px 40px; /* 余白を詰める */
    border-radius: 12px;
    text-align: left;
    font-size: clamp(0.85rem, 3.5vh, 0.95rem); /* 画面高さに応じてフォントを少し小さく */
    line-height: 1.4;
    font-weight: 700;
    color: #333;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.choice-btn::before {
    content: "🌸";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    filter: drop-shadow(0 0 5px rgba(255,182,193,0.5));
    transition: transform 0.3s;
}

.choice-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--kyoto-red);
    background: #fff;
    box-shadow: 0 8px 20px rgba(139,0,0,0.15);
}

.choice-btn:hover::before {
    transform: translateY(-50%) rotate(20deg) scale(1.2);
}

.choice-btn:active {
    transform: scale(0.98);
}

#choice-area.choice-hidden {
    opacity: 0;
    pointer-events: none;
}
#feedback-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8); /* 少し透明度を下げて背後の雰囲気を残す */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
    opacity: 1;
    transition: opacity 0.3s;
}

.feedback-card {
    background: var(--kyoto-paper);
    width: 85%;
    max-width: 340px;
    padding: 30px 20px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid var(--kyoto-gold);
    box-shadow: var(--shadow-premium);
    position: relative;
}

.result-label {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 20px;
    font-family: 'Noto Serif JP', serif;
}

.result-label.correct { color: #2e7d32; }
.result-label.wrong { color: var(--accent-red); }

#honne-label {
    font-size: 0.8rem;
    color: var(--kyoto-red);
    margin-bottom: 5px;
}

#honne-text {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 30px;
    color: var(--kyoto-sumi);
    line-height: 1.4;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--kyoto-gold);
    color: var(--kyoto-gold);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 900;
    margin-right: 10px;
    cursor: pointer;
}

/* DICTIONARY MODAL */
#dictionary-modal {
    position: fixed; /* absolute→fixed: タイトル画面からも開けるように */
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000; /* 最前面に表示 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.dict-content {
    background: var(--kyoto-paper);
    width: 100%;
    max-height: 80vh;
    border-radius: 15px;
    border: 2px solid var(--kyoto-gold);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.dict-content h3 {
    text-align: center;
    font-family: 'Noto Serif JP', serif;
    margin-bottom: 15px;
    color: var(--kyoto-red);
    border-bottom: 2px solid var(--kyoto-gold);
    padding-bottom: 10px;
}

#dict-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.dict-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #fdfaf5;
    border-left: 4px solid var(--kyoto-red);
    border-radius: 4px;
}
.dict-stage-tag {
    display: inline-block;
    font-size: 0.7rem;
    background: var(--kyoto-red);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-family: 'Outfit', sans-serif;
}

.dict-item .surface {
    font-weight: 900;
    color: var(--kyoto-red);
    font-size: 1rem;
}

.dict-item .honne {
    font-size: 0.85rem;
    color: #555;
    margin-top: 4px;
    font-style: italic;
}

/* MODALS */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s;
}

.modal-content {
    background: var(--kyoto-paper);
    width: 90%;
    max-width: 500px;
    max-height: 85vh; /* 少し広げる */
    border-radius: 20px;
    border: 3px double var(--kyoto-gold);
    padding: 30px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 40px; /* 下部に余白を追加してボタンを押しやすく */
}

/* 右上の×ボタン */
.modal-close-x {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: var(--kyoto-red);
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}

/* 閉じボタン用のスタイル */
.btn-glow {
    background: var(--kyoto-red);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.3);
    transition: all 0.3s ease;
    width: fit-content;
    margin: 20px auto 0;
}

/* 確認モーダル専用：対称ボタンレイアウト */
.modal-btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

.modal-btn-group button {
    flex: 1;
    max-width: 150px;
    padding: 12px 0;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: none;
}

.btn-kyoto-yes {
    background: var(--kyoto-red);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.2);
}

.btn-kyoto-yes:hover {
    background: #a00000;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.3);
}

.btn-kyoto-no {
    background: white;
    color: var(--kyoto-sumi);
    border: 2px solid var(--kyoto-sumi) !important;
}

.btn-kyoto-no:hover {
    background: #f8f8f8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.5);
    background: #a00000;
}

.btn-glow:active {
    transform: translateY(0);
}

.credits-content h3 {
    text-align: center;
    font-family: 'Noto Serif JP', serif;
    font-size: 1.8rem;
    color: var(--kyoto-red);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--kyoto-gold);
    padding-bottom: 15px;
}

.credits-list {
    flex: 1;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.8;
}

.credit-item {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

.credit-item::after {
    content: "・";
    position: absolute;
    left: 0;
    color: var(--kyoto-gold);
}

#btn-close-credits, #btn-close-dict {
    background: var(--kyoto-red);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50px;
    margin-top: 20px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139,0,0,0.3);
}

/* UTILITIES */
.hidden { display: none !important; opacity: 0; pointer-events: none; }

.btn-glow {
    background: var(--kyoto-red);
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 50px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(139,0,0,0.3);
}

.btn-glow:hover {
    transform: scale(1.05);
}

/* LOADING */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--kyoto-sumi);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--kyoto-gold);
}

.loader-container { text-align: center; }
.loader-circle {
    width: 50px;
    height: 50px;
    border: 4px solid var(--kyoto-gold);
    border-top: 4px solid transparent;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* RESULTS */
#result-screen {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, #000, #331111);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* 上詰めにしてスクロール可能に */
    padding: 40px 20px;
    text-align: center;
    color: white;
    overflow-y: auto;
}

/* PCのみ：結果画面を横並び全画面レイアウトに */
@media (min-width: 1024px) {
    #result-screen {
        justify-content: center;
        align-items: center;
        padding: 20px 40px;
        overflow: hidden; /* スクロール無効 */
    }

    .result-content {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 40px;
        width: 100%;
        max-width: 900px;
        max-height: 100%;
        background: none;  /* 枠を外す */
        box-shadow: none;
        border: none;
        padding: 0;
    }

    /* 左カラム：認定証 */
    #certificate-area {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    /* 右カラム：テキスト・ボタン */
    .result-right-col {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        text-align: left;
    }
}

/* result-right-col: モバイルは縦並びブロック */
.result-right-col {
    width: 100%;
    text-align: center;
}

.result-content h2 {
    font-size: 2.5rem;
    font-family: 'Noto Serif JP', serif;
    color: var(--kyoto-gold);
    margin-bottom: 20px;
}

.result-stats {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
}

.btn-premium {
    background: var(--kyoto-gold);
    color: black;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-weight: 900;
    font-size: 1.1rem;
    margin-bottom: 15px;
    cursor: pointer;
    width: 100%;
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    width: 100%;
}

/* ... */
#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* NEW: CERTIFICATE & SHARE */
#certificate-area {
    margin: 20px 0;
    animation: certFadeIn 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

#certificate-canvas {
    width: 100%;
    max-width: 400px;
    height: auto;
    border: 4px solid var(--kyoto-gold);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background: #fff;
}

.share-actions {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.btn-share {
    background: #000;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
}

.btn-share:hover {
    background: #222;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.btn-share-line {
    background: #06c755;
    color: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-share-line:hover {
    background: #05b14c;
    box-shadow: 0 4px 12px rgba(6, 199, 85, 0.3);
    transform: translateY(-2px);
}

/* GUEST NAV */
#guest-nav {
    margin: 20px 0;
    padding: 20px;
    background: rgba(139, 0, 0, 0.1);
    border: 2px dashed var(--kyoto-gold);
    border-radius: 15px;
    animation: pulseBorder 2s infinite alternate;
}

.guest-msg {
    color: var(--kyoto-gold);
    font-weight: 700;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.btn-premium.highlight {
    background: linear-gradient(135deg, var(--kyoto-gold) 0%, #e6c27a 100%);
    box-shadow: 0 0 20px rgba(197, 160, 89, 0.4);
    animation: buttonGlow 2s infinite;
}

@keyframes certFadeIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseBorder {
    from { border-color: var(--kyoto-gold); }
    to { border-color: #fff; }
}

@keyframes buttonGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(197, 160, 89, 0.4); }
    50% { box-shadow: 0 0 25px rgba(197, 160, 89, 0.8); }
}

#result-actions {
    margin-top: 20px;
}

/* BOSS WARNING (Global / Mobile base) */
#boss-warning {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    width: 90%;
    text-align: center;
    pointer-events: none;
    animation: flashWarning 1.5s infinite;
}

.boss-warning-inner {
    display: inline-block;
    background: rgba(139, 0, 0, 0.9);
    border: 2px solid #ff4444;
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.warning-icon {
    margin-right: 5px;
    animation: iconShake 0.5s infinite;
    display: inline-block;
}

@keyframes flashWarning {
    0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); box-shadow: 0 0 0 rgba(255,0,0,0); }
    50% { opacity: 0.8; transform: translateX(-50%) scale(1.05); }
}

@keyframes iconShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px) rotate(-5deg); }
    75% { transform: translateX(2px) rotate(5deg); }
}

/* PC LAYOUT (ADV style) */
@media (min-width: 1024px) {
    #game-container {
        max-width: 1000px;
        height: 650px;
        margin: auto;
        border-radius: 12px;
        border: 4px solid var(--kyoto-gold);
        box-shadow: 0 40px 80px rgba(0,0,0,0.8);
        position: relative;
    }

    #main-view {
        flex: 1;
        position: relative;
    }

    /* Message Window style at bottom */
    #dialogue-area {
        bottom: 30px;
        left: 50px;
        right: 50px;
        z-index: 100;
    }

    .message-box {
        background: rgba(26, 26, 26, 0.9);
        color: #eee;
        border: 2px solid var(--kyoto-gold);
        min-height: 150px;
        padding: 30px 40px;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    }
    
    #main-text {
        color: #fff;
        font-size: 1.4rem;
        line-height: 1.8;
    }

    .name-tag {
        font-size: 1.1rem;
        padding: 8px 25px;
        transform: translateY(-5px);
    }

    /* Choices floating in the middle like Visual Novel */
    #choice-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: transparent !important;
        border: none;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        padding-bottom: 150px;
        z-index: 200;
        pointer-events: none;
    }

    .choice-container {
        width: 500px;
        pointer-events: auto;
    }

    .choice-btn {
        background: rgba(255, 255, 255, 0.98);
        margin-bottom: 20px;
        padding: 18px 25px;
        font-size: 1.2rem;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0,0,0,0.4);
        border: 2px solid var(--kyoto-gold);
        border-radius: 50px; /* Pill shape for cleaner look */
    }

    .choice-btn:hover {
        transform: scale(1.05);
        background: #fff;
    }

    #character-layer {
        bottom: 0;
        height: 95%;
        z-index: 10;
        justify-content: center;
    }

    #current-char {
        height: 100%;
        width: auto;
    }

    /* Particle layer adjustment */
    #particle-canvas {
        z-index: 5;
    }

    /* Feedback overlay on PC */
    .feedback-card {
        width: 600px;
        padding: 40px;
    }

    /* Result screens on PC */
    .result-content {
        max-width: 900px;
    }

    #certificate-canvas {
        max-width: 340px; /* コンパクトに */
        width: 340px;
    }

    .result-content h2 {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }

    .result-content #result-message {
        font-size: 0.95rem;
        margin: 0;
    }

    .result-stats {
        margin: 8px 0;
        padding: 12px 20px;
        width: 100%;
    }

    .share-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    #result-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-premium, .btn-outline {
        width: 100%;
        margin-bottom: 0;
    }

    /* Boss warning: PC版では右上のライフゲージ下に配置して邪魔にならないようにする */
    #boss-warning {
        top: 75px;
        bottom: auto;
        left: auto;
        right: 20px;
        transform: none !important; /* 中央寄せを確実に解除 */
        z-index: 400;
        width: auto;
        text-align: right;
        animation: flashWarningPC 1.5s infinite;
    }
}

@keyframes flashWarningPC {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 rgba(255,0,0,0); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* DEATH SPLASH (GAME OVER REINFORCEMENT) */
#death-splash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(20,0,0,0.7) 0%, rgba(0,0,0,0.95) 100%);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px) grayscale(1);
    transition: opacity 1s;
}

.death-text-container {
    text-align: center;
    color: #8b0000;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.8));
    width: 100%;
}

.death-sub {
    font-size: 1rem;
    letter-spacing: 0.8em;
    color: #666;
    margin-bottom: 5px;
    opacity: 0;
    animation: fadeDown 1.5s ease-out forwards;
}

.death-main {
    font-family: 'Noto Serif JP', serif;
    font-size: 5.5rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    background: linear-gradient(to bottom, #8b0000 0%, #4a0000 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(139,0,0,0.4));
    opacity: 0;
    transform: scale(1.1);
    animation: deathVanish 3.5s ease-out forwards 0.5s;
}

.death-jp {
    font-size: 1.5rem;
    letter-spacing: 0.4em;
    color: #8b0000;
    margin-top: -10px;
    opacity: 0;
    font-weight: 900;
    animation: fadeIn 2s ease-in forwards 1.8s;
}

@keyframes deathVanish {
    0% { opacity: 0; transform: scale(1.1); filter: blur(10px) brightness(2); }
    20% { opacity: 1; transform: scale(1); filter: blur(0) brightness(1); }
    80% { opacity: 1; transform: scale(1); filter: blur(0) brightness(1); }
    100% { opacity: 0; transform: scale(1.05); filter: blur(10px) brightness(0.5); }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 0.6; transform: translateY(0); }
}

/* SUPER FINAL SPLASH */
#super-final-splash {
    position: absolute;
    inset: 0;
    z-index: 1500;
    background: radial-gradient(circle, rgba(20,0,0,0.9) 0%, rgba(0,0,0,0.98) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.super-final-content {
    text-align: center;
    color: #fff;
    perspective: 1000px;
}

.super-final-label {
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(4rem, 15vw, 8rem);
    font-weight: 900;
    color: var(--kyoto-red);
    text-shadow: 0 0 30px rgba(139,0,0,0.8), 0 0 60px rgba(255,0,0,0.4);
    letter-spacing: 0.5em;
    margin-right: -0.5em; /* 最後の一文字の余白を手動調整 */
    opacity: 0;
    transform: translateZ(200px) scale(0.5);
    animation: superFinalTitle 2.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.super-final-sub {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    color: var(--kyoto-gold);
    margin-top: 20px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 1s ease-out forwards 1.2s;
}

@keyframes superFinalTitle {
    0% { opacity: 0; transform: translateZ(200px) scale(0.8); filter: blur(20px); }
    50% { opacity: 1; transform: translateZ(0) scale(1.1); filter: blur(0); }
    100% { opacity: 1; transform: translateZ(0) scale(1); filter: blur(0); text-shadow: 0 0 50px rgba(255,0,0,0.8); }
}

/* STAGE CLEAR OVERLAY */
#stage-clear-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.5s forwards;
}

.stage-clear-content {
    text-align: center;
    animation: clearZoomIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.clear-text {
    font-size: 4rem;
    font-weight: 900;
    color: var(--kyoto-gold);
    text-shadow: 0 0 20px rgba(197, 160, 89, 0.6), 0 0 5px rgba(255,255,255,0.8);
    font-family: 'Noto Serif JP', serif;
    letter-spacing: 0.2em;
    margin-bottom: 20px;
}

.clear-sub {
    font-size: 1.5rem;
    color: #fff;
    font-family: 'Zen Maru Gothic', sans-serif;
    letter-spacing: 0.1em;
    opacity: 0.9;
}

@keyframes clearZoomIn {
    0% { transform: scale(0.5); opacity: 0; filter: blur(10px); }
    100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

/* DIFFICULTY CLEAR OVERLAY (NEW v1.4.5) */
#difficulty-clear-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, #2a0000 0%, #000 100%);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.8s forwards;
}

.diff-clear-content {
    animation: clearPop 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.diff-clear-label {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5rem;
    color: var(--kyoto-gold);
    letter-spacing: 0.5em;
    margin-bottom: 10px;
    opacity: 0.8;
}

.diff-clear-text {
    font-family: 'Noto Serif JP', serif;
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(to bottom, #fff7ad 0%, #ffa700 50%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(255,167,0,0.8));
    letter-spacing: 0.2em;
    margin-right: -0.2em;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================
   ENDING SCREEN
   ============================ */
#ending-screen {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ending-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(139,0,0,0.15) 0%, rgba(0,0,0,0) 70%);
    opacity: 0.3;
}
.ending-scroll-wrapper {
    position: relative;
    width: 100%;
    max-width: 680px;
    height: 100vh;
    overflow: hidden;
}
.ending-scroll-content {
    width: 100%;
    padding: 0 30px 100vh;
    text-align: center;
    animation: endingScroll 55s linear forwards;
}
@keyframes endingScroll {
    0%   { transform: translateY(100vh); }
    100% { transform: translateY(-100%); }
}
.ending-section { margin-bottom: 80px; padding: 20px 0; }
.ending-quote { font-family: 'Noto Serif JP', serif; font-size: 1.5rem; color: #e8d5a3; letter-spacing: 0.1em; line-height: 2; margin-bottom: 20px; text-shadow: 0 0 20px rgba(139,0,0,0.6); }
.ending-narrator { font-family: 'Zen Maru Gothic', sans-serif; font-size: 1.1rem; color: rgba(255,255,255,0.8); letter-spacing: 0.15em; line-height: 2.5; }
.ending-title { font-family: 'Noto Serif JP', serif; font-size: 3rem; font-weight: 900; color: var(--kyoto-gold); letter-spacing: 0.3em; text-shadow: 0 0 30px rgba(197,160,89,0.8); margin-bottom: 15px; }
.ending-subtitle { font-size: 1.2rem; color: rgba(255,255,255,0.5); letter-spacing: 0.5em; }
.ending-credits { border-top: 1px solid rgba(197,160,89,0.3); padding-top: 40px; }
.ending-credit-title { font-size: 0.9rem; color: rgba(255,255,255,0.4); letter-spacing: 0.4em; margin-bottom: 20px; }
.ending-credit-item { font-size: 0.95rem; color: rgba(255,255,255,0.75); line-height: 2.2; }
.ending-final { font-family: 'Noto Serif JP', serif; font-size: 2rem; color: var(--kyoto-gold); letter-spacing: 0.3em; }
.ending-skip-btn { position: fixed; bottom: 30px; right: 30px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.2); padding: 8px 20px; border-radius: 30px; font-size: 0.85rem; cursor: pointer; z-index: 5001; transition: all 0.3s; }
.ending-skip-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* PC版エンディング文字サイズ調整 */
@media (min-width: 1024px) {
    .ending-quote {
        font-size: 1.8rem;
        margin-bottom: 30px;
    }
    .ending-narrator {
        font-size: 1.3rem;
        line-height: 2.8;
    }
    .ending-final {
        font-size: 2.5rem;
    }
    .ending-credit-item {
        font-size: 1.1rem;
    }
}


/* ============================
   SCREEN SIZE SETTINGS (PC)
   ============================ */
.pc-only { display: none !important; }

/* 768px以上（タブレット〜）で表示を許可 */
@media (min-width: 768px) {
    .pc-only { display: flex !important; }

    /* ゲーム中ヘッダーの全画面ボタン調整 */
    #btn-fullscreen-game {
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(197, 160, 89, 0.4) !important;
        margin-right: 15px;
        padding: 5px 12px;
        font-size: 0.75rem;
        height: 32px;
        border-radius: 4px;
        color: var(--kyoto-gold);
        cursor: pointer;
        display: flex;
        align-items: center;
        transition: all 0.3s ease;
        white-space: nowrap;
    }
    #btn-fullscreen-game:hover {
        background: rgba(197, 160, 89, 0.2);
        box-shadow: 0 0 10px rgba(197, 160, 89, 0.3);
    }
}

/* スマホ版（768px以下）タイトル画面のレイアウト調整 */
@media screen and (max-width: 768px) {
    .title-main {
        margin-bottom: 25px; /* スマホでは余白を詰める */
    }
    .title-content {
        padding-top: 10px; /* 上端が切れないように少し下げる */
    }
    .difficulty-selection {
        gap: 8px; /* ボタン間の隙間も詰める */
    }
    .btn-difficulty {
        padding: 12px 10px;
        min-width: 150px;
    }
    #title-screen {
        align-items: flex-start; /* コンテンツが画面より大きい場合に中央寄せで上が切れるのを防ぐ */
        padding: 40px 0; /* 上下の安全マージン */
        overflow-y: auto; /* はみ出し時はスクロール可能に */
    }
}

@media (min-width: 1024px) {
    /* PC版のみ表示する要素（旧設定の互換性維持用だが、現在は768px以上で公開） */
    /* .pc-only { display: flex !important; } は上記に移動 */

    /* 画面サイズ調整クラス（アスペクト比 1000:650 を全体的に一回り縮小してリバランス） */
    #game-wrapper.size-small #game-container { 
        max-width: 800px; 
        height: 520px; 
    }
    #game-wrapper.size-medium #game-container { 
        max-width: 1000px; 
        height: 650px; 
    }
    #game-wrapper.size-large #game-container { 
        max-width: 1200px; 
        height: 780px; 
    }

    /* --- 小サイズ (0.8x) --- */
    #game-wrapper.size-small #main-text { font-size: 1.2rem; }
    #game-wrapper.size-small .choice-container { width: 450px; }
    #game-wrapper.size-small .choice-btn { font-size: 1.1rem; padding: 15px 20px 15px 55px; }
    #game-wrapper.size-small .choice-btn::before { left: 16px; }
    #game-wrapper.size-small .feedback-card { width: 500px; padding: 30px; }

    /* --- 中サイズ (1.0x - 従来の基準) --- */
    #game-wrapper.size-medium #main-text { font-size: 1.4rem; }
    #game-wrapper.size-medium .name-tag { font-size: 1.1rem; padding: 8px 25px; }
    #game-wrapper.size-medium .choice-container { width: 500px; }
    #game-wrapper.size-medium .choice-btn { font-size: 1.2rem; padding: 18px 25px 18px 65px; margin-bottom: 20px; }
    #game-wrapper.size-medium .choice-btn::before { left: 20px; font-size: 1.2rem; }
    #game-wrapper.size-medium .feedback-card { width: 600px; padding: 40px; border-width: 3px; }
    #game-wrapper.size-medium #feedback-result { font-size: 2.2rem; }
    #game-wrapper.size-medium #honne-text { font-size: 1.2rem; }
    #game-wrapper.size-medium .btn-glow { font-size: 1.1rem; padding: 12px 35px; }
    #game-wrapper.size-medium #ui-header { min-height: 60px; }

    /* --- 大サイズ (1.2x - 新たなデフォルト) --- */
    #game-wrapper.size-large #main-text { font-size: 1.6rem; }
    #game-wrapper.size-large .name-tag { font-size: 1.3rem; padding: 10px 30px; }
    #game-wrapper.size-large .choice-container { width: 650px; }
    #game-wrapper.size-large .choice-btn { font-size: 1.4rem; padding: 22px 30px 22px 75px; margin-bottom: 25px; }
    #game-wrapper.size-large .choice-btn::before { left: 24px; font-size: 1.4rem; }
    #game-wrapper.size-large .feedback-card { width: 720px; max-width: none !important; padding: 50px; border-width: 4px; }
    #game-wrapper.size-large #feedback-result { font-size: 2.6rem; }
    #game-wrapper.size-large #honne-text { font-size: 1.4rem; }


    #game-wrapper.size-large .btn-glow { font-size: 1.4rem; padding: 18px 55px; }
    #game-wrapper.size-large #ui-header { min-height: 84px; padding: 0 25px; }
    #game-wrapper.size-large #current-stage-num { font-size: 1.8rem; }
    #game-wrapper.size-large .heart { font-size: 1.8rem; }
    #game-wrapper.size-large #game-title { font-size: 1.3rem; }
}


/* サイズセレクターUI */
.size-selector {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}
.btn-size {
    flex: 1;
    background: #fff;
    border: 1px solid var(--kyoto-gold);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--kyoto-sumi);
    display: flex;
    justify-content: center;
    align-items: center;
}
.btn-size:hover {
    background: var(--kyoto-paper);
    border-color: var(--kyoto-red);
    transform: translateY(-1px);
}
.btn-size.active {
    background: var(--kyoto-red);
    color: #fff !important;
    border-color: var(--kyoto-red);
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.3);
}

/* ============================
   VOLUME SLIDERS & CONTINUE
   ============================ */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    outline: none;
    transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--kyoto-red);
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#continue-area {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 25px;
    perspective: 1000px;
}

#btn-continue-game {
    animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(197, 160, 89, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 8px 25px rgba(197, 160, 89, 0.7); }
    100% { transform: scale(1); box-shadow: 0 4px 15px rgba(197, 160, 89, 0.4); }
}

#btn-continue-stage {
    background: linear-gradient(135deg, var(--kyoto-gold), #8b6d31) !important;
    color: white !important;
    border: 2px solid #fff !important;
}

#btn-config-game {
    font-size: 1.1rem;
    padding: 0 8px;
}

@media screen and (max-width: 768px) {
    #continue-area button {
        width: 100% !important;
        max-width: none !important;
    }
}
