/* minigame.css */

/* === 0. カーソル設定 (全体 & 各種) === */
body {
    cursor: url('../assets/cursors/cursor-default.png'), auto; /* デフォルト */
}

/* リンクやボタン */
a, button, .clickable, .nav-item, .sidebar-link {
    cursor: url('../assets/cursors/cursor-point.png'), auto !important;
}

/* 固有カーソルクラス */
.cursor-point { cursor: url('../assets/cursors/cursor-point.png'), auto !important; }
.cursor-stroke { cursor: url('../assets/cursors/cursor-stroke.png'), auto !important; } /* なでる */
.cursor-push { cursor: url('../assets/cursors/cursor-push.png'), auto !important; }     /* 家具/選択肢 */
.cursor-grab { cursor: url('../assets/cursors/cursor-grab.png'), auto !important; }     /* 掴む */
.cursor-clean { cursor: url('../assets/cursors/cursor-clean.png'), auto !important; }   /* 掃除 */
.cursor-message { cursor: url('../assets/cursors/cursor-message.png'), auto !important; } /* 話す */
.cursor-shop { cursor: url('../assets/cursors/cursor-grab-star.png'), auto !important; }  /* 交換所 */


/* === 1. 基本レイアウト & お部屋の背景 === */
/* ★修正: レイアウト崩れ防止のため absolute に変更 */
#page-minigame {
    position: absolute; 
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background-color: #fdfbf7;
    display: none; /* 初期状態は非表示 */
}
/* アクティブ時は style.css の .page.active が display:flex/block にしてくれる */

.hakoniwa-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.room-background {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    display: flex;
    flex-direction: column;
}

/* --- 壁紙バリエーション (5種類・透過なし) --- */
.room-wall {
    height: 35%; 
    box-sizing: border-box;
    transition: background 0.3s;
    border-bottom: 8px solid rgba(0,0,0,0.05);
}

/* 0. ピンクストライプ */
.room-wall.wall-0 {
    background-color: #fff0f5;
    background-image: repeating-linear-gradient(90deg, #fff0f5, #fff0f5 20px, #ffe4e1 20px, #ffe4e1 40px);
}
/* 1. ミントグリーン */
.room-wall.wall-1 {
    background-color: #e0f2f1;
    background-image: radial-gradient(#b2dfdb 15%, transparent 16%);
    background-size: 30px 30px;
}
/* 2. イエローチェック */
.room-wall.wall-2 {
    background-color: #fffde7;
    background-image: linear-gradient(0deg, transparent 24%, #fff59d 25%, #fff59d 26%, transparent 27%, transparent 74%, #fff59d 75%, #fff59d 76%, transparent 77%, transparent), linear-gradient(90deg, transparent 24%, #fff59d 25%, #fff59d 26%, transparent 27%, transparent 74%, #fff59d 75%, #fff59d 76%, transparent 77%, transparent);
    background-size: 50px 50px;
}
/* 青ストライプ */
.room-wall.wall-3 {
    background-color: #98c2e7;
    background-image: repeating-linear-gradient(90deg,#f0f8ff,#f0f8ff 20px,#e0f0ff 20px,#e0f0ff 40px);
}

/* 4. クラシックローズ */
.room-wall.wall-4 {
    background-color: #fce4ec;
    background-image: radial-gradient(circle, #f8bbd0 2px, transparent 2.5px);
    background-size: 20px 20px;
}

/* --- 床バリエーション (5種類・透過なし) --- */
.room-floor {
    flex: 1;
    transition: background 0.3s;
}

/* 0. ナチュラルウッド */
.room-floor.floor-0 {
    background-color: #f6e6cd;
    background-image: linear-gradient(90deg, rgba(255,255,255,0.3) 2px, transparent 2px);
    background-size: 20px 100%;
    border-top: 2px solid #deb887;
}
/* 1. ホワイトタイル（修正版：しっかりした陶器風） */
.room-floor.floor-1 {
    background-color: #ffffff;
    /* グレーのラインでタイル目地を表現 */
    background-image: 
        linear-gradient(#e0e0e0 2px, transparent 2px),
        linear-gradient(90deg, #e0e0e0 2px, transparent 2px);
    background-size: 3px 30px; /* タイルのサイズ */
    background-position: center;
    /* 部屋の奥に少し影を落として実在感を出す */
    box-shadow: inset 0 0 60px rgba(0,0,0,0.05);
}
/* 2. ダークウッド */
.room-floor.floor-2 {
    background-color: #8d6e63;
    background-image: linear-gradient(0deg, rgba(0,0,0,0.1) 1px, transparent 1px);
    background-size: 100% 30px;
}
/* 3. 畳 (Tatami) */
.room-floor.floor-3 {
    background-color: #dcedc8;
    background-image: repeating-linear-gradient(90deg, transparent, transparent 48px, #aed581 50px);
    border-top: 4px solid #558b2f;
}
/* 4. ピンクラグ */
.room-floor.floor-4 {
    background-color: #f8bbd0;
    background-image: repeating-linear-gradient(45deg, #f48fb1 0, #f48fb1 1px, transparent 0, transparent 50%);
    background-size: 20px 20px;
}

canvas#game-canvas {
    display: block;
    width: 100%; height: 100%;
    position: relative; z-index: 1;
    image-rendering: pixelated;
}

/* === UI === */
.game-overlay-ui {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; display: flex; flex-direction: column;
    justify-content: space-between; padding: 15px; box-sizing: border-box;
    z-index: 10;
}
.status-panel {
    display: flex; gap: 15px;
    background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(4px);
    padding: 6px 12px; border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); pointer-events: auto;
    width: fit-content; margin-top: 10px; 
}
.status-item { display: flex; align-items: center; gap: 8px; }
.status-icon { color: var(--accent-color); font-size: 14px; }
.status-wrapper { display: flex; flex-direction: column; gap: 2px; }
.bar-container { width: 60px; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #ff9a9e, #ffc0cb); transition: width 0.5s; }
.bar-value { font-size: 9px; color: #666; font-weight: bold; text-align: center; line-height: 1; }

.action-dock {
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 12px; pointer-events: auto;
}
.dock-btn {
    background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px); border-radius: 16px;
    width: 55px; height: 55px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative; overflow: hidden;
}
.dock-btn:active { transform: scale(0.9); }
.dock-btn:hover { transform: scale(1.05); background: white; }
.btn-inner {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; color: #555; font-size: 9px; font-weight: 700; gap: 3px;
}
.btn-inner i { font-size: 18px; color: var(--deep-rose); margin-bottom: 1px; }

/* === ショップ === */
#shop-modal {
    position: absolute !important; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 100; display: none;
    justify-content: center; align-items: center;
}
.shop-content {
    background: #fff; padding: 20px; border-radius: 20px;
    width: 85%; max-width: 350px; max-height: 85%;
    display: flex; flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.shop-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 10px;
}
.shop-header h3 { margin: 0; color: var(--deep-rose); font-size: 18px; }
.shop-wallet { font-weight: bold; color: #555; background: #f0f0f0; padding: 4px 10px; border-radius: 10px; font-size: 12px; }
.shop-items-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
    overflow-y: auto; padding: 5px; margin-bottom: 15px;
}
.shop-item {
    background: #fff; border: 2px solid #eee; border-radius: 16px;
    padding: 15px 5px; text-align: center; transition: all 0.2s;
    position: relative; cursor: url('../assets/cursors/cursor-grab-star.png'), auto !important;
}
.shop-item:hover { border-color: var(--secondary-color); transform: translateY(-2px); }
.shop-check {
    position: absolute; top: 5px; right: 5px;
    background: var(--deep-rose); color: white;
    width: 20px; height: 20px; border-radius: 50%;
    font-size: 12px; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.shop-icon { font-size: 50px; display: block; margin-bottom: 10px; line-height: 1; }
.shop-icon-sprite {
    width: 83px; /* 166px / 2 */
    height: 83px; /* 166px / 2 */
    background-image: url('present.png');
    background-size: calc(166px * 3) auto; /* (166px * 6) / 2 */
    background-repeat: no-repeat;
    font-size: 0; /* テキストを非表示 */
    margin: 0 auto 10px;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    transform: scale(1); /* スケールを1にリセット */
}
.shop-name { font-size: 12px; font-weight: bold; color: #333; display: block; }
.shop-price { font-size: 11px; color: var(--accent-color); font-weight: bold; }

/* minigame.css */

/* .shop-icon-sprite の既存の定義を上書き、または修正してください */
.shop-icon-sprite {
    display: inline-block;      /* ブロック要素として表示 */
    background-repeat: no-repeat;
    margin: 0 auto 10px;        /* 中央寄せと下マージン */
    
    /* 以前の transform: scale(1) などを整理 */
    image-rendering: -webkit-optimize-contrast; /* 画像をきれいに */
    border-radius: 8px;         /* 角を少し丸くすると可愛いです */
    
    /* フォールバックの絵文字などを消す */
    color: transparent; 
}

/* もし .shop-icon に font-size: 50px; が効いてレイアウトが崩れる場合は上書き */
.shop-item .shop-icon-sprite {
    font-size: 0; 
}

/* --- スプライトシート座標 --- */
.item-box { background-position: calc(-166px * 0) calc(-166px * 0); }
.item-cutlery { background-position: calc(-166px * 1) calc(-166px * 0); }
.item-teapot { background-position: calc(-166px * 2) calc(-166px * 0); }
.item-pajamas { background-position: calc(-166px * 3) calc(-166px * 0); }
.item-umbrella { background-position: calc(-166px * 4) calc(-166px * 0); }
.item-warmer { background-position: calc(-166px * 5) calc(-166px * 0); }

.item-bathsalt { background-position: calc(-166px * 0) calc(-166px * 1); }
.item-bedsheets { background-position: calc(-166px * 1) calc(-166px * 1); }
.item-souppot { background-position: calc(-166px * 2) calc(-166px * 1); }
.item-printer { background-position: calc(-166px * 3) calc(-166px * 1); }
.item-headset { background-position: calc(-166px * 4) calc(-166px * 1); }
.item-necklace { background-position: calc(-166px * 5) calc(-166px * 1); }

.item-oilset { background-position: calc(-166px * 0) calc(-166px * 2); }
.item-tablecloth { background-position: calc(-166px * 1) calc(-166px * 2); }
.item-mirror { background-position: calc(-166px * 2) calc(-166px * 2); }
.item-guitar { background-position: calc(-166px * 3) calc(-166px * 2); }
.item-cabinet { background-position: calc(-166px * 4) calc(-166px * 2); }
.item-smartphone { background-position: calc(-166px * 5) calc(-166px * 2); }

.item-treasure { background-position: calc(-166px * 0) calc(-166px * 3); }
.item-tissuecase { background-position: calc(-166px * 1) calc(-166px * 3); }

/* 華やかなテーブルクロスの特別スタイル */
.item-tablecloth::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="10"><path d="M0 5 Q 5 0, 10 5 T 20 5" stroke="rgba(0,0,0,0.1)" fill="none" stroke-width="1"/></svg>');
    background-size: 20px 10px;
    opacity: 0.5;
}


/* === 各種モーダル共通ボタン === */
.modal-btn {
    padding: 10px 20px; border-radius: 20px;
    font-weight: bold; font-size: 13px; border: none;
    cursor: url('../assets/cursors/cursor-hand.png'), auto !important;
    transition: opacity 0.2s; background: #eee; color: #555; margin: 5px;
}
.modal-btn.send, .modal-btn.primary {
    background: #ffb6c1 !important; color: white !important;
    box-shadow: 0 4px 10px rgba(255, 182, 193, 0.4);
}
/* 中央寄せ強制用 */
.btn-center {
    display: block !important; margin: 15px auto 0 !important;
    width: fit-content; min-width: 120px;
}

/* === ポップアップ類 === */
.modal-overlay, .feature-unlock-modal, .purchase-success-modal, #complete-modal {
    position: absolute !important; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
    animation: fadeIn 0.3s; border-radius: 0;
}
.unlock-content, .purchase-content {
    background: white; padding: 30px; border-radius: 20px;
    text-align: center; width: 80%; max-width: 300px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); animation: popIn 0.5s;
    border: 4px solid #ffb6c1; 
}
.unlock-icon { font-size: 50px; margin-bottom: 15px; display: block; animation: bounce 1s infinite; }
.unlock-title { color: var(--deep-rose); margin: 0 0 10px 0; font-size: 18px; font-weight: 900; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.level-up-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); z-index: 1000;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
}
.level-up-overlay.show { display: flex; animation: fadeIn 0.3s; }
.level-up-box {
    background: white; padding: 30px; border-radius: 20px;
    text-align: center; color: var(--deep-rose);
    box-shadow: 0 10px 30px rgba(255,183,213,0.5);
    animation: popIn 0.5s;
}

/* === ノベルゲーム風UI === */
#novel-talk-ui {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 160px;
    display: flex; align-items: flex-end; z-index: 50; pointer-events: none;
}
/* --- 1. キャラクター：下から上に登場 --- */
.novel-char-img {
    /* 既存のスタイルを維持しつつ、アニメーション用クラスを追加 */
    position: absolute; left: 0; bottom: 0; height: 140px;
    object-fit: contain; z-index: 70; pointer-events: none;
    filter: drop-shadow(2px 2px 5px rgba(0,0,0,0.2));
    object-position: bottom; /* 画像の下部を基準にする */

    /* 初期状態は画面外（下）に隠す */
    transform: translateY(160px);
    opacity: 0;
    /* ジャンプしないように ease-out に変更 */
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}
/* 登場時のクラス */
.novel-char-img.show {
    transform: translateY(0);
    opacity: 1;
}
/* --- 2. 名前：フェードイン --- */
.novel-name-area {
    /* 既存スタイル */
    position: absolute; top: 41px; left: 122px;
    font-size: 11px; font-weight: 800; color: #000;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
    
    /* アニメーション設定 */
    opacity: 0;
    transition: opacity 1s ease 0.3s; /* 0.3秒待ってからふわっと表示 */
}

/* 登場時のクラス */
.novel-name-area.show {
    opacity: 1;
}

/* --- 3. テキスト：上下中央揃え（前回の修正含む） --- */
.novel-text {
    font-size: 14px; color: #5d4037; font-weight: 700;
    line-height: 1.5; position: absolute; left: 130px;
    
    /* 上下中央揃え設定 */
    top: 85px; 
    transform: translateY(-50%);
    
    /* タイプライター中は改行が崩れないように white-space を指定 */
    white-space: pre-wrap; 
}

/* --- 4. 三角（次はボタン）：点滅 --- */
.novel-next-btn {
    /* 初期状態は非表示（文字が出終わったらJSで表示） */
    display: none;
    pointer-events: none;

    /* 既存の設定 */
    position: absolute; bottom: 10px; right: 10px;
    font-size: 16px; color: #ff9aa2; cursor: url('../assets/cursors/cursor-hand.png'), auto !important;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
/* --- 5. メッセージ枠 --- */
.novel-window {
    position: relative; width: 100%; height: 150px;
    background-image: url('../assets/images/frame.png');
    background-size: 100% 100%; background-position: center;
    pointer-events: auto;
    display: flex; flex-direction: column;
    padding: 30px 35px 20px 45px; box-sizing: border-box;
    z-index: 60; animation: popUp 0.3s ease-out;
    cursor: url('../assets/cursors/cursor-message.png'), auto !important;
}

/* --- 6. 選択肢ボタン：ホバーで揺れるアニメーション --- */
.novel-choices {
    display: flex; gap: 15px; position: absolute;
    bottom: 15px; top: 109px; left: 150px; height: 25px; width: 200px;
}
.novel-choice-btn {
    width: 100%; display: flex; align-items: center; justify-content: center;
    background: #fff; border: 2px solid #ffb6c1; color: #e62e5c;
    border-radius: 15px; padding: 8px 12px;
    font-size: 12px; font-weight: 800;
    transition: all 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: url('../assets/cursors/cursor-push.png'), auto !important;
}
.novel-choice-btn:hover {
    background: #ffb6c1; color: white;
    animation: wobble 0.5s ease-in-out infinite;
}
@keyframes wobble { 0%,100% {transform:rotate(0deg);} 25% {transform:rotate(-3deg);} 75% {transform:rotate(3deg);} }

/* === ゴミ箱 === */
#trash-zone {
    position: absolute; bottom: 20px; left: 50%;
    transform: translateX(-50%) translateY(150px);
    width: 80px; height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #ff6b6b; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 30px; color: #ff6b6b; z-index: 50;
    transition: transform 0.3s, background 0.2s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    pointer-events: none;
}
#trash-zone.active { transform: translateX(-50%) translateY(0); }
#trash-zone.hover { background: #ff6b6b; color: white; transform: translateX(-50%) scale(1.2); }

/* === 模様替えコントローラー（壁・床の名前入り） === */
.redecorate-controls {
    position: absolute; top: 60px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 10px; z-index: 50;
    pointer-events: auto; animation: slideDown 0.3s;
    background: rgba(255,255,255,0.9);
    padding: 10px; border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    white-space: nowrap;
}
@keyframes slideDown { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.redecorate-group {
    display: flex; flex-direction: column; align-items: center;
    width: 120px;
}
.redecorate-label {
    font-size: 10px; color: #888; font-weight: bold; margin-bottom: 4px;
}
.style-change-btn {
    background: white; border: 2px solid var(--deep-rose); color: var(--deep-rose);
    padding: 6px 12px; border-radius: 15px; font-weight: 800; font-size: 11px;
    cursor: url('../assets/cursors/cursor-grab.png'), auto !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.2s;
    width: 100%;
}
.style-change-btn:hover { background: var(--deep-rose); color: white; }
.current-style-name {
    margin-top: 4px; font-size: 10px; font-weight: 800; color: #333;
    background: #f0f0f0; padding: 2px 8px; border-radius: 8px;
}

/* === コンプリートモーダル (中央寄せ修正) === */
.complete-content {
    background: linear-gradient(135deg, #fff 0%, #fff5f8 100%);
    padding: 30px 20px; border-radius: 30px; text-align: center;
    border: 4px solid #ffc0cb;
    box-shadow: 0 10px 40px rgba(255, 105, 180, 0.3);
    animation: popIn 0.5s; width: 80%; max-width: 300px;
    display: flex; flex-direction: column; align-items: center;
}
.complete-icon { font-size: 60px; margin-bottom: 10px; animation: spinPop 1s ease-out; }
.complete-title { color: var(--deep-rose); font-size: 20px; font-weight: 900; margin: 10px 0; }
.complete-msg { font-weight: bold; color: #333; margin-bottom: 5px; line-height: 1.5; }
.complete-sub { font-size: 12px; color: #888; margin-bottom: 20px; }

/* === ボタン固有カーソル === */
#redecorate-btn { cursor: url('../assets/cursors/cursor-grab.png'), auto !important; }
#btn-shop { cursor: url('../assets/cursors/cursor-grab-star.png'), auto !important; }
#btn-food { cursor: url('../assets/cursors/cursor-hand.png'), auto !important; }
#btn-toy { cursor: url('../assets/cursors/cursor-hand.png'), auto !important; }
#btn-clean { cursor: url('../assets/cursors/cursor-clean.png'), auto !important; }
#talk-btn { cursor: url('../assets/cursors/cursor-message.png'), auto !important; }
#redecorate-btn.active { background: var(--deep-rose); border-color: var(--deep-rose); }
#redecorate-btn.active .btn-inner, #redecorate-btn.active .btn-inner i { color: white; }

/* トースト */
.game-toast {
    position: absolute; top: 20%; left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(255, 255, 255, 0.95); color: var(--deep-rose);
    border: 2px solid #ffeff5; padding: 10px 20px; border-radius: 30px;
    font-size: 13px; font-weight: 800; opacity: 0; pointer-events: none;
    transition: all 0.3s; z-index: 20; white-space: nowrap;
    box-shadow: 0 4px 15px rgba(230, 46, 92, 0.15);
}
.game-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); top: 18%; }