body {
    background: #000;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* タップハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
    /* ズーム防止 */
    touch-action: manipulation;
}

#view {
    position: fixed;
    top: 0;
    left: 0;
}

/* UI Container */
#ui-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    /* safe-area対応 */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

#screen-input.active {
    pointer-events: auto;
}

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

/* UI Button */
.ui-button {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px 60px;
    font-size: 50px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    border-radius: 10px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho Pro', serif;
    /* タップハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
    /* safe-area対応 */
    bottom: calc(5% + env(safe-area-inset-bottom));
}

.ui-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-50%) scale(1.05);
}

/* Paper Container */
#paper-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -70%);
    width: 70vw; /* レスポンシブ対応 */
    max-width: 800px;
    height: calc(70vw * 0.6); /* 横長: 5:3 ratio */
    max-height: 480px;
    pointer-events: auto;
    overflow: visible; /* TornPaperの切り抜きが見えるように */
}

.paper {
    width: 100%;
    height: 100%;
    /* background-image はJavaScriptで動的に設定 */
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5%; /* レスポンシブ対応 */
    box-sizing: border-box;
    /* 一時的に無効化: TornPaper filter */
    /* filter: url(#filter_tornpaper); */
}

/* Textarea */
#text-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: 48px;
    font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho Pro', serif;
    color: #000;
    line-height: 1.8;
    /* 紙の中のスクロールを許可 */
    overflow-y: auto;
    touch-action: pan-y;
    /* タップハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
}

#text-input::placeholder {
    color: rgba(0, 0, 0, 0.6);
}

/* 燃焼アニメーション用 */
#paper-animation-clone {
    position: fixed;
    pointer-events: none;
    z-index: 200;
}

/* 確認ダイアログ */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    pointer-events: auto;
    /* safe-area対応 */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

.dialog-overlay.active {
    display: flex;
}

.dialog-box {
    background: rgba(20, 20, 20, 0.95);
    border: 3px solid white;
    border-radius: 15px;
    padding: 40px 60px;
    text-align: center;
    /* タップハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
}

.dialog-message {
    font-size: 36px;
    color: white;
    font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho Pro', serif;
    margin: 0 0 30px 0;
}

.dialog-sub-message {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho Pro', serif;
    margin: -20px 0 30px 0;
}

.dialog-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.dialog-button {
    padding: 15px 50px;
    font-size: 28px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho Pro', serif;
    /* タップハイライト無効化 */
    -webkit-tap-highlight-color: transparent;
}

.dialog-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ========================================
   モバイル対応 (768px以下)
   ======================================== */
@media screen and (max-width: 768px) {
    /* フォントサイズ調整 */
    .ui-button {
        font-size: 1.5rem;
        padding: 12px 35px;
    }

    #text-input {
        font-size: 20px;
    }

    .dialog-message {
        font-size: 18px;
        margin: 0 0 20px 0;
    }

    .dialog-button {
        font-size: 20px;
        padding: 12px 30px;
    }

    .dialog-box {
        padding: 25px 35px;
        margin: 0 20px;
    }

    /* 紙のサイズ調整 */
    #paper-container {
    transform: translate(-50%, -80%);
        bottom: 15%;
        width: 85vw;
        height: calc(85vw * 0.6);
    }
}

/* ========================================
   小型モバイル対応 (390px以下)
   ======================================== */
@media screen and (max-width: 390px) {
    .ui-button {
        font-size: 1.5rem;
        padding: 10px 25px;
    }

    #text-input {
        font-size: 18px;
    }

    .dialog-message {
        font-size: 16px;
    }

    .dialog-button {
        font-size: 18px;
        padding: 10px 20px;
    }

    .dialog-box {
        padding: 20px 25px;
    }

    #paper-container {
        width: 90vw;
        height: calc(90vw * 0.6);
    }
}
