@charset "UTF-8";

body {
    font-family: "UD Digital Kyokasho-tai-R", sans-serif;
    background-color: #263238;
    color: white;
    margin: 0;
    padding: 0;
    text-align: center;
    overflow: hidden;
    /* スクロール防止 */
    touch-action: none;
    /* スマホでのスクロール防止 */
}

.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    max-width: 800px;
    /* PCでの最大幅 */
    margin: 0 auto;
    position: relative;
}

.game-header {
    background: #37474f;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.game-header h1 {
    font-size: 1.2rem;
    margin: 0;
    color: #ff9800;
}

.btn-home {
    background: #546e7a;
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
}

/* メインエリア */
.main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 人体模型エリア（上部・メイン） */
.model-area-wrapper {
    flex-grow: 1;
    position: relative;
    background: #102027;
    /* 暗い理科室の雰囲気 */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.model-area {
    width: 100%;
    height: 100%;
    max-width: 500px;
    /* スマホ想定 */
    position: relative;
    /* 背景プレースホルダー */
    background: radial-gradient(circle at center, #263238 0%, #000000 100%);
    border: 2px solid #546e7a;
    box-sizing: border-box;
    margin: 10px;
    border-radius: 10px;
}

/* 骨格画像 */
.skeleton-img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.8;
}

/* ドロップゾーン */
.drop-zone {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    /* ガイドとして薄く表示 */
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 20%;
    /* 少し丸く */
    transform: translate(-50%, -50%);
    transition: background 0.3s, border 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    /* デフォルトでは判定無効 */
    opacity: 0;
    /* デフォルトでは非表示（または薄く） */
}

.drop-zone.correct-placed {
    background: transparent;
    border: none;
    opacity: 1 !important;
    /* 配置済みは常に表示 */
    pointer-events: none !important;
    /* もう操作させない */
    animation: none !important;
    /* 点滅停止 */
    z-index: auto !important;
    /* 本来の重なり順に戻す */
}

/* ターゲットゾーンのハイライト */
.target-zone {
    border: 2px dashed #ffff00 !important;
    background: rgba(255, 255, 0, 0.1);
    animation: pulse 1.5s infinite;
    pointer-events: auto !important;
    /* ターゲットのみ判定有効 */
    opacity: 1 !important;
    z-index: 100 !important;
    /* 操作中は最前面 */
}

/* 肺: 最前面・胸部全体 */
.drop-zone[data-organ="hai"] {
    top: 30%;
    left: 50%;
    width: 200px;
    height: 160px;
    z-index: 20;
}

/* 心臓: 肺の間・少し左寄り */
.drop-zone[data-organ="shinzo"] {
    top: 32%;
    left: 56%;
    width: 80px;
    height: 90px;
    z-index: 21;
}

/* 肝臓: 腹部右上（画面左） */
.drop-zone[data-organ="kanzo"] {
    top: 45%;
    left: 42%;
    width: 120px;
    height: 100px;
    z-index: 15;
}

/* 胃: 腹部左上（画面右） */
.drop-zone[data-organ="i"] {
    top: 48%;
    left: 62%;
    width: 100px;
    height: 90px;
    z-index: 14;
}

/* 膵臓: 胃の裏 */
.drop-zone[data-organ="suizo"] {
    top: 50%;
    left: 55%;
    width: 100px;
    height: 50px;
    z-index: 5;
}

/* 腎臓: 背中側・一番奥 */
.drop-zone[data-organ="jinzo"] {
    top: 52%;
    left: 50%;
    width: 160px;
    height: 80px;
    z-index: 4;
}

/* 大腸: 腹部全体を囲む */
.drop-zone[data-organ="daicho"] {
    top: 65%;
    left: 50%;
    width: 190px;
    height: 170px;
    z-index: 10;
}

/* 小腸: 大腸の中 */
.drop-zone[data-organ="shocho"] {
    top: 64%;
    left: 50%;
    width: 110px;
    height: 90px;
    z-index: 11;
}

.drop-zone.highlight {
    background: rgba(255, 255, 0, 0.3);
    box-shadow: 0 0 15px yellow;
    border-color: yellow;
}

.drop-zone.correct-placed {
    background: transparent;
    border: none;
}

/* パーツトレイ（下部） */
.parts-tray {
    height: 120px;
    background: #37474f;
    border-top: 2px solid #546e7a;
    padding: 10px;
    z-index: 30;
    /* 臓器より手前に */
    overflow-x: auto;
    /* 横スクロール */
    white-space: nowrap;
}

.parts-scroll {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    height: 100%;
}

/* ガイドテキスト */
.header-center {
    flex-grow: 1;
    text-align: center;
}

.guide-text {
    margin: 0;
    color: #ffd54f;
    font-size: 1.2rem;
    text-shadow: 0 0 5px #ff6f00;
}

.pop-anim {
    animation: popText 0.3s;
}

@keyframes popText {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* パーツトレイ */
.organ-part {
    width: 80px;
    height: 80px;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.1s, filter 0.3s, opacity 0.3s;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.organ-part.active-target {
    filter: drop-shadow(0 0 10px #ffff00);
    transform: scale(1.05);
}

.organ-part.disabled {
    filter: grayscale(100%) brightness(0.5);
    opacity: 0.5;
    cursor: not-allowed;
}

.organ-part:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.organ-part.placed {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

/* ドラッグ中のスタイル */
.organ-part.dragging {
    opacity: 0.8;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

/* ドロップされたパーツ（盤面上） */
.placed-organ {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* ポップアップ */
.info-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.popup-content {
    background: white;
    color: #333;
    padding: 20px;
    border-radius: 15px;
    width: 80%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: popUp 0.3s ease-out;
}

.popup-content h3 {
    color: #e91e63;
    margin-top: 0;
    font-size: 1.5rem;
}

.popup-content p {
    font-size: 1rem;
    line-height: 1.5;
}

.btn-ok {
    background: #00bcd4;
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 20px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
}

@keyframes popUp {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* オーバーレイ（クリア画面） */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.message-box {
    background: white;
    color: #333;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    width: 80%;
    max-width: 400px;
}

.message-box h2 {
    color: #ff9800;
    font-size: 2rem;
}

/* ポイント獲得ボタン（クリア画面） */
.btn-reward {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: bold;
    display: block;
    width: 100%;
    margin: 10px 0;
    box-shadow: 0 4px #e65100;
    animation: rewardPulse 1.5s ease-in-out infinite;
    font-family: inherit;
    box-sizing: border-box;
}

.btn-reward:active {
    transform: translateY(2px);
    box-shadow: none;
}

.btn-reward:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: default;
    animation: none;
}

@keyframes rewardPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

.btn-retry {
    background: #ff9800;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: bold;
    display: block;
    width: 100%;
    margin: 10px 0;
}

.btn-home-large {
    display: block;
    background: #90a4ae;
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1rem;
    margin-top: 10px;
}