/* Hallmark · playful / tactile arcade · workbench + character stage
 * pre-emit critique: P4 H5 E4 S5 R4 V4 */
/* ===========================================
   Tomo Game - Refined Mobile App UI
   =========================================== */

:root {
    /* Colors */
    --bg-primary: #0a1628;
    --bg-secondary: #0f2847;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-border: rgba(255, 255, 255, 0.1);
    --accent-cyan: #00d4ff;
    --accent-pink: #ff6b9d;
    --accent-orange: #ff8c42;
    --accent-gold: #ffd700;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --danger-red: #ff3366;

    /* Game Sizes */
    --game-width: 440px;
    --game-height: 700px;
    --header-height: 48px;
    --next-height: 44px;
    --evo-height: 36px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(ellipse at top, #1a3a5c 0%, #0f2847 30%, #0a1628 60%, #050d18 100%);
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-font-smoothing: antialiased;
}

/* Stars background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(2px 2px at 200px 50px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 250px 100px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 300px 30px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 350px 80px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(2px 2px at 400px 120px, rgba(255, 255, 255, 0.5), transparent);
    background-size: 450px 150px;
    animation: twinkle 4s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 0.4;
    }
}

/* ===========================================
   Title Screen
   =========================================== */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    animation: fadeIn 0.8s ease;
    background: radial-gradient(ellipse at center, rgba(0, 100, 150, 0.2) 0%, transparent 60%);
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 16px);
    overflow-y: auto;
}

#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('./assets/title.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.3;
    /* 薄く表示 */
    z-index: -1;
    pointer-events: none;
}

#title-screen.hidden {
    display: none;
}

.title-content {
    text-align: center;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 24px 16px;
}

.title-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.title-main {
    display: flex;
    align-items: baseline;
    gap: 12px;
    line-height: 1;
    white-space: nowrap;
}

.title-tomo {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: 4.5rem;
    font-weight: 900;
    color: #ff8c42;
    letter-spacing: -3px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 140, 66, 0.4);
}

.title-game {
    font-family: 'Inter', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: #00d4ff;
    letter-spacing: 6px;
    text-transform: uppercase;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 212, 255, 0.3);
}

.title-tagline {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 6px;
    text-transform: uppercase;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Music Box */
.music-box {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.music-box-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-pink);
    letter-spacing: 5px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.music-box-header::before {
    content: '🎵';
    font-size: 1rem;
}

.music-box-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.music-nav-btn {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.music-nav-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}

.music-info {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.music-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.music-counter {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Start Button */
#start-btn {
    width: 100%;
    padding: 18px 32px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#start-btn:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.15);
}

/* ===========================================
   Game Container
   =========================================== */
#game-container {
    width: 100%;
    max-width: var(--game-width);
    height: var(--game-height);
    max-height: var(--game-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
    z-index: 1;
    padding: 0;
    overflow: hidden;
}

#game-container.hidden {
    display: none;
}

/* ===========================================
   Header
   =========================================== */
#game-header {
    width: 100%;
    height: var(--header-height);
    flex-shrink: 0;
    background: rgba(10, 20, 40, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    /* 余白を埋める */
    min-width: 0;
    /* 縮小許可 */
    margin-right: 4px;
    /* 右側との間隔確保 */
    justify-content: center;
}

.title {
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.title-sub {
    font-size: 0.4rem;
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
    font-style: italic;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    gap: 6px;
    /* 間隔少し狭める */
    flex-shrink: 0;
    /* 右側は縮小させない */
    align-items: center;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    min-width: 44px;
    justify-content: center;
}

.score-label {
    font-size: 0.4rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    line-height: 1;
    white-space: nowrap;
}

.score-value {
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.1;
    transition: transform 0.1s ease;
    white-space: nowrap;
}

.score-card.best .score-value {
    font-size: 0.85rem;
    color: var(--accent-gold);
}

.score-card.max-lv {
    min-width: 36px;
}

.score-card.max-lv .score-value {
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

/* Combo Badge */
/* Combo Badge (Updated Position) */
.combo-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 200;
    margin-top: 0;
    transform: none;

    background: var(--accent-pink);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    padding: 2px 6px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    animation: comboPulse 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    white-space: nowrap;
}

.header-right {
    position: relative;
    /* 基準点にする */
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.combo-badge.hidden {
    display: none;
}

.combo-badge.combo-active {
    animation: comboPulse 0.15s ease;
}

@keyframes comboPulse {
    0% {
        transform: translateX(-50%) scale(0.8);
        /* translateXを維持 */
        opacity: 0;
    }

    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* Combo Pop Effect */
.combo-pop {
    position: absolute;
    pointer-events: none;
    z-index: 26;
    font-size: 1.2rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: var(--accent-pink);
    text-shadow: 0 0 12px rgba(255, 107, 157, 0.6);
    animation: comboPop 1s ease-out forwards;
}

@keyframes comboPop {
    0% {
        transform: translate(-50%, 0) scale(0.8);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -80px) scale(1.3);
        opacity: 0;
    }
}

/* Fever Time */
#game-area.fever-active {
    box-shadow: inset 0 0 30px rgba(255, 215, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.2);
    animation: feverGlow 0.8s ease-in-out infinite alternate;
}

@keyframes feverGlow {
    0% { box-shadow: inset 0 0 30px rgba(255, 215, 0, 0.2), 0 0 15px rgba(255, 215, 0, 0.15); }
    100% { box-shadow: inset 0 0 40px rgba(255, 107, 157, 0.3), 0 0 25px rgba(255, 107, 157, 0.2); }
}

.combo-badge.fever {
    background: linear-gradient(135deg, #ffd700, #ff6b9d);
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    animation: feverBadgePulse 0.5s ease-in-out infinite alternate;
}

@keyframes feverBadgePulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

.fever-announce {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 300;
    font-size: 2rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 107, 157, 0.5);
    pointer-events: none;
    animation: feverAnnounce 1.5s ease-out forwards;
}

@keyframes feverAnnounce {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* Max Level Value in Game Over */
.result-value.max-lv-value {
    font-size: 1rem;
    color: var(--accent-cyan);
}

/* Settings Button */
.settings-btn {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin-left: 4px;
    flex-shrink: 0;
}

.settings-btn:active {
    transform: scale(0.9);
    color: var(--text-primary);
}

/* Settings Panel */
#settings-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 10, 20, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    animation: fadeIn 0.2s ease;
}

#settings-panel.hidden {
    display: none;
}

.settings-content {
    width: 320px;
    max-width: 88vw;
    background: rgba(15, 25, 45, 0.95);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-sizing: border-box;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.settings-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 4px;
}

.settings-close-btn {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.settings-close-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}

.settings-section {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

/* Cast Button */
.cast-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.cast-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.cast-btn:active {
    transform: scale(0.9);
}

/* Cast Panel */
#cast-panel {
    position: fixed;
    /* absolute -> fixed に変更 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 10, 20, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* 最前面に */
    animation: fadeIn 0.2s ease;
    touch-action: pan-y;
    /* bodyのtouch-action:noneを上書きしてスクロール有効化 */
    overscroll-behavior: contain;
    /* スクロールがページ全体に伝播しないように */
}

#cast-panel.hidden {
    display: none;
}

.cast-content {
    width: 450px;
    max-width: 90%;
    max-height: 85vh;
    max-height: 85dvh;
    /* dvh: Androidアドレスバーを考慮した実際の表示領域 */
    background: rgba(15, 25, 45, 0.95);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* はみ出し防止 */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.cast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.cast-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 4px;
}

.cast-close-btn {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.cast-close-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}

.cast-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.cast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
}

.cast-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
}

.cast-image {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
}

.cast-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    text-align: center;
}

.cast-level {
    font-size: 0.55rem;
    color: var(--accent-cyan);
    opacity: 0.8;
}

/* Scrollbar for cast list */
.cast-list::-webkit-scrollbar {
    width: 4px;
}

.cast-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.cast-list::-webkit-scrollbar-thumb {
    background: var(--surface-border);
    border-radius: 4px;
}

/* Cast Detail View */
.cast-nav-btn {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: transparent;
    border: none;
    cursor: pointer;
    letter-spacing: 1px;
    padding: 4px 8px;
    margin-left: -8px;
    transition: all 0.2s ease;
}

.cast-nav-btn:hover {
    color: var(--text-primary);
}

.cast-detail-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.detail-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--surface-border);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.detail-info-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.detail-name {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-primary);
    text-align: center;
}

.detail-level {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    background: rgba(255, 215, 0, 0.1);
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.detail-desc {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.detail-links {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.detail-link-btn {
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-link-btn.twitter {
    background: #000;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.detail-link-btn.instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: #fff;
    border: none;
}

.detail-link-btn.youtube {
    background: #ff0000;
    color: #fff;
    border: none;
}

.detail-link-btn.map {
    background: #34a853;
    color: #fff;
    border: none;
}

.detail-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0.9;
}

/* ===========================================
   Cast Detail Modal (全画面)
   =========================================== */
#cast-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 10, 20, 0.98);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
    padding: 20px;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#cast-detail-modal.hidden {
    display: none;
}

.detail-modal-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    position: relative;
}

.detail-modal-close-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.detail-modal-close-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.12);
}

#cast-detail-modal .detail-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid var(--accent-pink);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    box-shadow: 0 8px 32px rgba(255, 107, 157, 0.3);
    margin-top: 20px;
}

#cast-detail-modal .detail-name {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text-primary);
    text-align: center;
}

#cast-detail-modal .detail-level {
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 16px;
}

#cast-detail-modal .detail-desc {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    text-align: center;
    margin: 16px 0;
}

#cast-detail-modal .detail-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

#cast-detail-modal .detail-link-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 0.9rem;
}

/* ===========================================
   Next Preview
   =========================================== */
#next-preview {
    width: 100%;
    height: var(--next-height);
    flex-shrink: 0;
    background: rgba(10, 20, 40, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.next-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.next-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 3px;
}

.next-cat {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    overflow: hidden;
}

/* Hold feature */
.hold-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hold-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    min-width: 90px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hold-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cyan);
}

.hold-btn:active {
    transform: scale(0.95);
}

.hold-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hold-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.hold-cat {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--surface-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    overflow: hidden;
}

.hold-cat.has-cat {
    border-style: solid;
    background: var(--surface);
}

.hold-count {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-cyan);
    min-width: 16px;
    text-align: center;
}

.hold-count.exhausted {
    color: var(--text-secondary);
}

/* Reroll feature */
.reroll-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reroll-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    min-width: 90px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reroll-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-pink);
}

.reroll-btn:hover .reroll-icon {
    transform: rotate(180deg);
}

.reroll-btn:active {
    transform: scale(0.95);
}

.reroll-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.reroll-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.reroll-icon {
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    transition: transform 0.3s ease;
}

.reroll-count {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-pink);
    min-width: 16px;
    text-align: center;
}

.reroll-count.exhausted {
    color: var(--text-secondary);
}


/* Bomb skip button */
.skip-bomb-btn {
    padding: 6px 16px;
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    background: var(--accent-orange);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 1px;
}

.skip-bomb-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.skip-bomb-btn.hidden {
    display: none;
}

/* Bomb mode */
#next-preview.bomb-mode {
    background: rgba(255, 100, 50, 0.15);
    border-color: rgba(255, 140, 66, 0.4);
}

/* Shake animation */
@keyframes shake {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    5% {
        transform: translate(-30px, -12px) rotate(-5deg);
    }

    10% {
        transform: translate(30px, 10px) rotate(5deg);
    }

    15% {
        transform: translate(-28px, -10px) rotate(-4.5deg);
    }

    20% {
        transform: translate(28px, 12px) rotate(4.5deg);
    }

    25% {
        transform: translate(-25px, -8px) rotate(-4deg);
    }

    30% {
        transform: translate(25px, 8px) rotate(4deg);
    }

    35% {
        transform: translate(-22px, -10px) rotate(-3.5deg);
    }

    40% {
        transform: translate(22px, 10px) rotate(3.5deg);
    }

    45% {
        transform: translate(-18px, -6px) rotate(-3deg);
    }

    50% {
        transform: translate(18px, 6px) rotate(3deg);
    }

    55% {
        transform: translate(-15px, -5px) rotate(-2deg);
    }

    60% {
        transform: translate(15px, 5px) rotate(2deg);
    }

    65% {
        transform: translate(-12px, -4px) rotate(-1.5deg);
    }

    70% {
        transform: translate(12px, 4px) rotate(1.5deg);
    }

    75% {
        transform: translate(-8px, -2px) rotate(-1deg);
    }

    80% {
        transform: translate(8px, 2px) rotate(1deg);
    }

    85% {
        transform: translate(-5px, -1px) rotate(-0.5deg);
    }

    90% {
        transform: translate(5px, 1px) rotate(0.5deg);
    }

    95% {
        transform: translate(-2px, 0) rotate(0deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

.shaking {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ===========================================
   Game Area
   =========================================== */
#game-area {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
    background:
        linear-gradient(180deg,
            rgba(6, 16, 32, 0.7) 0%,
            rgba(10, 22, 40, 0.5) 50%,
            rgba(15, 30, 50, 0.3) 100%),
        url('./assets/beach_night_bg.png');
    background-size: cover;
    background-position: center bottom;
    overflow: hidden;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
}

/* Wall textures */
#game-area::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 15px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 2;
}

#game-area::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 15px;
    background: linear-gradient(270deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 2;
}

/* Danger line */
#danger-line {
    position: absolute;
    top: 100px;
    left: 15px;
    right: 15px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--danger-red), transparent);
    opacity: 0.6;
    z-index: 10;
    animation: dangerPulse 2s ease-in-out infinite;
}

#danger-line::before,
#danger-line::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--danger-red);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--danger-red);
}

#danger-line::before {
    left: 0;
}

#danger-line::after {
    right: 0;
}

@keyframes dangerPulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

#game-canvas {
    display: block;
    position: relative;
    z-index: 1;
}

/* (Evolution Guide styles moved to single block below) */

/* Skip Bomb Button (Highlight) */
.skip-bomb-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff4d4d, #cc0000);
    color: white;
    border: 2px solid #ffcccc;
    padding: 12px 32px;
    border-radius: 30px;
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 2px;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.6);
    cursor: pointer;
    z-index: 1000;
    animation: pulseBtn 1s infinite alternate;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.skip-bomb-btn::before {
    content: '💣';
    font-size: 1.4rem;
}

.skip-bomb-btn:active {
    transform: translateX(-50%) scale(0.95);
    background: #aa0000;
}

@keyframes pulseBtn {
    0% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 4px 15px rgba(255, 0, 0, 0.6);
    }

    100% {
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 0 25px rgba(255, 50, 50, 0.8);
    }
}

/* ===========================================
   Game Over Overlay
   =========================================== */
#game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 10, 20, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

#game-over.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.game-over-content {
    text-align: center;
    padding: 40px 36px;
    background: rgba(15, 25, 45, 0.95);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    width: 340px;
    max-width: 90vw;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gameover-icon {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: 3px;
    margin-bottom: 6px;
}

.game-over-content .subtitle {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.result-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.result-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
}

.result-value.best {
    font-size: 1.3rem;
    color: var(--accent-gold);
}

.result-divider {
    height: 1px;
    background: var(--surface-border);
    margin: 10px 0;
}

.new-record {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 3px;
    margin-top: 12px;
    animation: recordPulse 1s ease-in-out infinite alternate;
}

.new-record.hidden {
    display: none;
}

@keyframes recordPulse {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
    }
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.share-btn {
    padding: 10px 20px;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    color: var(--text-primary);
}

.share-btn:active {
    transform: scale(0.96);
    opacity: 0.8;
}

.share-btn.twitter {
    background: rgba(255, 255, 255, 0.08);
}

.share-btn.line {
    background: rgba(0, 185, 0, 0.15);
    border-color: rgba(0, 185, 0, 0.3);
    color: #4dff4d;
}

/* Continue Button */
/* Continue Button */
.continue-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    background: linear-gradient(135deg, #ff8c42 0%, #ff6b9d 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(255, 140, 66, 0.3);
    white-space: nowrap;
}

.continue-btn .icon {
    font-size: 1.2rem;
}

.continue-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.continue-btn.hidden {
    display: none;
}

/* Ad Loading Countdown */
#countdown-area {
    width: 100%;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

#countdown-area.hidden {
    display: none;
}

#countdown-area p {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#restart-btn {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    background: var(--accent-cyan);
    color: #001a2e;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 2px;
}

#restart-btn:active {
    transform: scale(0.97);
    opacity: 0.85;
}

/* ===========================================
   Evolution Guide - Rebuilt
   =========================================== */
#evolution-guide {
    width: 100%;
    flex-shrink: 0;
    background: rgba(10, 20, 35, 0.92);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: 6px 8px 8px;
    margin: 0;
    position: relative;
    z-index: 10;
}

.guide-title {
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 3px;
    line-height: 1;
}

#evolution-chart {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
    width: 100%;
}

.evo-item {
    width: 30px;
    height: 30px;
    min-width: 30px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    background: var(--surface);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    position: relative;
}

.evo-arrow {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.45rem;
    flex-shrink: 0;
    width: 8px;
    text-align: center;
    line-height: 1;
}

/* Level badge under each item */
.evo-level {
    display: none;
}

/* Responsive: scale items to always fit */
@media (max-width: 440px) {
    #evolution-guide {
        padding: 5px 4px 6px;
    }

    .evo-item {
        width: 26px;
        height: 26px;
        min-width: 26px;
    }

    .evo-arrow {
        width: 6px;
        font-size: 0.4rem;
    }
}

@media (max-width: 360px) {
    #evolution-guide {
        padding: 4px 2px 5px;
    }

    .evo-item {
        width: 23px;
        height: 23px;
        min-width: 23px;
    }

    .evo-arrow {
        width: 5px;
        font-size: 0.35rem;
    }

    .guide-title {
        font-size: 0.4rem;
        letter-spacing: 2px;
        margin-bottom: 3px;
    }
}

@media (max-width: 320px) {
    .evo-item {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }

    .evo-arrow {
        width: 4px;
        font-size: 0.3rem;
    }
}

/* ===========================================
   Merge Effect
   =========================================== */
.merge-effect {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    animation: mergeExpand 0.5s ease-out forwards;
}

@keyframes mergeExpand {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

/* Score pop */
.score-pop {
    position: absolute;
    pointer-events: none;
    z-index: 25;
    font-size: 1rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: var(--accent-gold);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
    animation: scorePop 0.8s ease-out forwards;
}

@keyframes scorePop {
    0% {
        transform: translate(-50%, 0) scale(0.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -60px) scale(1.2);
        opacity: 0;
    }
}

/* ===========================================
   Skill Effect
   =========================================== */
.skill-announce {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.8), 0 0 40px rgba(0, 212, 255, 0.4);
    letter-spacing: 8px;
    z-index: 30;
    pointer-events: none;
    animation: skillAnnounce 1.2s ease-out forwards;
}

@keyframes skillAnnounce {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

.skill-sparkle {
    position: absolute;
    pointer-events: none;
    z-index: 25;
    font-size: 2rem;
    animation: skillSparkle 0.6s ease-out forwards;
}

@keyframes skillSparkle {
    0% {
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2) rotate(180deg);
        opacity: 0;
    }
}

/* ===========================================
   Responsive
   =========================================== */

/* Mobile: align game to top, full-screen */
@media (max-width: 460px) {
    body {
        align-items: flex-start;
        padding: 0;
    }

    :root {
        --game-width: 100vw;
        --game-height: 100dvh;
    }

    #game-container {
        height: 100dvh;
        max-height: 100dvh;
        padding: 0 0 env(safe-area-inset-bottom, 0px) 0;
        border-radius: 0;
    }

    #game-header {
        border-radius: 0;
    }

    #evolution-guide {
        border-radius: 0;
    }
}

/* Tablet: full-screen height, width constrained by aspect ratio */
@media (min-width: 461px) and (max-width: 1024px) {
    body {
        align-items: center;
        padding: 0;
    }

    :root {
        --game-height: 100dvh;
    }

    #game-container {
        height: 100dvh;
        max-height: 100dvh;
        width: min(100vw, calc(100dvh * 440 / 700));
        max-width: min(100vw, calc(100dvh * 440 / 700));
        padding: 0;
        border-radius: 0;
    }

    #game-header {
        border-radius: 0;
    }

    #evolution-guide {
        border-radius: 0;
    }
}

/* PC (large screens): keep centered with fixed aspect ratio */
@media (min-width: 1025px) {
    body {
        align-items: center;
        padding: 16px;
    }

    #game-container {
        /* 高さは画面高さ - padding分に制限、幅はアスペクト比440:700で自動計算 */
        height: min(var(--game-height), calc(100dvh - 32px));
        max-height: min(var(--game-height), calc(100dvh - 32px));
        max-width: min(var(--game-width), calc((100dvh - 32px) * 440 / 700));
    }
}

@media (max-width: 460px) {
    .title {
        font-size: 0.75rem;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .score-card {
        min-width: 60px;
        padding: 5px 10px;
    }

    .game-over-content {
        padding: 32px 24px;
    }
}

/* ===========================================
   Android App Optimized Styles
   =========================================== */

/* Small phones (height < 700px) */
@media (max-height: 700px) {
    .title-content {
        gap: 24px;
    }

    .title-tomo {
        font-size: 3rem;
    }

    .title-game {
        font-size: 1.2rem;
    }

    .title-tagline {
        font-size: 0.6rem;
        letter-spacing: 4px;
    }

    .music-box {
        padding: 16px;
    }

    #start-btn {
        padding: 14px 24px;
        font-size: 0.9rem;
    }
}

/* Medium phones (height 700-850px) */
@media (min-height: 700px) and (max-height: 850px) {
    .title-content {
        gap: 32px;
    }

    .title-tomo {
        font-size: 3.8rem;
    }

    .title-game {
        font-size: 1.5rem;
    }
}

/* Large phones & tablets (height > 850px) */
@media (min-height: 850px) {
    .title-content {
        gap: 44px;
    }

    .title-tomo {
        font-size: 5rem;
    }

    .title-game {
        font-size: 2rem;
    }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .title-content {
        gap: 16px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 90vw;
    }

    .title-logo {
        width: 100%;
    }

    .title-tomo {
        font-size: 2.5rem;
    }

    .title-game {
        font-size: 1rem;
    }

    .title-tagline {
        font-size: 0.55rem;
    }

    .music-box {
        width: auto;
        flex: 1;
        min-width: 200px;
    }

    #start-btn {
        flex: 1;
        min-width: 150px;
        padding: 14px 20px;
    }
}

/* Mobile Responsiveness for Cast Panel */
@media (max-width: 480px) {
    .cast-content {
        width: 92%;
        max-height: 80vh;
        max-height: 80dvh;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        /* ノッチ付き端末の下部セーフエリア対応 */
    }

    .cast-header {
        margin-bottom: 12px;
    }

    .cast-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .detail-image {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .detail-name {
        font-size: 1.2rem;
    }

    .detail-link-btn {
        padding: 8px 16px;
        font-size: 0.7rem;
    }

    .detail-links {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        align-items: center;
    }

    .detail-link-btn {
        width: 100%;
        justify-content: center;
        max-width: 200px;
    }
}

/* 小型Android端末向け (Galaxy A系, Pixel 4aなど 360px幅) */
@media (max-width: 380px) {
    .cast-content {
        width: 95%;
        max-height: 78dvh;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .cast-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .cast-item {
        padding: 8px 6px;
    }

    .cast-image {
        width: 40px;
        height: 40px;
    }

    .cast-name {
        font-size: 0.6rem;
    }

    .detail-image {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .detail-name {
        font-size: 1rem;
    }

    .detail-desc {
        font-size: 0.7rem;
        padding: 0 4px;
    }

    .detail-link-btn {
        padding: 6px 12px;
        font-size: 0.65rem;
    }
}

/* ===========================================
   小型Android端末向け ゲームUI調整 (360px以下)
   Galaxy A系, Pixel 4a, AQUOS sense 等
   =========================================== */
@media (max-width: 360px) {
    :root {
        --game-width: 100vw;
    }

    body {
        padding: 0;
    }

    /* ヘッダー */
    #game-header {
        padding: 0 8px;
    }

    .title {
        font-size: 0.7rem;
    }

    .title-sub {
        display: none;
    }

    .score-card {
        min-width: 48px;
        padding: 4px 6px;
    }

    .score-value {
        font-size: 1rem;
    }

    .score-label {
        font-size: 0.45rem;
    }

    .header-right {
        gap: 4px;
    }

    /* 設定・キャストボタン */
    .settings-btn,
    .cast-btn {
        width: 40px;
        height: 40px;
    }

    /* 設定パネル */
    .settings-content {
        max-width: 92vw;
        padding: 20px 16px;
    }

    /* Next/Hold/Reroll エリア */
    .next-preview {
        padding: 6px 8px;
    }

    .next-cat {
        width: 32px;
        height: 32px;
    }

    /* タイトル画面 */
    .title-content {
        max-width: 95vw;
        padding: 0 8px;
    }

    .title-tomo {
        font-size: 2.5rem;
    }

    .title-game {
        font-size: 1rem;
    }

    .music-box {
        padding: 12px;
    }

    #start-btn {
        padding: 14px 20px;
        font-size: 0.9rem;
    }

    /* ゲームオーバー */
    .game-over-content {
        padding: 24px 16px;
        max-width: 92vw;
    }
}

/* 超小型端末 (320px以下) */
@media (max-width: 320px) {
    :root {
        --game-width: 100vw;
        --header-height: 48px;
    }

    .title {
        font-size: 0.65rem;
    }

    .score-card {
        min-width: 42px;
        padding: 3px 5px;
    }

    .score-value {
        font-size: 0.9rem;
    }

    .settings-btn,
    .cast-btn {
        width: 36px;
        height: 36px;
    }

    .title-tomo {
        font-size: 2rem;
    }

    .title-game {
        font-size: 0.9rem;
    }
}

/* Skill feature */
.skill-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    display: none;
    /* Initially hidden */
}

.skill-inner.visible {
    display: flex;
    /* Show only when ready */
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.skill-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    min-width: 90px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.skill-btn:hover:not(:disabled) {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.skill-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.skill-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.skill-btn.active {
    background: var(--accent-gold);
    color: #000;
    border-color: var(--accent-gold);
    animation: skillPulse 1s infinite alternate;
}

@keyframes skillPulse {
    from {
        box-shadow: 0 0 5px var(--accent-gold);
    }

    to {
        box-shadow: 0 0 15px var(--accent-gold);
    }
}

.skill-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.skill-icon {
    font-size: 1rem;
}

.skill-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: center;
}

.skill-count.ready {
    color: var(--accent-gold);
}

/* ===========================================
   Skill Video Overlay (game-area内)
   =========================================== */
#skill-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

#skill-video-overlay.hidden {
    display: none;
}

#skill-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.skill-video-skip-btn {
    position: absolute;
    bottom: 16px;
    right: 12px;
    padding: 14px 28px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    cursor: pointer;
    z-index: 9999;
    letter-spacing: 2px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.skill-video-skip-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

/* Arcade refresh — scoped to the existing game. */
html, body { overflow-x: clip; }
body { background: var(--color-paper) !important; color: var(--color-ink); font-family: var(--font-body); position: relative; min-height: 100dvh; height: auto; overflow-y: auto; touch-action: auto; }
body::before, body::after { display: none; }
button, a { -webkit-tap-highlight-color: var(--color-clear); touch-action: manipulation; }
button { font-family: var(--font-body); white-space: nowrap; transition: transform var(--dur-short) var(--ease-out), background var(--dur-short); }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(2px) scale(.98); }
button:disabled { cursor: not-allowed; opacity: .4; }
button:focus-visible, a:focus-visible, #game-area:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
button:focus:not(:focus-visible) { outline: none; }
#title-screen { position: relative; min-height: 100dvh; width: min(1080px, 100%); padding: 40px 48px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 56px; background: none; animation: none; overflow: visible; }
#title-screen::before { display: none; }
.title-content { max-width: none; gap: 0; text-align: left; align-items: stretch; padding: 0; }
.back-link { color: var(--color-muted); text-decoration: none; font-size: 12px; align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; margin-bottom: 22px; }
.arcade-eyebrow { color: var(--color-accent); font: 700 10px var(--font-display); letter-spacing: 2px; margin-bottom: 20px; }
.title-logo { align-items: flex-start; gap: 18px; }
.title-main { gap: 10px; flex-wrap: wrap; }
.title-tomo { font: 900 clamp(56px, 6vw, 84px)/.95 var(--font-display); color: var(--color-ink); letter-spacing: -5px; text-shadow: none; }
.title-game { font: 900 clamp(32px, 3.5vw, 46px)/1 var(--font-display); letter-spacing: -2px; color: var(--color-accent); text-shadow: none; }
.title-tagline { font: 900 clamp(16px, 1.8vw, 22px)/1.5 var(--font-body); color: var(--color-ink); letter-spacing: .03em; text-shadow: none; }
.title-description { margin: 14px 0 26px; color: var(--color-muted); font-size: 13px; line-height: 1.9; }
.title-play-actions { display: flex; gap: 20px; align-items: center; }
#start-btn, .primary-button, #restart-btn { background: var(--color-accent); color: var(--color-accent-ink); border: 0; border-radius: var(--radius-control); box-shadow: 0 5px 0 var(--color-accent-deep); font: 900 18px var(--font-body); letter-spacing: .05em; min-height: 56px; padding: 12px 26px; }
#start-btn { flex: 1; width: auto; display: flex; justify-content: space-between; align-items: center; max-width: 260px; }
#start-btn span { font: 700 28px var(--font-display); }
.title-best { display: flex; flex-direction: column; gap: 3px; color: var(--color-muted); font-size: 11px; }
.title-best strong { color: var(--color-ink); font: 800 24px var(--font-display); }
.quick-rules { display: flex; flex-direction: column; gap: 10px; margin: 30px 0 22px; font-size: 12px; }
.quick-rules b { font: 700 10px var(--font-display); color: var(--color-accent); margin-right: 12px; }
.music-box { padding: 14px 0 0; border: 0; border-top: 1px solid var(--color-rule); background: none; border-radius: 0; box-shadow: none; width: 100%; backdrop-filter: none; }
.music-box-header { font-size: 10px; color: var(--color-muted); letter-spacing: 1px; margin-bottom: 4px; text-align: left; }
.music-box-header::before { display: none; }
.music-box-selector { gap: 12px; }
.music-nav-btn { min-width: 44px; height: 44px; border: 1px solid var(--color-rule); border-radius: 10px; background: var(--color-panel); color: var(--color-ink); font-size: 22px; }
.music-name { color: var(--color-ink); font-size: 12px; }
.music-counter { color: var(--color-muted); font-size: 10px; }
.quiet-button { min-height: 44px; padding: 10px 14px; border: 1px solid var(--color-rule); border-radius: 10px; background: var(--color-panel); color: var(--color-ink); font-size: 12px; font-weight: 700; }
.title-content > .quiet-button { align-self: flex-start; margin-top: 12px; }
.title-art { position: relative; min-width: 0; height: 490px; align-self: center; background: var(--color-panel); border: 1px solid var(--color-rule); border-radius: 160px 160px 24px 24px; overflow: hidden; }
.art-caption { position: absolute; top: 52px; width: 100%; text-align: center; font: 700 9px var(--font-display); letter-spacing: 2px; color: var(--color-muted); }
.art-orbit { position: absolute; inset: 100px 24px 60px; border: 1px dashed var(--color-rule); border-radius: 50%; transform: rotate(-20deg); }
.art-ball { position: absolute; object-fit: cover; border-radius: 50%; border: 5px solid var(--color-sky); box-shadow: 0 12px 0 var(--color-shadow); }
.art-ball-one { width: 100px; height: 100px; left: 26px; top: 116px; transform: rotate(-16deg); }
.art-ball-two { width: 126px; height: 126px; right: 25px; top: 94px; border-color: var(--color-coral); transform: rotate(12deg); }
.art-ball-three { width: 150px; height: 150px; left: 18px; bottom: 68px; border-color: var(--color-accent); transform: rotate(-10deg); }
.art-ball-four { width: 184px; height: 184px; right: 12px; bottom: 72px; border-color: var(--color-sky); transform: rotate(8deg); }
.art-merge { position: absolute; top: 228px; left: 50%; transform: translateX(-50%) rotate(-8deg); background: var(--color-accent); color: var(--color-accent-ink); border: 4px solid var(--color-paper); padding: 8px 16px; font: 900 32px var(--font-display); letter-spacing: -1px; }
.art-level { position: absolute; bottom: 25px; width: 100%; text-align: center; color: var(--color-muted); font-size: 11px; font-weight: 700; }
#game-container { width: min(460px, 100vw); max-width: 460px; height: min(900px, calc(100dvh - 24px)); max-height: none; padding: 0; border: 1px solid var(--color-rule); border-radius: 20px; background: var(--color-panel); overflow: hidden; margin: 12px auto; }
#game-header { height: 76px; padding: 10px 12px; background: var(--color-panel); gap: 10px; border: 0; backdrop-filter: none; }
.header-left { min-width: 68px; flex: 0 0 auto; }
.header-left .title { color: var(--color-ink); font: 900 14px var(--font-display); letter-spacing: -.5px; text-shadow: none; background: none; -webkit-text-fill-color: var(--color-ink); }
.title-sub { font: 700 8px var(--font-display); color: var(--color-muted); letter-spacing: 1px; }
.header-right { flex: 1; gap: 7px; justify-content: flex-end; min-width: 0; }
.score-card { padding: 0; background: none; border: 0; border-radius: 0; min-width: 52px; align-items: flex-start; gap: 3px; }
.score-label { font: 700 8px var(--font-display); letter-spacing: 1px; color: var(--color-muted); }
.score-value { font: 900 23px/1.1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--color-accent); text-shadow: none; }
.score-card.best .score-value { color: var(--color-ink); font-size: 16px; }
.score-card.max-lv { display: none; }
.settings-btn, .cast-btn { flex-shrink: 0; width: 40px; height: 44px; background: var(--color-raised); border: 0; color: var(--color-ink); border-radius: 10px; font-size: 11px; }
#chain-panel { width: 100%; padding: 0 14px 9px; flex-shrink: 0; }
.chain-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 10px; margin-bottom: 7px; }
.chain-heading strong { color: var(--color-accent); font-size: 12px; }
.chain-heading span { color: var(--color-muted); font-size: 9px; }
.chain-segments { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.chain-segments i { height: 6px; background: var(--color-raised); border-radius: 2px; transition: background var(--dur-short); }
.chain-segments i.lit { background: var(--color-accent); }
.chain-clock { height: 2px; margin-top: 4px; }
#chain-time { width: 0; height: 100%; background: var(--color-coral); }
#next-preview { order: 3; min-height: 76px; height: auto; padding: 9px 14px; justify-content: space-between; gap: 10px; background: var(--color-panel); border-top: 1px solid var(--color-rule); border-bottom: 0; }
.next-inner { gap: 6px; flex-direction: column; }
.next-label { color: var(--color-muted); letter-spacing: 0; font-size: 10px; }
.next-cat { width: 32px; height: 32px; border: 1px solid var(--color-rule); box-shadow: none; }
.hold-inner, .reroll-inner { gap: 5px; position: relative; }
.hold-btn, .reroll-btn { height: 52px; min-width: 94px; flex-direction: row; justify-content: center; padding: 8px 12px; gap: 8px; border: 1px solid var(--color-rule); border-radius: 12px; background: var(--color-raised); color: var(--color-ink); }
.hold-label, .reroll-label { font-size: 11px; letter-spacing: 0; }
.hold-cat { width: 25px; height: 25px; border: 1px dashed var(--color-muted); background: var(--color-panel); }
.reroll-icon { font-size: 23px; line-height: 1; color: var(--color-accent); }
.hold-count, .reroll-count { min-width: 16px; color: var(--color-accent); font: 700 12px var(--font-display); }
.skill-inner { display: none; }
.skip-bomb-btn { min-height: 44px; font-size: 10px; letter-spacing: 0; padding: 8px; }
#next-preview.bomb-mode .reroll-inner { display: none; }
#game-area { order: 2; width: calc(100% - 20px); margin: 0 10px; min-height: 160px; border: 1px solid var(--color-rule); border-radius: 12px; background-color: var(--color-paper); box-shadow: none; touch-action: none; }
#game-area::before, #game-area::after { pointer-events: none; }
#game-canvas { width: 100%; height: 100%; }
#danger-line { opacity: .45; animation: none; background: none; height: 1px; border-top: 1px dashed var(--color-danger); }
#danger-line::before, #danger-line::after { display: none; }
#play-hint { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--color-ink); z-index: 4; pointer-events: none; transition: opacity .25s; }
#play-hint.used { opacity: 0; }
#milestone { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); z-index: 30; padding: 7px 14px; background: var(--color-accent); color: var(--color-accent-ink); border-radius: 6px; font-size: 12px; font-weight: 900; pointer-events: none; opacity: 0; white-space: nowrap; }
#milestone.visible { opacity: 1; }
#evolution-guide { order: 4; padding: 8px 12px 10px; background: var(--color-paper); border: 0; }
.guide-title { display: flex; justify-content: space-between; color: var(--color-muted); font-size: 9px; letter-spacing: 0; margin-bottom: 8px; }
.guide-title span { font-weight: 400; }
#evolution-chart { justify-content: space-between; }
.evo-item { width: clamp(19px, 5.1vw, 29px); min-width: 0; height: clamp(19px, 5.1vw, 29px); border-color: var(--color-rule); }
.evo-arrow { width: 7px; color: var(--color-muted); }
#settings-panel, #cast-panel, #cast-detail-modal, #game-over { background: var(--color-overlay); backdrop-filter: blur(8px); padding: 20px; overflow-y: auto; }
.settings-content, .cast-content, .detail-modal-content, .game-over-content { background: var(--color-panel); border: 1px solid var(--color-rule); border-radius: 20px; box-shadow: 0 20px 80px var(--color-shadow); color: var(--color-ink); max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-content { width: min(400px, 100%); padding: 24px; }
.settings-title { color: var(--color-ink); font-size: 22px; letter-spacing: 0; }
.settings-close-btn, .cast-close-btn, .detail-modal-close-btn { min-width: 44px; min-height: 44px; }
.preference-buttons { display: flex; gap: 8px; margin-top: 20px; }
.preference-buttons > button { flex: 1; padding-inline: 8px; }
.settings-help { color: var(--color-muted); line-height: 1.9; font-size: 11px; margin: 20px 0; }
.primary-button { width: 100%; font-size: 14px; }
.game-over-content { width: min(380px, 100%); padding: 26px; }
.gameover-icon { color: var(--color-accent); font: 900 34px var(--font-display); letter-spacing: -1px; text-shadow: none; }
.game-over-content .subtitle { font-size: 11px; color: var(--color-muted); margin: 8px 0 18px; }
.run-summary { display: flex; justify-content: center; gap: 24px; font-size: 11px; color: var(--color-muted); margin-bottom: 18px; }
.run-summary strong { color: var(--color-accent); font: 800 22px var(--font-display); padding-left: 5px; }
.result-card { background: var(--color-paper); border: 1px solid var(--color-rule); border-radius: 12px; padding: 16px; }
.result-value { color: var(--color-ink); font-size: 28px; }
#restart-btn { width: 100%; margin-top: 14px; font-size: 16px; }
.continue-btn { background: var(--color-raised); border: 1px solid var(--color-rule); color: var(--color-ink); font-size: 12px; min-height: 44px; letter-spacing: 0; }
.merge-ring { position: absolute; width: 32px; height: 32px; border: 3px solid var(--color-accent); border-radius: 50%; pointer-events: none; z-index: 12; animation: arcade-ring .5s var(--ease-out) forwards; }
.merge-spark { position: absolute; width: 6px; height: 10px; background: var(--color-accent); border-radius: 2px; pointer-events: none; z-index: 13; animation: arcade-spark .65s var(--ease-out) forwards; }
.merge-spark:nth-child(3n) { background: var(--color-coral); }
.merge-spark:nth-child(3n + 1) { background: var(--color-sky); }
.score-pop { color: var(--color-accent); font-family: var(--font-display); text-shadow: 0 2px 3px var(--color-paper); }
.combo-badge { top: 12px; right: 12px; border-radius: 8px; font: 900 18px var(--font-display); }
#game-area.fever-active { border-color: var(--color-accent); box-shadow: inset 0 0 0 2px var(--color-accent); animation: none; }
.fever-announce { color: var(--color-accent); font-family: var(--font-display); font-size: clamp(20px, 6vw, 32px); }
@keyframes arcade-ring { from { transform: translate(-50%, -50%) scale(.5); opacity: 1; } to { transform: translate(-50%, -50%) scale(4); opacity: 0; } }
@keyframes arcade-spark { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(var(--spark-x), var(--spark-y)) rotate(160deg); opacity: 0; } }
@media (max-width: 760px) {
    #title-screen { max-width: 460px; display: flex; padding: 24px; gap: 0; justify-content: center; }
    .title-content { width: 100%; }
    .back-link { margin-bottom: 8px; }
    .arcade-eyebrow { margin-bottom: 14px; }
    .title-tomo { font-size: 62px; }
    .title-game { font-size: 38px; }
    .title-art { display: none; }
    .title-description { margin-bottom: 20px; }
    .quick-rules { margin: 25px 0 20px; }
}
@media (max-width: 480px) {
    #game-container { width: 100%; height: 100dvh; max-width: 100%; border: 0; border-radius: 0; margin: 0; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
    #game-header { height: 70px; padding-inline: 12px; }
    #game-area { width: calc(100% - 16px); margin-inline: 8px; }
}
@media (max-width: 360px) {
    #title-screen { padding: 20px; }
    .title-tomo { font-size: 54px; }
    .title-game { font-size: 30px; }
    .title-tagline { font-size: 15px; }
    .header-left { min-width: 62px; }
    .header-left .title { font-size: 12px; }
    .header-right { gap: 5px; }
    .score-card { min-width: 44px; }
    .score-value { font-size: 20px; }
    .settings-btn, .cast-btn { width: 36px; }
    .hold-btn, .reroll-btn { min-width: 84px; padding-inline: 8px; }
    #next-preview { gap: 5px; padding-inline: 10px; }
}
@media (max-height: 650px) {
    #title-screen { padding-block: 12px; }
    .back-link { margin-bottom: 0; }
    .title-description { margin-block: 10px 16px; }
    .quick-rules { margin-block: 20px 14px; gap: 6px; }
    .title-art { height: 450px; }
    #game-header { height: 60px; }
    #next-preview { min-height: 64px; padding-block: 5px; }
    #evolution-guide { padding-block: 5px; }
}
@media (orientation: landscape) and (max-height: 500px) {
    #game-container { height: 620px; min-height: 620px; width: 380px; margin: 12px auto; }
}
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
body.reduced-motion .merge-spark, body.reduced-motion .merge-ring, body.reduced-motion .merge-effect { display: none; }
body.reduced-motion .score-pop, body.reduced-motion .combo-pop, body.reduced-motion .fever-announce { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* Keep the portrait playfield proportionate on short desktop windows. */
@media (min-width: 761px) and (min-height: 501px) {
    #game-container { max-width: min(460px, calc((100dvh - 250px) * .86)); }
}
.settings-section { background: var(--color-paper); border: 1px solid var(--color-rule); margin-top: 20px; border-radius: 12px; }
#settings-panel .settings-content { display: flex; flex-direction: column; }
#settings-panel .settings-header { order: 0; }
#settings-panel .settings-section { order: 1; }
#settings-panel .preference-buttons { order: 2; }
#settings-panel .settings-help { order: 3; }
#settings-panel .primary-button { order: 4; }
