/* 1. 基本設定とセーフエリア対応 */
:root {
    --safe-bottom: env(safe-area-inset-bottom);
    --modal-bg: rgba(255, 255, 255, 0.95);
}

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

.hidden {
    display: none !important;
}

/* 8. 言語選択画面 */
.overlay-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.modal-content p {
    font-size: 18px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.btn-group {
    display: flex;
    gap: 20px;
}

/* 汎用的なHTMLボタンデザイン */
button {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: #333;
    transition: transform 0.1s, background 0.2s;
}

button:active {
    transform: scale(0.95);
    background: #ddd;
}

/* 17, 18. UIレイヤー（画面右下のボタン配置） */
.bottom-controls {
    position: fixed;
    bottom: calc(30px + var(--safe-bottom));
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 500;
}

.circle-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #333;
    font-size: 11px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(0,0,0,0.1);
}

/* 19. モーダル共通仕様 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 600;
}

.modal-window {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 33vh; /* 画面の約1/3に固定 */
    background: var(--modal-bg);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding-bottom: calc(10px + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2); /* 少し影をつけて浮かせます */
}

.modal-overlay:not(.hidden) .modal-window {
    transform: translateY(0);
}

.drag-bar {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 12px auto 0; /* 中央配置 */
    flex-shrink: 0; /* 棒が潰れないように固定 */
}

.modal-body {
    padding: 20px 25px; /* 少し余白を詰めました */
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    color: #333;
    line-height: 1.6;
    font-size: 15px; /* 小さめ画面でも読みやすいサイズ */
    word-break: break-word; /* 長い英単語などが枠を突き抜けないようにする */
    text-align: justify;    /* 日本語の行末を綺麗に揃える（お好みで） */
}

/* ドラッグ中の滑らかさを制御するクラス（JSで切り替えます） */
.modal-window.dragging {
    transition: none !important; /* 指に吸い付くようにアニメーションをオフにする */
}