:root {
    --brand-color: #4A90E2;
    --bg-ui: #1a252f;
    --text-light: #ecf0f1;
    --btn-go: #2ecc71;
    --btn-turn: #f39c12;
    --btn-active: #d35400;
    --gold: #f1c40f;
}

/* 拡大防止の魔法「touch-action: manipulation;」を追加！ */
* { 
    box-sizing: border-box; 
    user-select: none; 
    -webkit-user-select: none; 
    -webkit-touch-callout: none; 
    touch-action: manipulation; 
}

body {
    margin: 0; padding: 0; width: 100vw; height: 100dvh; display: flex;
    font-family: 'M PLUS Rounded 1c', sans-serif; overflow: hidden; background-color: #000;
}

.hidden { opacity: 0; pointer-events: none; visibility: hidden; z-index: -1 !important; position: absolute; }

#app-container {
    position: relative; width: 100%; height: 100%; background-color: #fff; display: flex; overflow: hidden;
}

.screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #fdf6e3; z-index: 10;
}

/* === スタート＆パスワード画面 === */
.title { font-size: clamp(3rem, 5vw, 4rem); color: var(--brand-color); margin-bottom: 2vh; font-weight: bold; }
.subtitle { font-size: clamp(1.2rem, 2vw, 1.5rem); color: #555; margin-bottom: 4vh; }

.role-buttons { display: flex; gap: 3vw; }
.ui-btn {
    font-family: 'M PLUS Rounded 1c', sans-serif; font-size: clamp(1.2rem, 2vw, 1.8rem); font-weight: bold;
    padding: 1.5vh 3vw; border: none; border-radius: 15px; cursor: pointer;
    box-shadow: 0 6px 0 rgba(0,0,0,0.2); transition: transform 0.1s, box-shadow 0.1s;
}
.ui-btn:active { transform: translateY(6px); box-shadow: none; }
.primary-btn { background-color: #e74c3c; color: white; box-shadow: 0 6px 0 #c0392b; }
.secondary-btn { background-color: #3498db; color: white; box-shadow: 0 6px 0 #2980b9; }

.prompt-text { font-size: clamp(1.5rem, 2.5vw, 2rem); text-align: center; margin-bottom: 2vh; line-height: 1.5; }
.pw-box {
    font-size: clamp(2.5rem, 4vw, 4rem); font-family: monospace; letter-spacing: 10px; background: #fff;
    padding: 1vh 2vw; border: 4px solid #ccc; border-radius: 10px; margin-bottom: 2vh;
}
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1vh; margin-bottom: 2vh; }
.num-btn {
    font-size: clamp(1.5rem, 2.5vw, 2rem); padding: 1.5vh 3vw; border: none; border-radius: 10px;
    background: #bdc3c7; color: #2c3e50; font-weight: bold; cursor: pointer; box-shadow: 0 4px 0 #95a5a6;
}
.num-btn:active { transform: translateY(4px); box-shadow: none; }
.danger-btn { background: #e74c3c; color: white; box-shadow: 0 4px 0 #c0392b; }
.ui-grayout { opacity: 0; pointer-events: none; }

/* === ゲーム画面（70:30） === */
#game-screen { flex-direction: row; background: #000; }
#game-area { width: 70%; height: 100%; position: relative; overflow: hidden; }

/* 地図のズレ防止：強制的にコンテナに合わせる */
.bg-image { width: 100%; height: 100%; object-fit: fill; position: absolute; top: 0; left: 0; z-index: 1; display: block; }
#buildings-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.building-icon { position: absolute; width: 14%; transform: translate(-50%, -50%); filter: drop-shadow(0px 6px 4px rgba(0,0,0,0.3)); }

#route-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }

.gem-character {
    position: absolute; width: 8%; transform: translate(-50%, -85%); z-index: 4;
    transition: left 0.4s ease-in-out, top 0.4s ease-in-out;
}
.ghost { opacity: 0.6; filter: grayscale(50%) sepia(50%) hue-rotate(180deg); z-index: 5; }

@keyframes shake { 0%, 100% { transform: translate(-50%, -85%); } 25% { transform: translate(-55%, -85%); } 50% { transform: translate(-45%, -85%); } 75% { transform: translate(-55%, -85%); } }
.shake { animation: shake 0.3s ease; }

/* 右側パネル */
#ui-area { 
    width: 30%; height: 100%; background-color: var(--bg-ui); 
    padding: 1.5vh 1.5vw; display: flex; flex-direction: column; 
    z-index: 10; color: var(--text-light); overflow-y: auto; 
}
.role-label { font-size: clamp(1rem, 1.5vw, 1.2rem); color: var(--gold); text-align: center; margin-bottom: 0.5vh; font-weight: bold; }
.seed-display { font-size: clamp(1.5rem, 2vw, 2.5rem); text-align: center; letter-spacing: 2px; color: #f1c40f; margin-bottom: 1vh; }
.hint-text { font-size: clamp(0.9rem, 1.2vw, 1.1rem); text-align: center; line-height: 1.5; margin-bottom: 1vh; }

/* 目的地（お店）の表示デザイン */
.target-display { font-size: clamp(0.9rem, 1.2vw, 1.1rem); text-align: center; margin-bottom: 1vh; background: rgba(0,0,0,0.3); padding: 0.5vh; border-radius: 8px; border: 2px dashed #e74c3c; }
.target-name { font-size: clamp(1.5rem, 2vw, 2.2rem); font-weight: bold; color: #e74c3c; font-family: 'Klee One', cursive; text-shadow: 1px 1px 2px #fff; }

.audio-btn { background: #9b59b6; color: white; border: none; padding: 1vh 0.5vw; border-radius: 8px; font-size: clamp(0.9rem, 1.2vw, 1.1rem); cursor: pointer; margin-bottom: 1vh; width: 100%; font-family: 'M PLUS Rounded 1c', sans-serif;}

.controls-container { display: flex; flex-direction: column; gap: 1vh; flex-grow: 0; justify-content: center; margin-bottom: 1vh; }
.control-btn { border: none; border-radius: 10px; color: white; font-family: 'M PLUS Rounded 1c', sans-serif; font-size: clamp(1.2rem, 1.8vw, 1.8rem); font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 1vw; transition: transform 0.1s, box-shadow 0.1s; }
.go-btn { background-color: var(--btn-go); padding: 2vh 1vw; box-shadow: 0 6px 0 #27ae60; }
.go-btn:active { transform: translateY(6px); box-shadow: 0 0 0 #27ae60; }
.turn-buttons { display: flex; gap: 1vw; }
.turn-btn { flex: 1; background-color: var(--btn-turn); padding: 1.5vh 0.5vw; font-size: clamp(0.9rem, 1.2vw, 1.2rem); box-shadow: 0 4px 0 #e67e22; }
.turn-btn:active { background-color: var(--btn-active); transform: translateY(4px); box-shadow: 0 0 0 #e67e22; }
.btn-icon { font-size: clamp(1.2rem, 1.8vw, 2rem); }

/* 下部ボタン群を上に詰め、ジェムナビ用の安全な余白を確保 */
.bottom-controls { 
    display: flex; flex-direction: column; gap: 1vh; 
    margin-top: 1vh; 
    padding-bottom: 10vh; /* ジェムナビが被らないための安全エリア */
}
.action-btn { font-family: 'M PLUS Rounded 1c', sans-serif; font-size: clamp(0.8rem, 1vw, 1.1rem); padding: 1vh; border: none; border-radius: 8px; cursor: pointer; color: white; font-weight: bold;}
.warning-btn { background: #e67e22; }
.success-btn { background: #3498db; }
.quit-btn { background: #7f8c8d; }

/* ジェムナビボタン */
.gem-navi-wrapper { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; align-items: stretch; background: #fff; border-radius: 30px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); border: 3px solid #78C2C4; overflow: hidden; }
.gem-navi-handle { padding: 0 15px; background: #E6E9ED; color: #AAB2BD; cursor: grab; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.gem-navi-btn { background: linear-gradient(135deg, #A0CECB, #78C2C4); color: #fff !important; text-decoration: none; padding: 10px 20px; font-weight: bold; display: flex; align-items: center; gap: 5px; font-size: 1rem; }
.gem-navi-icon { width: 24px !important; height: 24px !important; border-radius: 50% !important; margin-right: 4px !important; }