:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(0, 0, 0, 0.7);
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  overflow: hidden;
  height: 100vh;
  display: flex; justify-content: center; align-items: center;
  user-select: none;
  transition: color 1s ease, background-color 1s ease;
}

/* 世界の背景エフェクト */
.world-bg {
  position: absolute; inset: 0; 
  background-color: var(--bg-color);
  transition: background-color 1s ease; 
  z-index: -10;
}
.fog-layer {
  position: absolute; inset: 0;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>');
  opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay;
}
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }

.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }

/* ★幾何学（秩序）とヒビ（混沌）をCSS変数で動的に色変え */
.grid-layer {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none;
}
.crack-layer {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px);
  opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; mix-blend-mode: normal;
}
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

/* コンテナ */
.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; color: inherit; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: var(--card-bg); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); transition: background 1s; }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: var(--card-bg); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn:hover { background: var(--text-color); color: var(--bg-color); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

/* HUDとフィールド */
.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.3); }
.stage-info { font-size: 1rem; font-weight: bold; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.15); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.2); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }

/* パネル */
.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 20px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 90%; max-width: 550px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.5); backdrop-filter: blur(10px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.target-view { font-size: 3.5rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.1rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.9rem; opacity: 0.9; line-height: 1.5; max-height: 120px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.2); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.4); }

/* ランダムイベント結果 */
.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 400px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes pop { 0%{transform:scale(0);} 100%{transform:scale(1);} }

/* リザルト画面 */
.result-header { text-align: center; margin-bottom: 30px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 40px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(10px); transition: background 1s; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 25px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }
.chart-container { display: flex; justify-content: center; margin-bottom: 20px; }
.alignment-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 240px; height: 240px; position: relative; border: 2px solid var(--grid-color); border-radius: 8px; }
.alignment-grid .cell { border: 1px solid var(--grid-color); display: flex; justify-content: center; align-items: center; font-size: 0.7rem; opacity: 0.6; text-align: center; }
.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.7; margin-top: 15px; line-height: 1.5; }

/* 芋虫 */
#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; }
.cat-bubble.hidden { opacity: 0; pointer-events: none; }
.squished { animation: none !important; transform: scaleY(0.2) !important; filter: brightness(0.3); pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(0, 0, 0, 0.75);
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  overflow: hidden; height: 100vh;
  display: flex; justify-content: center; align-items: center;
  user-select: none; transition: color 1s ease, background-color 1s ease;
}

/* 世界の背景エフェクト */
.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }

.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }

.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; mix-blend-mode: normal; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

/* コンテナ */
.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: var(--card-bg); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); transition: background 1s; }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: var(--card-bg); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn:hover { background: var(--text-color); color: var(--bg-color); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.3); }
.stage-info { font-size: 1rem; font-weight: bold; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.15); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.2); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }

/* 吹き出し（フィールド用） */
.field-bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; white-space: nowrap; border: 1px solid #555; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 10; }
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

/* アクションパネル（拡張版） */
.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 25px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 95%; max-width: 650px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.5); backdrop-filter: blur(10px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 10px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; }
.close-btn:hover { opacity: 1; }

.target-view { font-size: 4rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.2rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.95rem; opacity: 0.9; line-height: 1.6; max-height: 150px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.3); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.5); border-color: #fff; }

/* ランダムイベント結果 */
.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 400px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes pop { 0%{transform:scale(0);} 100%{transform:scale(1);} }

/* リザルト画面 */
.result-header { text-align: center; margin-bottom: 30px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 40px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(10px); transition: background 1s; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 25px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }
.chart-container { display: flex; justify-content: center; margin-bottom: 20px; }
.alignment-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 240px; height: 240px; position: relative; border: 2px solid var(--grid-color); border-radius: 8px; }
.alignment-grid .cell { border: 1px solid var(--grid-color); display: flex; justify-content: center; align-items: center; font-size: 0.7rem; opacity: 0.6; text-align: center; }
.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.7; margin-top: 15px; line-height: 1.5; }

/* 芋虫🐛 */
#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; }
.cat-bubble.hidden { opacity: 0; pointer-events: none; }
.squished { animation: none !important; transform: scaleY(0.2) !important; filter: brightness(0.3); pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(0, 0, 0, 0.75);
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }

.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }

.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: var(--card-bg); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); transition: background 1s; }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: var(--card-bg); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn:hover { background: var(--text-color); color: var(--bg-color); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 1rem; font-weight: bold; }
.money-ui { font-size: 1.1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 6px; border: 1px solid #f1c40f; text-shadow: none; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.15); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.2); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.5rem; }

.field-bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; white-space: nowrap; border: 1px solid #555; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 10; text-shadow: none;}
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 25px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 95%; max-width: 650px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.6); backdrop-filter: blur(10px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; }
.close-btn:hover { opacity: 1; }

.target-view { font-size: 4rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.2rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.95rem; opacity: 0.9; line-height: 1.6; max-height: 150px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.3); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.5); border-color: #fff; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 450px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.result-header { text-align: center; margin-bottom: 30px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 40px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(10px); transition: background 1s; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 25px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }
.chart-container { display: flex; justify-content: center; margin-bottom: 20px; }
.alignment-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 240px; height: 240px; position: relative; border: 2px solid var(--grid-color); border-radius: 8px; }
.alignment-grid .cell { border: 1px solid var(--grid-color); display: flex; justify-content: center; align-items: center; font-size: 0.7rem; opacity: 0.6; text-align: center; }
.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.7; margin-top: 15px; line-height: 1.5; }

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }
.squished { animation: none !important; transform: scaleY(0.2) !important; filter: brightness(0.3); pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.75); /* 中立の鈍色に同期 */
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }

.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }

.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: rgba(0,0,0,0.4); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.5); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn:hover { background: var(--text-color); color: var(--bg-color); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 1rem; font-weight: bold; }
.money-ui { font-size: 1.1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 6px; border: 1px solid #f1c40f; text-shadow: none; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.5rem; }

.field-bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; white-space: nowrap; border: 1px solid #555; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 10; text-shadow: none;}
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 25px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 95%; max-width: 650px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7); backdrop-filter: blur(15px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; }
.close-btn:hover { opacity: 1; }

.target-view { font-size: 4rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.2rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.95rem; opacity: 0.9; line-height: 1.6; max-height: 150px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.6); border-color: #fff; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 450px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.result-header { text-align: center; margin-bottom: 30px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 40px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 25px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }
.chart-container { display: flex; justify-content: center; margin-bottom: 20px; }
.alignment-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 240px; height: 240px; position: relative; border: 2px solid var(--grid-color); border-radius: 8px; }
.alignment-grid .cell { border: 1px solid var(--grid-color); display: flex; justify-content: center; align-items: center; font-size: 0.7rem; opacity: 0.6; text-align: center; }
.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.7; margin-top: 15px; line-height: 1.5; }

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }
.squished { animation: none !important; transform: scaleY(0.2) !important; filter: brightness(0.3); pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.75);
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: rgba(0,0,0,0.4); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.5); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; }
.primary-btn:hover { opacity: 0.9; transform: scale(1.02); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 1rem; font-weight: bold; }
.money-ui { font-size: 1.1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 6px; border: 1px solid #f1c40f; text-shadow: none; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.5rem; }
.field-bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; white-space: nowrap; border: 1px solid #555; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 10; text-shadow: none;}
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 25px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 95%; max-width: 650px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7); backdrop-filter: blur(15px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; }
.close-btn:hover { opacity: 1; }

.target-view { font-size: 4rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.2rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.95rem; opacity: 0.9; line-height: 1.6; max-height: 150px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.6); border-color: #fff; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 450px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* リザルト画面・キャプチャエリア */
.result-capture-area { padding: 20px; border-radius: 16px; background-color: var(--bg-color); transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 20px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 30px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.8rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 1px; margin-bottom: 30px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

/* 5x5 チャートコンテナ */
.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 20px; padding: 25px; }
.axis-label { position: absolute; font-size: 0.8rem; opacity: 0.7; font-weight: bold; letter-spacing: 1px; }
.axis-label.top { top: 0; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.axis-label.left { left: -10px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: -15px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { display: flex; justify-content: center; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 250px; height: 250px; position: relative; border: 2px solid var(--grid-color); border-radius: 4px; background: rgba(255,255,255,0.02); }
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: center; align-items: center; }
.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.8; margin-top: 20px; line-height: 1.5; }

/* アクションボタン群 */
.action-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; padding: 0 20px; }

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.85);
  --grid-color: rgba(255, 255, 255, 0.15);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.1"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 20px; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 20px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2.2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 40px; font-weight: 300; opacity: 0.8; }
.warning-text { text-align: center; font-size: 0.8rem; margin-bottom: 20px; opacity: 0.6; }

.input-group { background: rgba(0,0,0,0.4); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 15px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.5); color: inherit; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; border-color: transparent; }
.primary-btn:hover { opacity: 0.9; transform: scale(1.02); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 1rem; font-weight: bold; }
.money-ui { font-size: 1.1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 6px; border: 1px solid #f1c40f; text-shadow: none; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.5rem; font-weight: bold; font-family: monospace; transition: color 0.3s; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 65%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.5rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.5rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 3rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.5rem; }
.field-bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.85); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; white-space: nowrap; border: 1px solid #777; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 10; text-shadow: none; box-shadow: 0 4px 10px rgba(0,0,0,0.5);}
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

.interaction-panel { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 25px; border-radius: 12px; display: flex; align-items: flex-start; gap: 20px; width: 95%; max-width: 650px; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7); backdrop-filter: blur(15px); transition: background 1s; }
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; }
.close-btn:hover { opacity: 1; }

.target-view { font-size: 4rem; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.target-content h3 { font-size: 1.2rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 8px; margin-bottom: 5px; }
.info-log { font-size: 0.95rem; opacity: 0.9; line-height: 1.6; max-height: 150px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 8px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 10px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 12px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 1rem; resize: none; user-select: auto; pointer-events: auto; }
.text-input-panel textarea:focus { outline: none; background: rgba(0,0,0,0.6); border-color: #fff; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 40px 30px; text-align: center; border-radius: 12px; width: 85%; max-width: 450px; }
.event-box h3 { opacity: 0.7; font-size: 0.9rem; letter-spacing: 3px; margin-bottom: 15px; }
.event-box p { font-size: 1.05rem; line-height: 1.6; margin-bottom: 25px; }
.npc-reaction { font-size: 4rem; margin-bottom: 30px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* リザルト画面・キャプチャエリア */
.result-capture-area { padding: 20px 10px; border-radius: 16px; transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 20px; }
.result-header h2 { font-size: 1.2rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 30px 20px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.8rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 2.2rem; font-weight: bold; letter-spacing: 1px; margin-bottom: 20px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

/* ★ 5x5 チャートコンテナの修正（ラベル位置・枠線の強調） */
.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 20px; padding: 25px; }
.axis-label { position: absolute; font-size: 0.8rem; opacity: 0.8; font-weight: bold; letter-spacing: 1px; text-shadow: 0 0 5px rgba(0,0,0,0.5); }
.axis-label.top { top: 5px; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 5px; left: 50%; transform: translateX(-50%); }
.axis-label.left { left: 0px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: 0px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { position: relative; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 250px; height: 250px; border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.2); border-radius: 4px; }
/* マス目の線をハッキリさせる */
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.25); display: flex; justify-content: center; align-items: center; }

.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.85rem; opacity: 0.8; margin-top: 15px; line-height: 1.5; }

.action-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; padding: 0 20px; }

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.85);
  --grid-color: rgba(255, 255, 255, 0.2);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.15"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 10px; max-height: 98vh; overflow-y: auto; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 15px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 30px; font-weight: 300; opacity: 0.8; font-size: 0.9rem; }
.warning-text { text-align: center; font-size: 0.75rem; margin-bottom: 15px; opacity: 0.6; }

.input-group { background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 8px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 8px 0; font-size: 1.1rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 12px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.4); color: inherit; border-radius: 8px; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; border-color: transparent; }
.primary-btn:hover { opacity: 0.9; transform: scale(1.01); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.9; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 15px; left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 0.9rem; font-weight: bold; }
.money-ui { font-size: 1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; border: 1px solid #f1c40f; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.3rem; font-weight: bold; font-family: monospace; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 50%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.8rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.2rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.4rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 2.8rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.3rem; }

/* 🌟 新規：モーダル内水槽エリアのスタイル */
.aquarium-container {
  width: 100%; height: 110px; border-radius: 8px; overflow: hidden;
  position: relative; margin-bottom: 15px; border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
}
.aquarium-container.hidden { display: none; }
.aquarium-water {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(52, 152, 219, 0.2) 0%, rgba(41, 128, 185, 0.7) 100%);
  animation: waterWobble 4s ease-in-out infinite alternate;
}
@keyframes waterWobble { from { transform: translateY(0) scaleY(1); } to { transform: translateY(5px) scaleY(1.05); } }
.aquarium-bug {
  position: absolute; left: 50%; top: 10%; font-size: 2.8rem;
  transform: translateX(-50%); transition: top 0.2s linear, opacity 0.2s;
  z-index: 5; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
}
.field-bubble { 
  position: absolute; background: rgba(0,0,0,0.9); color: #fff; 
  padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; 
  white-space: nowrap; border: 1px solid #777; pointer-events: none; 
  animation: popBubble 0.3s forwards; transition: opacity 0.5s; 
  z-index: 100; text-shadow: none; box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* ★ 修正済み：はみ出し防止用のスクロール・高さ制限 */
.interaction-panel {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: var(--card-bg); border: 1px solid var(--grid-color);
  padding: 15px 20px; border-radius: 12px;
  display: flex; flex-direction: column; gap: 10px;
  width: 95%; max-width: 600px; max-height: 48%; /* 画面高の約半分に抑える */
  z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  backdrop-filter: blur(15px); transition: background 1s;
  overflow-y: auto; /* ★ 縦スクロール可能に修正 */
}
.interaction-panel.hidden { display: none; }
.panel-content-layout { display: flex; gap: 15px; width: 100%; align-items: flex-start; }

.target-view { font-size: 3.2rem; display: flex; align-items: center; justify-content: center; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.target-content h3 { font-size: 1.1rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 5px; margin-bottom: 2px; }
.info-log { font-size: 0.85rem; opacity: 0.9; line-height: 1.5; max-height: 90px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 6px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 8px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 10px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 0.95rem; resize: none; user-select: auto; pointer-events: auto; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 30px; text-align: center; border-radius: 12px; width: 90%; max-width: 420px; }
.event-box h3 { opacity: 0.7; font-size: 0.85rem; letter-spacing: 3px; margin-bottom: 10px; }
.event-box p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 20px; }
.npc-reaction { font-size: 3.5rem; margin-bottom: 20px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* リザルト画面・キャプチャエリア */
.result-capture-area { padding: 15px 5px; border-radius: 16px; transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 15px; }
.result-header h2 { font-size: 1.1rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 20px 15px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.75rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 1.8rem; font-weight: bold; letter-spacing: 0.5px; margin-bottom: 15px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

/* 5x5 チャートコンテナ */
.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 15px; padding: 20px; }
.axis-label { position: absolute; font-size: 0.75rem; opacity: 0.8; font-weight: bold; }
.axis-label.top { top: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 0px; left: 50%; transform: translateX(-50%); }
/* ★ ラベルをグラフ本体にギュッと近づけた */
.axis-label.left { left: 15px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: 15px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { position: relative; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 220px; height: 220px; border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.25); border-radius: 4px; }
/* ★ 枠線を完全にハッキリさせた */
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.35); display: flex; justify-content: center; align-items: center; }

.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.8rem; opacity: 0.8; margin-top: 10px; line-height: 1.5; }

.action-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; padding: 0 10px; }

/* スマホ用メディアクエリ (レスポンシブ対応) */
@media (max-height: 700px) {
  .field { height: 42%; top: 12%; }
  .interaction-panel { max-height: 48%; padding: 10px 15px; }
  .panel-content-layout { gap: 10px; }
  .target-view { font-size: 2.8rem; }
  .target-content h3 { font-size: 1rem; }
  .info-log { font-size: 0.8rem; max-height: 70px; }
  .alignment-grid { width: 180px; height: 180px; }
  .chart-wrapper { padding: 15px; }
  .alignment-title { font-size: 1.5rem; }
  .btn { padding: 10px; font-size: 0.9rem; }
}

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.85);
  --grid-color: rgba(255, 255, 255, 0.2);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

/* 🌟 オシャレな近未来風カスタムスクロールバー */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.15"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 10px; max-height: 98vh; overflow-y: auto; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 15px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 30px; font-weight: 300; opacity: 0.8; font-size: 0.9rem; }
.warning-text { text-align: center; font-size: 0.75rem; margin-bottom: 15px; opacity: 0.6; }

.input-group { background: rgba(0,0,0,0.4); padding: 20px; border-radius: 8px; margin-bottom: 30px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 10px 0; font-size: 1.2rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 12px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.4); color: inherit; border-radius: 8px; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; border-color: transparent; }
.primary-btn:hover { opacity: 0.9; transform: scale(1.01); }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.9; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 15px; left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 0.9rem; font-weight: bold; }
.money-ui { font-size: 1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; border: 1px solid #f1c40f; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.3rem; font-weight: bold; font-family: monospace; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 50%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.8rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.2rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.4rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 2.8rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.3rem; }

/* 🌟 水槽エリア（常に上部に固定！） */
.aquarium-container {
  width: 100%; height: 110px; border-radius: 8px; overflow: hidden;
  position: relative; margin-bottom: 10px; border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 15px rgba(0,0,0,0.5); flex-shrink: 0; /* 高さが縮まないように */
}
.aquarium-container.hidden { display: none; }
.aquarium-water {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(52, 152, 219, 0.2) 0%, rgba(41, 128, 185, 0.7) 100%);
  animation: waterWobble 4s ease-in-out infinite alternate;
}
@keyframes waterWobble { from { transform: translateY(0) scaleY(1); } to { transform: translateY(5px) scaleY(1.05); } }
.aquarium-bug {
  position: absolute; left: 50%; top: 10%; font-size: 2.8rem;
  transform: translateX(-50%); transition: top 0.2s linear, opacity 0.2s;
  z-index: 5; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
}
.field-bubble { 
  position: absolute; background: rgba(0,0,0,0.95); color: #fff; 
  padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; 
  white-space: nowrap; border: 1px solid #777; pointer-events: none; 
  animation: popBubble 0.3s forwards; transition: opacity 0.5s; 
  z-index: 100; text-shadow: none; box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* ★ アクションパネル (パネル自体はスクロールさせず、固定エリアとする) */
.interaction-panel {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: var(--card-bg); border: 1px solid var(--grid-color);
  padding: 15px 20px; border-radius: 12px;
  display: flex; flex-direction: column;
  width: 95%; max-width: 600px; max-height: 52%; /* パネル全体の最大高 */
  z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  backdrop-filter: blur(15px); transition: background 1s;
  overflow: hidden; /* パネル外へのはみ出しを制御 */
}
.interaction-panel.hidden { display: none; }

/* ★ 選択肢とログを包むスクロール専用インナーエリア */
.panel-scroll-content {
  overflow-y: auto; /* ここだけスクロールさせる！ */
  flex: 1;
  padding-right: 5px;
}

.panel-content-layout { display: flex; gap: 15px; width: 100%; align-items: flex-start; }

.target-view { font-size: 3.2rem; display: flex; align-items: center; justify-content: center; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.target-content h3 { font-size: 1.1rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 5px; margin-bottom: 2px; }
.info-log { font-size: 0.85rem; opacity: 0.9; line-height: 1.5; max-height: 120px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 6px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 8px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 10px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 0.95rem; resize: none; user-select: auto; pointer-events: auto; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 30px; text-align: center; border-radius: 12px; width: 90%; max-width: 420px; }
.event-box h3 { opacity: 0.7; font-size: 0.85rem; letter-spacing: 3px; margin-bottom: 10px; }
.event-box p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 20px; }
.npc-reaction { font-size: 3.5rem; margin-bottom: 20px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* リザルト画面・キャプチャエリア */
.result-capture-area { padding: 15px 5px; border-radius: 16px; transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 15px; }
.result-header h2 { font-size: 1.1rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 20px 15px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.75rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 1.6rem; font-weight: bold; letter-spacing: 0.5px; margin-bottom: 15px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

/* 5x5 チャートコンテナ */
.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 15px; padding: 20px; }
.axis-label { position: absolute; font-size: 0.75rem; opacity: 0.8; font-weight: bold; }
.axis-label.top { top: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.left { left: 15px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: 15px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { position: relative; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 220px; height: 220px; border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.25); border-radius: 4px; }
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.35); display: flex; justify-content: center; align-items: center; }

.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.8rem; opacity: 0.8; margin-top: 10px; line-height: 1.5; }

.action-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; padding: 0 10px; }

/* スマホ用メディアクエリ (レスポンシブ対応) */
@media (max-height: 700px) {
  .field { height: 42%; top: 12%; }
  .interaction-panel { max-height: 48%; padding: 10px 15px; }
  .panel-content-layout { gap: 10px; }
  .target-view { font-size: 2.8rem; }
  .target-content h3 { font-size: 1rem; }
  .info-log { font-size: 0.8rem; max-height: 70px; }
  .alignment-grid { width: 180px; height: 180px; }
  .chart-wrapper { padding: 15px; }
  .alignment-title { font-size: 1.5rem; }
  .btn { padding: 10px; font-size: 0.9rem; }
}

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.85);
  --grid-color: rgba(255, 255, 255, 0.2);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
  --scale-angle: -20deg; /* 天秤初期傾き */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

/* 近未来風スクロールバー */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 10px; border: 1px solid rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.15"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 10px; max-height: 98vh; overflow-y: auto; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 15px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 20px; font-weight: 300; opacity: 0.8; font-size: 0.9rem; }

/* 実験説明 & 規約 */
.experiment-desc, .terms-box {
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--grid-color);
  padding: 15px; border-radius: 8px; font-size: 0.85rem; line-height: 1.6;
  margin-bottom: 15px; max-height: 120px; overflow-y: auto; text-align: left;
}
.experiment-desc h3, .terms-box h4 { font-size: 0.95rem; margin-bottom: 8px; border-left: 3px solid var(--text-color); padding-left: 8px; }
.terms-box { border-color: rgba(231, 76, 60, 0.3); }

.agreement-area { margin-bottom: 25px; text-align: left; }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; font-size: 0.8rem; cursor: pointer; line-height: 1.4; }
.checkbox-label input { width: 16px; height: 16px; margin-top: 2px; cursor: pointer; }

/* 🌟 天秤均衡ゲート 🌟 */
.scale-gate-container {
  background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--grid-color);
  padding: 15px; border-radius: 12px; margin-bottom: 25px; text-align: center;
}
.scale-instruction { font-size: 0.8rem; opacity: 0.8; margin-bottom: 10px; }
.scale-visual {
  display: flex; justify-content: center; align-items: center; gap: 15px;
  font-size: 1.8rem; margin: 15px 0;
}
.scale-beam {
  font-size: 3.5rem; transition: transform 0.1s linear;
  transform: rotate(var(--scale-angle));
  display: inline-block;
}
.scale-slider {
  width: 80%; max-width: 300px; margin: 10px 0; cursor: pointer; accent-color: var(--text-color);
}
.scale-status { font-size: 0.8rem; font-weight: bold; color: var(--danger-color); margin-top: 5px; }
.scale-status.balanced { color: #2ecc71; }

.input-group { background: rgba(0,0,0,0.4); padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 8px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 8px 0; font-size: 1.1rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 12px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.4); color: inherit; border-radius: 8px; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; border-color: transparent; }
.primary-btn:hover:not(:disabled) { opacity: 0.9; transform: scale(1.01); }
.primary-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.9; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 15px; left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 0.9rem; font-weight: bold; }
.money-ui { font-size: 1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; border: 1px solid #f1c40f; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.3rem; font-weight: bold; font-family: monospace; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 50%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.8rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.2rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.4rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 2.8rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.3rem; }

/* 水槽エリア（常に上部に固定！） */
.aquarium-container {
  width: 100%; height: 110px; border-radius: 8px; overflow: hidden;
  position: relative; margin-bottom: 10px; border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 15px rgba(0,0,0,0.5); flex-shrink: 0;
}
.aquarium-container.hidden { display: none; }
.aquarium-water {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(52, 152, 219, 0.2) 0%, rgba(41, 128, 185, 0.7) 100%);
  animation: waterWobble 4s ease-in-out infinite alternate;
}
@keyframes waterWobble { from { transform: translateY(0) scaleY(1); } to { transform: translateY(5px) scaleY(1.05); } }
.aquarium-bug {
  position: absolute; left: 50%; top: 10%; font-size: 2.8rem;
  transform: translateX(-50%); transition: top 0.2s linear, opacity 0.2s;
  z-index: 5; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
}

/* アクションパネル */
.interaction-panel {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: var(--card-bg); border: 1px solid var(--grid-color);
  padding: 15px 20px; border-radius: 12px;
  display: flex; flex-direction: column;
  width: 95%; max-width: 600px; max-height: 52%;
  z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  backdrop-filter: blur(15px); transition: background 1s;
  overflow: hidden;
}
.interaction-panel.hidden { display: none; }
.close-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; color: inherit; font-size: 1.5rem; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 5px; z-index: 30;}
.close-btn:hover { opacity: 1; }

.panel-scroll-content { overflow-y: auto; flex: 1; padding-right: 5px; }
.panel-content-layout { display: flex; gap: 15px; width: 100%; align-items: flex-start; }

.target-view { font-size: 3.2rem; display: flex; align-items: center; justify-content: center; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.target-content h3 { font-size: 1.1rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 5px; margin-bottom: 2px; }
.info-log { font-size: 0.85rem; opacity: 0.9; line-height: 1.5; max-height: 120px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 6px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 8px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 10px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 0.95rem; resize: none; user-select: auto; pointer-events: auto; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 30px; text-align: center; border-radius: 12px; width: 90%; max-width: 420px; }
.event-box h3 { opacity: 0.7; font-size: 0.85rem; letter-spacing: 3px; margin-bottom: 10px; }
.event-box p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 20px; }
.npc-reaction { font-size: 3.5rem; margin-bottom: 20px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* キャプチャエリア */
.result-capture-area { padding: 15px 5px; border-radius: 16px; transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 15px; }
.result-header h2 { font-size: 1.1rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 20px 15px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.75rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 1.5rem; font-weight: bold; letter-spacing: 0.5px; margin-bottom: 15px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 15px; padding: 20px; }
.axis-label { position: absolute; font-size: 0.75rem; opacity: 0.8; font-weight: bold; }
.axis-label.top { top: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.left { left: 15px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: 15px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { position: relative; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 220px; height: 220px; border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.25); border-radius: 4px; }
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.35); display: flex; justify-content: center; align-items: center; }

.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.8rem; opacity: 0.8; margin-top: 10px; line-height: 1.5; }

.action-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; padding: 0 10px; }

/* スマホ用メディアクエリ */
@media (max-height: 700px) {
  .field { height: 42%; top: 12%; }
  .interaction-panel { max-height: 48%; padding: 10px 15px; }
  .panel-content-layout { gap: 10px; }
  .target-view { font-size: 2.8rem; }
  .target-content h3 { font-size: 1rem; }
  .info-log { font-size: 0.8rem; max-height: 70px; }
  .alignment-grid { width: 180px; height: 180px; }
  .chart-wrapper { padding: 15px; }
  .alignment-title { font-size: 1.3rem; }
  .btn { padding: 10px; font-size: 0.9rem; }
}

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

:root {
  --bg-color: rgb(114, 113, 113);
  --text-color: #f0f0f0;
  --card-bg: rgba(114, 113, 113, 0.85);
  --grid-color: rgba(255, 255, 255, 0.2);
  --crack-color: rgba(0, 0, 0, 0.3);
  --danger-color: #e74c3c;
  --scale-angle: -20deg;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Helvetica Neue", Arial, sans-serif; color: var(--text-color); background-color: var(--bg-color); overflow: hidden; height: 100vh; display: flex; justify-content: center; align-items: center; user-select: none; transition: color 1s ease, background-color 1s ease; }

/* おしゃれスクロールバー */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 10px; border: 1px solid rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

.world-bg { position: absolute; inset: 0; background-color: var(--bg-color); transition: background-color 1s ease; z-index: -10; }
.fog-layer { position: absolute; inset: 0; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="f"><feTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3"/></filter><rect width="100%" height="100%" filter="url(%23f)" opacity="0.15"/></svg>'); opacity: 0.15; animation: fogMove 30s linear infinite; pointer-events: none; mix-blend-mode: overlay; }
@keyframes fogMove { from { transform: translateX(0); } to { transform: translateX(-10%); } }
.particles-layer { position: absolute; inset: 0; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; background: #fff; border-radius: 50%; box-shadow: 0 0 10px #fff; animation: floatUp 4s infinite ease-in; opacity: 0.8; }
@keyframes floatUp { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1.5); opacity: 0; } }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px); background-size: 40px 40px; opacity: 0; transition: opacity 2s, background-image 1s; pointer-events: none; }
.crack-layer { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 15px, var(--crack-color) 15px, var(--crack-color) 20px); opacity: 0; transition: opacity 2s, background 1s; pointer-events: none; }
.heartbeat-overlay { position: absolute; inset: 0; background: radial-gradient(circle, transparent 50%, rgba(231, 76, 60, 0.3) 100%); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.heartbeat-overlay.active { animation: heartbeat 1s infinite; }
@keyframes heartbeat { 0%, 100%{opacity:0.1;} 20%{opacity:0.8;} 40%{opacity:0.2;} 60%{opacity:0.6;} }

.container { width: 100%; max-width: 800px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: center; }
.screen { display: none; padding: 10px; max-height: 98vh; overflow-y: auto; }
.screen.active { display: block; animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.title-group { text-align: center; margin-bottom: 15px; }
.sub-title { font-size: 0.85rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.glitch-text { font-size: 2rem; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 10px rgba(255,255,255,0.4); }
.subtitle { text-align: center; margin-bottom: 20px; font-weight: 300; opacity: 0.8; font-size: 0.9rem; }

/* 🌟 概要はスクロールなしの普通表示に修正！ */
.experiment-desc-full {
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--grid-color);
  padding: 20px; border-radius: 8px; font-size: 0.85rem; line-height: 1.6;
  margin-bottom: 15px; text-align: left;
}
.experiment-desc-full h3 { font-size: 0.95rem; margin-bottom: 8px; border-left: 3px solid var(--text-color); padding-left: 8px; }

/* 規約（脆弱対策） */
.terms-box {
  background: rgba(10, 0, 0, 0.4); border: 1px solid rgba(231, 76, 60, 0.3);
  padding: 15px; border-radius: 8px; font-size: 0.8rem; line-height: 1.5;
  margin-bottom: 15px; max-height: 90px; overflow-y: auto; text-align: left;
}
.terms-box h4 { font-size: 0.85rem; margin-bottom: 6px; color: #ff7675; }

.agreement-area { margin-bottom: 20px; text-align: left; }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; font-size: 0.8rem; cursor: pointer; line-height: 1.4; }
.checkbox-label input { width: 16px; height: 16px; margin-top: 2px; cursor: pointer; }

/* 天秤均衡ゲート */
.scale-gate-container {
  background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--grid-color);
  padding: 15px; border-radius: 12px; margin-bottom: 20px; text-align: center;
}
.scale-instruction { font-size: 0.8rem; opacity: 0.8; margin-bottom: 5px; }
.scale-visual { display: flex; justify-content: center; align-items: center; gap: 15px; font-size: 1.8rem; margin: 10px 0; }
.scale-beam { font-size: 3.5rem; transition: transform 0.1s linear; transform: rotate(var(--scale-angle)); display: inline-block; }
.scale-slider { width: 80%; max-width: 300px; margin: 10px 0; cursor: pointer; accent-color: var(--text-color); }
.scale-status { font-size: 0.8rem; font-weight: bold; color: var(--danger-color); margin-top: 5px; }
.scale-status.balanced { color: #2ecc71; animation: glowPulse 1.5s infinite alternate; }
@keyframes glowPulse { from { text-shadow: 0 0 5px #2ecc71; } to { text-shadow: 0 0 15px #2ecc71; } }

.start-btns-row { display: flex; gap: 10px; width: 100%; }
.back-lab-btn { flex: 0.4; }

.input-group { background: rgba(0,0,0,0.4); padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid var(--grid-color); }
.input-group label { display: block; font-size: 0.8rem; margin-bottom: 10px; opacity: 0.8; }
.input-group input { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--text-color); color: inherit; padding: 8px 0; font-size: 1.1rem; outline: none; user-select: auto; }

.btn { width: 100%; padding: 12px; border: 1px solid var(--grid-color); background: rgba(0,0,0,0.4); color: inherit; border-radius: 8px; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; gap: 8px; }
.primary-btn { background: var(--text-color); color: var(--bg-color); font-weight: bold; border-color: transparent; }
.primary-btn:hover:not(:disabled) { opacity: 0.9; transform: scale(1.01); }
.primary-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.action-btn { margin-top: 5px; }
.action-btn:hover { opacity: 0.9; background: rgba(255,255,255,0.1); }
.danger-btn { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; margin-top: 5px; }

.hud { position: absolute; top: 15px; left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.hud-left { display: flex; flex-direction: column; gap: 5px; }
.stage-info { font-size: 0.9rem; font-weight: bold; }
.money-ui { font-size: 1rem; color: #f1c40f; font-weight: bold; background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; border: 1px solid #f1c40f; display: inline-block; width: fit-content; }
.money-ui.hidden { display: none; }
.timer-ui { font-size: 1.3rem; font-weight: bold; font-family: monospace; }
.timer-ui.danger { color: var(--danger-color); }

.field { position: absolute; top: 15%; left: 5%; right: 5%; height: 50%; background: rgba(0,0,0,0.2); border: 1px solid var(--grid-color); border-radius: 12px; overflow: hidden; touch-action: none; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
.instruction-text { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 0.8rem; opacity: 0.6; pointer-events: none; }
.player { position: absolute; font-size: 2.2rem; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; display: flex; align-items: center; }
.companion { font-size: 1.4rem; margin-left: -5px; animation: bounce 0.5s infinite alternate; }
.companion.hidden { display: none; }
@keyframes bounce { from{transform:translateY(0);} to{transform:translateY(-5px);} }
.npc { position: absolute; font-size: 2.8rem; transform: translate(-50%, -50%); z-index: 2; transition: filter 0.3s; display: flex; justify-content: center; align-items: center; }
.npc.glow { filter: drop-shadow(0 0 15px rgba(255,255,255,0.9)); }
.door { font-size: 2.3rem; }

/* 水槽エリア */
.aquarium-container { width: 100%; height: 110px; border-radius: 8px; overflow: hidden; position: relative; margin-bottom: 10px; border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: inset 0 0 15px rgba(0,0,0,0.5); flex-shrink: 0; }
.aquarium-container.hidden { display: none; }
.aquarium-water { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(52, 152, 219, 0.2) 0%, rgba(41, 128, 185, 0.7) 100%); animation: waterWobble 4s ease-in-out infinite alternate; }
@keyframes waterWobble { from { transform: translateY(0) scaleY(1); } to { transform: translateY(5px) scaleY(1.05); } }
.aquarium-bug { position: absolute; left: 50%; top: 10%; font-size: 2.8rem; transform: translateX(-50%); transition: top 0.2s linear, opacity 0.2s; z-index: 5; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3)); }
.field-bubble { position: absolute; background: rgba(0,0,0,0.95); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; white-space: nowrap; border: 1px solid #777; pointer-events: none; animation: popBubble 0.3s forwards; transition: opacity 0.5s; z-index: 100; text-shadow: none; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
@keyframes popBubble { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

/* アクションパネル */
.interaction-panel { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--grid-color); padding: 15px 20px; border-radius: 12px; display: flex; flex-direction: column; width: 95%; max-width: 600px; max-height: 52%; z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,0.7); backdrop-filter: blur(15px); transition: background 1s; overflow: hidden; }
.interaction-panel.hidden { display: none; }
.panel-scroll-content { overflow-y: auto; flex: 1; padding-right: 5px; }
.panel-content-layout { display: flex; gap: 15px; width: 100%; align-items: flex-start; }

.target-view { font-size: 3.2rem; display: flex; align-items: center; justify-content: center; }
.target-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.target-content h3 { font-size: 1.1rem; border-bottom: 1px solid var(--grid-color); padding-bottom: 5px; margin-bottom: 2px; }
.info-log { font-size: 0.85rem; opacity: 0.9; line-height: 1.5; max-height: 120px; overflow-y: auto; }
.choices-panel { display: flex; flex-direction: column; gap: 6px; }
.choices-panel.hidden { display: none; }
.text-input-panel { display: flex; flex-direction: column; gap: 8px; }
.text-input-panel.hidden { display: none; }
.text-input-panel textarea { width: 100%; padding: 10px; border-radius: 8px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid var(--grid-color); font-size: 0.95rem; resize: none; user-select: auto; pointer-events: auto; }

.event-result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.event-result-overlay.hidden { display: none; }
.event-box { background: var(--card-bg); border: 1px solid var(--grid-color); padding: 30px; text-align: center; border-radius: 12px; width: 90%; max-width: 420px; }
.event-box h3 { opacity: 0.7; font-size: 0.85rem; letter-spacing: 3px; margin-bottom: 10px; }
.event-box p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 20px; }
.npc-reaction { font-size: 3.5rem; margin-bottom: 20px; animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* キャプチャエリア */
.result-capture-area { padding: 15px 5px; border-radius: 16px; transition: background-color 1s; }
.result-header { text-align: center; margin-bottom: 15px; }
.result-header h2 { font-size: 1.1rem; opacity: 0.8; letter-spacing: 4px; }
.result-card { text-align: center; background: var(--card-bg); padding: 20px 15px; border: 1px solid var(--grid-color); border-radius: 12px; backdrop-filter: blur(15px); transition: background 1s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.alignment-sub { font-size: 0.75rem; opacity: 0.7; letter-spacing: 2px; margin-bottom: 5px; }
.alignment-title { font-size: 1.5rem; font-weight: bold; letter-spacing: 0.5px; margin-bottom: 15px; text-shadow: 0 0 15px rgba(255,255,255,0.3); }

.chart-wrapper { position: relative; display: flex; justify-content: center; margin-bottom: 15px; padding: 20px; }
.axis-label { position: absolute; font-size: 0.75rem; opacity: 0.8; font-weight: bold; }
.axis-label.top { top: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.bottom { bottom: 0px; left: 50%; transform: translateX(-50%); }
.axis-label.left { left: 15px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.axis-label.right { right: 15px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.chart-container { position: relative; }
.alignment-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); width: 220px; height: 220px; border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.25); border-radius: 4px; }
.alignment-grid .cell { border: 1px solid rgba(255,255,255,0.35); display: flex; justify-content: center; align-items: center; }

.position-marker { position: absolute; width: 14px; height: 14px; background: var(--text-color); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color); transition: all 1s ease-out; z-index: 10; }
.alignment-desc { font-size: 0.8rem; opacity: 0.8; margin-top: 10px; line-height: 1.5; text-align: left; background: rgba(0,0,0,0.2); padding: 12px; border-radius: 6px; border-left: 3px solid var(--text-color); }

.action-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; padding: 0 10px; }

/* スマホ用メディアクエリ */
@media (max-height: 700px) {
  .field { height: 42%; top: 12%; }
  .interaction-panel { max-height: 48%; padding: 10px 15px; }
  .panel-content-layout { gap: 10px; }
  .target-view { font-size: 2.8rem; }
  .target-content h3 { font-size: 1rem; }
  .info-log { font-size: 0.8rem; max-height: 70px; }
  .alignment-grid { width: 180px; height: 180px; }
  .chart-wrapper { padding: 15px; }
  .alignment-title { font-size: 1.3rem; }
  .btn { padding: 10px; font-size: 0.9rem; }
}

#caterpillar-container { position: absolute; bottom: 10px; width: 100%; z-index: 60; pointer-events: none; }
.caterpillar { position: absolute; font-size: 2rem; bottom: 0; cursor: pointer; pointer-events: auto; animation: crawlLeft 25s linear infinite; }
@keyframes crawlLeft { from { left: 110%; } to { left: -10%; } }
.cat-bubble { position: absolute; bottom: 40px; background: rgba(0,0,0,0.9); border: 1px solid #555; padding: 10px 15px; font-size: 0.85rem; border-radius: 8px; white-space: nowrap; transition: opacity 0.3s; color: #fff; text-shadow: none;}
.cat-bubble.hidden { opacity: 0; pointer-events: none; }

/* スマホの自動ズーム防止対策 */
input, textarea {
  font-size: 16px !important; /* iOSは16px未満だと入力時に自動ズームしてしまうため強制 */
}

/* フィールドのダブルタップズーム防止 */
.field {
  touch-action: none; /* スマホのスワイプやダブルタップによるズーム・スクロールを完全に防ぐ */
}
