/* --- 変数 --- */
:root {
    --window-bg: #ffffff;
    --text-main: #333;
    --footer-height: 48px;
    --footer-bg: rgba(243, 243, 243, 0.95);
    --border-color: #ccc;
}

/* --- 基本設定 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-image: url('../image/pcbg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', sans-serif;
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    /* ★修正: 画面全体を強制固定して揺れを防止 */
    position: fixed;
    width: 100%;
    overscroll-behavior: none;
    touch-action: none;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: 0;
}

/* --- デスクトップエリア --- */
.desktop-area {
    /* ★修正: 親要素に依存せず、画面左上に絶対固定 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 15px;
    z-index: 1;
    /* エリア自体は背後の操作を邪魔しないようにするが、アイコンは押せるようにする */
    pointer-events: none;
}

/* --- アイコン --- */
.icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 4px;
    transition: background-color 0.1s;
    position: relative;
    /* ★修正: pointer-events: noneの親の中でもクリックできるようにする */
    pointer-events: auto;
}

.icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.icon:active {
    background-color: rgba(255, 255, 255, 0.3);
}

.icon-img {
    font-size: 40px;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.icon-label {
    font-size: 13px;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    text-align: center;
    line-height: 1.2;
    word-break: break-all;
}

/* 通知バッジ */
.notification-badge {
    position: absolute;
    top: 5px;
    right: 15px;
    background-color: #ff3b30;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* --- ウィンドウ (共通) --- */
.window {
    position: fixed;
    background-color: var(--window-bg);
    display: none;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
    overflow: hidden;
    border: 1px solid #999;
}

.window-header {
    height: 36px;
    background-color: #e6e6e6;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    flex-shrink: 0;
    user-select: none;
}

.window-title {
    font-weight: bold;
    font-size: 13px;
    color: #333;
}

.close-btn {
    font-size: 20px;
    color: #666;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    line-height: 1;
}

.close-btn:hover {
    background-color: #ff5f57;
    color: white;
}

.window-frame {
    flex: 1;
    border: none;
    width: 100%;
    height: 100%;
    background: #fff;
}

/* --- フッター --- */
.footer {
    height: var(--footer-height);
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    /* ★修正: スマホでの位置ズレ防止のため fixed に変更 */
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 25px;
    z-index: 2000;
    justify-content: space-between;
}

.footer-left {
    display: flex;
    align-items: center;
}

.start-btn {
    font-size: 24px;
    padding: 0 10px;
    cursor: pointer;
    color: #444;
    transition: transform 0.1s;
}

.start-btn:active {
    transform: scale(0.9);
}

.footer-center {
    font-size: 10px;
    color: #666;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sp-br {
    display: none;
}

.footer-msg-text {
    display: inline-block;
    white-space: nowrap;
}

.copyright {
    opacity: 0.7;
    font-size: 9px;
    display: block;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ★修正: 位置調整を追加 */
.hint-btn {
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    transition: transform 0.1s;
    user-select: none;
    line-height: 1;
    position: relative;
    /* 位置調整用 */
    left: 4px;
    /* 少し右（時計側）に移動 */
}

.hint-btn:hover {
    opacity: 0.8;
}

.hint-btn:active {
    transform: scale(0.9);
}

.clock-area {
    font-size: 14px;
    padding: 0 10px;
    border-radius: 4px;
    cursor: default;
    text-align: right;
    line-height: 1.1;
}

.clock-area span:last-child {
    font-size: 11px;
    display: block;
}

.clock-area:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* --- オーバーレイ --- */
#shutdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.0s ease-in-out;
}

#shutdown-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* --- 通知トースト (PC: 右下から) --- */
#notification-toast {
    position: fixed;
    bottom: 60px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.98);
    border-left: 5px solid #0078d7;
    border-radius: 4px;
    padding: 15px;
    width: 300px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transform: translateX(120%);
    transition: transform 0.3s ease-out;
    z-index: 5000;
    cursor: pointer;
}

#notification-toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 24px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.toast-message {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* ==================================== */
/* --- PC / スマホ 切り替え --- */
/* ==================================== */

/* スマホ (768px以下) */
@media (max-width: 768px) {

    .sp-br {
        display: block;
    }

    .window {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .window-header {
        height: 48px;
    }

    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 24px;
    }

    .footer {
        /* ★修正: スマホでのフッター高さを60pxから45pxに縮小 */
        height: 45px;
        padding: 0 15px;
    }

    .footer-center {
        display: flex;
        transform: scale(0.8);
        width: 100%;
        overflow: hidden;
    }

    .footer-msg-text {
        white-space: normal;
        font-size: 9px;
        line-height: 1.1;
    }

    .footer-right {
        gap: 5px;
    }

    .start-btn {
        padding: 0 5px;
    }

    /* スマホ用通知: 上部からスライド (中央維持) */
    #notification-toast {
        bottom: auto;
        top: 20px;
        left: 50%;
        right: auto;
        width: 95%;
        border-left: none;
        border-top: 5px solid #0078d7;
        transform: translate(-50%, -200%);
    }

    #notification-toast.show {
        transform: translate(-50%, 0);
    }
}

/* PC (769px以上) */
@media (min-width: 769px) {
    .window {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 800px;
        height: 600px;
        max-width: 90%;
        max-height: 85%;
        border-radius: 2px;
    }

    #win-browser {
        width: 90%;
        height: 85%;
        max-width: 1200px;
    }

    #win-spreadsheet {
        width: 400px;
        height: 700px;
    }

    #win-mail {
        width: 900px;
        height: 600px;
    }

    #win-memo {
        width: 600px;
        height: 500px;
    }
}