* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #2e1a2e 0%, #1a1a2e 50%, #2e1a28 100%);
  font-family: 'Zen Maru Gothic', 'Hiragino Kaku Gothic Pro', 'メイリオ', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 0;
  overflow-y: auto;
}

/* ===== レイアウト ===== */
#game-wrapper {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  max-width: 980px;
  width: 100%;
  padding: 0 10px;
}

#game-container {
  width: 780px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.game-title {
  text-align: center;
  color: #e0d0f8;
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: 6px;
  text-shadow: 0 0 15px rgba(210, 180, 248, 0.5);
}

/* ===== 部屋 ===== */
#room {
  width: 100%;
  height: 380px;
  position: relative;
  overflow: hidden;
  border: 3px solid #7a5a8a;
  border-radius: 12px;
  cursor: default;
  background: linear-gradient(180deg, #ccb8e8 0%, #b8a0d4 55%, #c89a80 55%, #b88870 100%);
  box-shadow: 0 0 30px rgba(160, 120, 200, 0.3), inset 0 0 40px rgba(0, 0, 0, 0.15);
}

#wall-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 55%;
  background: linear-gradient(180deg, #d8c8f0 0%, #c4b0e0 40%, #b8a0d8 100%);
}

/* 壁紙の模様 */
#wall-back::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 38px,
    rgba(255,255,255,0.15) 38px,
    rgba(255,255,255,0.15) 40px
  );
}

#wall-back::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 78px,
    rgba(200,200,255,0.2) 78px,
    rgba(200,200,255,0.2) 80px
  );
}

#floor {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 45%;
  background: repeating-linear-gradient(90deg, #c89a80 0px, #d4a888 55px, #c89a80 57px);
  background-size: 57px 100%;
}

#floor::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.02) 100%);
}

/* ===== クリッカブル ===== */
.clickable { cursor: pointer; }
.clickable:hover { filter: brightness(1.12); }

/* ===== 扉 ===== */
#door {
  position: absolute;
  left: 50px; top: 30px;
  width: 110px; height: 195px;
  z-index: 10;
}

#door-frame {
  width: 100%; height: 100%;
  background: #d0c0e8;
  border: 5px solid #a890c0;
  border-radius: 6px 6px 0 0;
  padding: 7px;
}

#door-panel {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #e0d0f0 0%, #d4c0e8 50%, #c8b0dd 100%);
  border: 2px solid #b8a0c8;
  position: relative;
  border-radius: 4px 4px 0 0;
}

#door-detail-top, #door-detail-bottom {
  position: absolute;
  left: 12%; width: 76%; height: 26%;
  border: 2px solid rgba(160,140,180,0.5);
  border-radius: 3px;
}
#door-detail-top { top: 8%; }
#door-detail-bottom { bottom: 10%; }

#doorknob {
  position: absolute;
  right: 12px; top: 44%;
  width: 15px; height: 15px;
  background: radial-gradient(circle at 35% 30%, #f8e080, #d0a040);
  border-radius: 50%;
  border: 1px solid #b89030;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

#keyhole {
  position: absolute;
  right: 14px; top: 54%;
  width: 8px; height: 13px;
}

#keyhole::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 7px; height: 7px;
  background: #40305a;
  border-radius: 50%;
}

#keyhole::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 7px;
  background: #40305a;
}

#door.door-unlocked #door-frame {
  animation: doorGlow 1.5s ease-in-out infinite;
}

@keyframes doorGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 240, 200, 0.3); }
  50% { box-shadow: 0 0 20px rgba(255, 240, 200, 0.8), 0 0 40px rgba(255, 220, 150, 0.3); }
}

#door.door-open #door-panel {
  animation: doorOpen 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes doorOpen {
  0% { transform: perspective(800px) rotateY(0deg); transform-origin: left; }
  100% { transform: perspective(800px) rotateY(-75deg); transform-origin: left; }
}

#door.door-open #door-frame {
  background: linear-gradient(180deg, #fff8ee 0%, #fffcf4 100%);
  box-shadow: inset 0 0 40px rgba(255, 240, 200, 0.8);
}

/* ===== 絵画 ===== */
#painting {
  position: absolute;
  left: 250px; top: 20px;
  width: 100px; height: 72px;
  z-index: 5;
}

#painting-frame {
  width: 100%; height: 100%;
  background: #f0d0b8;
  border: 5px solid #d8a890;
  border-radius: 3px;
  padding: 5px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
}

#painting-canvas {
  position: relative;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #282848 0%, #383868 100%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border-radius: 1px;
}

#painting-canvas .star {
  color: #ffe84a;
  font-size: 14px;
  text-shadow: 0 0 4px rgba(255, 232, 74, 0.6);
}

#painting-canvas .moon {
  color: #f0e080;
  font-size: 20px;
  text-shadow: 0 0 6px rgba(240, 224, 128, 0.5);
}

/* ===== 絵画破壊 ===== */
#painting.painting-destroyed #painting-canvas {
  filter: grayscale(1) brightness(0.4);
}

#painting.painting-destroyed #painting-canvas::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    linear-gradient(45deg, transparent 30%, rgba(80,40,40,0.6) 30%, rgba(80,40,40,0.6) 32%, transparent 32%),
    linear-gradient(-30deg, transparent 40%, rgba(80,40,40,0.6) 40%, rgba(80,40,40,0.6) 42%, transparent 42%),
    linear-gradient(60deg, transparent 50%, rgba(80,40,40,0.6) 50%, rgba(80,40,40,0.6) 52%, transparent 52%);
}

#painting.painting-destroyed #painting-frame {
  border-color: #8a6060;
  box-shadow: none;
}

/* ===== 時計 ===== */
#clock {
  position: absolute;
  right: 120px; top: 15px;
  width: 62px; height: 62px;
  z-index: 5;
}

#clock-face {
  width: 100%; height: 100%;
  background: radial-gradient(circle, #fff8f0 60%, #f0e0d0 100%);
  border-radius: 50%;
  border: 4px solid #b8a8d8;
  position: relative;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
}

#clock-center {
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  background: #7868a0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

#clock-hand-hour {
  position: absolute;
  top: 50%; left: 50%;
  width: 13px; height: 3px;
  background: #7868a0;
  transform-origin: 0% 50%;
  transform: rotate(0deg);
  border-radius: 2px;
  z-index: 2;
}

#clock-hand-minute {
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 2px;
  background: #a088c0;
  transform-origin: 0% 50%;
  transform: rotate(-90deg);
  border-radius: 2px;
  z-index: 2;
}

/* ===== 窓 ===== */
#window {
  position: absolute;
  left: 420px; top: 25px;
  width: 110px; height: 80px;
  background: #2a3a5a;
  border: 6px solid #b8a8d8;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  z-index: 5;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
  border-radius: 4px;
}

.window-pane {
  background: linear-gradient(135deg, #4060a0 0%, #305088 50%, #283870 100%);
  border: 2px solid #b8a8d8;
}

#window-frame-v {
  position: absolute;
  left: 50%; top: 0;
  width: 4px; height: 100%;
  background: #b8a8d8;
  transform: translateX(-50%);
}

#window-frame-h {
  position: absolute;
  top: 50%; left: 0;
  width: 100%; height: 4px;
  background: #b8a8d8;
  transform: translateY(-50%);
}

/* ===== 窓の外からのセリフ ===== */
#window-speech {
  position: absolute;
  top: 115px;
  left: 475px;
  transform: translateX(-50%);
  background: #fff;
  color: #333;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: opacity 0.4s;
}

#window-speech::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #fff;
}

#window-speech.visible {
  opacity: 1;
  animation: windowSpeechPop 0.4s ease-out, windowSpeechFade 5s forwards;
}

@keyframes windowSpeechPop {
  0% { transform: translateX(-50%) scale(0.5); }
  60% { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes windowSpeechFade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== テーブル＋金庫 ===== */
#table {
  position: absolute;
  right: 50px; bottom: 30px;
  width: 140px; height: 90px;
  z-index: 5;
}

#table-top {
  position: absolute;
  top: 0; left: -10px;
  width: 160px; height: 12px;
  background: linear-gradient(180deg, #e8c0a8 0%, #d8b098 100%);
  border-radius: 4px;
  border: 2px solid #c8a088;
}

.table-leg {
  position: absolute;
  top: 12px;
  width: 10px; height: 78px;
  background: linear-gradient(90deg, #c8a888, #d8b898, #c8a888);
  border: 1px solid #b89878;
  border-radius: 0 0 3px 3px;
}

.table-leg-left { left: 8px; }
.table-leg-right { right: 8px; }

#safe {
  position: absolute;
  right: 70px; bottom: 122px;
  width: 76px; height: 50px;
  z-index: 8;
}

#safe-body {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #b8c8b8 0%, #90a890 100%);
  border: 3px solid #708870;
  border-radius: 6px;
  position: relative;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.3);
}

#safe-display {
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  background: #1a2a1a;
  color: #4aea4a;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: bold;
  padding: 2px 10px;
  border-radius: 3px;
  letter-spacing: 4px;
  border: 1px solid #2a3a2a;
}

#safe-handle {
  position: absolute;
  right: 7px; bottom: 6px;
  width: 16px; height: 16px;
  border: 3px solid #a8b8a8;
  border-radius: 50%;
}

#safe.safe-open #safe-body {
  background: linear-gradient(180deg, #c0d0c0 0%, #a0b8a0 100%);
  border-color: #80b080;
}

#safe.safe-open #safe-display { color: #8afa8a; }

#safe.safe-shake {
  animation: safeShake 0.3s ease-in-out;
}

@keyframes safeShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-2deg); }
  40% { transform: translateX(4px) rotate(2deg); }
  60% { transform: translateX(-3px) rotate(-1deg); }
  80% { transform: translateX(3px) rotate(1deg); }
}

#safe.safe-broken #safe-body {
  background: linear-gradient(180deg, #8a7060 0%, #6a5040 100%);
  border-color: #5a4030;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

#safe.safe-broken #safe-display {
  color: transparent;
}

#safe.safe-broken #safe-handle {
  opacity: 0.3;
  transform: rotate(45deg);
}

/* ===== 床のアイテム ===== */
.floor-item {
  z-index: 15;
  position: absolute;
}

.floor-item.hidden { display: none; }

#memo-on-floor {
  left: 320px; bottom: 55px;
  width: 46px; height: 46px;
}

.memo-shape {
  font-size: 28px;
  text-align: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

#flashlight-on-floor {
  left: 500px; bottom: 70px;
  width: 46px; height: 46px;
}

.flashlight-shape {
  font-size: 26px;
  text-align: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

.item-sparkle {
  position: absolute;
  top: -4px; right: -2px;
  color: #ffe0a0;
  font-size: 15px;
  animation: sparkle 1.5s ease-in-out infinite;
}

.sparkle2 { animation-delay: 0.7s; }
.sparkle3 { animation-delay: 0.3s; }
.sparkle4 { animation-delay: 1.1s; }

#dust-on-floor {
  left: 180px; bottom: 40px;
  width: 46px; height: 46px;
}

.dust-shape {
  font-size: 26px;
  text-align: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

#bento-on-floor {
  left: 430px; bottom: 35px;
  width: 46px; height: 46px;
}

.bento-shape {
  font-size: 26px;
  text-align: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

@keyframes sparkle {
  0%, 100% { opacity: 0.2; transform: scale(0.7) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.3) rotate(20deg); }
}

/* ===== 隠しメッセージ ===== */
#hidden-message {
  position: absolute;
  left: 220px; top: 130px;
  color: transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 4;
  pointer-events: none;
  transition: color 0.5s, text-shadow 0.5s;
}

#hidden-message.revealed {
  color: rgba(100, 60, 80, 0.8);
  text-shadow: 0 0 8px rgba(200, 100, 150, 0.4);
}

/* ===== セリフボックス ===== */
#dialog-box {
  width: 100%;
  height: 126px;
  background: linear-gradient(180deg, rgba(60, 30, 50, 0.96) 0%, rgba(40, 20, 35, 0.98) 100%);
  border: 2px solid #b0789a;
  border-radius: 14px;
  margin-top: 10px;
  padding: 0;
  display: flex;
  align-items: stretch;
  position: relative;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(200, 150, 180, 0.2);
  overflow: hidden;
  flex-shrink: 0;
}

#dialog-portrait {
  width: 72px;
  background: linear-gradient(135deg, #3e2a4a 0%, #301a3a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 2px solid #6a4a5e;
  flex-shrink: 0;
}

#portrait-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#dialog-content {
  flex: 1;
  padding: 12px 18px;
  min-width: 0;
}

#dialog-name {
  color: #f0a0c0;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 3px;
}

#dialog-text {
  color: #f8f0f4;
  font-size: 15px;
  line-height: 1.75;
}

#dialog-indicator {
  position: absolute;
  bottom: 8px; right: 14px;
  color: #8a6a7e;
  font-size: 11px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* ===== アイテムボックス ===== */
#item-box {
  width: 150px;
  background: linear-gradient(180deg, rgba(60, 30, 50, 0.95) 0%, rgba(40, 20, 35, 0.97) 100%);
  border: 2px solid #b0789a;
  border-radius: 14px;
  padding: 12px 8px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(200, 150, 180, 0.2);
  margin-top: 30px;
}

#item-box-label {
  color: #f0a0c0;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 4px;
}

#item-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.item-slot {
  width: 56px; height: 56px;
  background: rgba(80, 40, 60, 0.5);
  border: 2px solid #6a4a5e;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: default;
  transition: all 0.2s;
}

.item-slot.has-item {
  cursor: pointer;
  border-color: #a0708a;
  background: rgba(100, 50, 70, 0.5);
}

.item-slot.has-item:hover {
  border-color: #d0a0b8;
  background: rgba(120, 60, 80, 0.6);
  transform: scale(1.06);
}

.item-slot.selected {
  border-color: #f8d060;
  background: rgba(120, 100, 40, 0.5);
  box-shadow: 0 0 12px rgba(248, 208, 96, 0.4);
  animation: selectedPulse 2s ease-in-out infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(248, 208, 96, 0.3); }
  50% { box-shadow: 0 0 18px rgba(248, 208, 96, 0.6); }
}

#selected-item-name {
  color: #f8d060;
  font-size: 11px;
  text-align: center;
  margin-top: 8px;
  min-height: 16px;
  letter-spacing: 1px;
}

/* ===== 言語切替ボタン ===== */
#lang-switch {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.lang-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  background: rgba(80, 40, 60, 0.4);
  color: #a08090;
  border: 1px solid #6a4a5e;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.lang-btn:hover {
  background: rgba(100, 50, 70, 0.5);
  color: #d0b0c0;
}

.lang-btn.active {
  background: rgba(160, 80, 120, 0.5);
  color: #f0d0e0;
  border-color: #b0789a;
}

/* ===== モーダル共通 ===== */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
}

.modal.hidden { display: none; }

/* ===== 金庫モーダル ===== */
#safe-modal-content {
  background: linear-gradient(180deg, #2a3a2a 0%, #1a2a1a 100%);
  border: 3px solid #5a8a5a;
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  min-width: 280px;
}

#safe-modal-title {
  color: #8aea8a;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: 2px;
}

#safe-code-display {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

.code-digit {
  width: 48px; height: 56px;
  background: #0a1a0a;
  border: 2px solid #3a5a3a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4aea4a;
  font-family: 'Courier New', monospace;
  font-size: 30px;
  font-weight: bold;
}

#safe-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 210px;
  margin: 0 auto 14px;
}

.numpad-btn {
  padding: 10px;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Zen Maru Gothic', sans-serif;
  background: #2a4a2a;
  color: #c0e8c0;
  border: 2px solid #3a5a3a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.numpad-btn:hover { background: #3a6a3a; transform: scale(1.05); }
.numpad-btn:active { transform: scale(0.95); }

.numpad-clear {
  background: #4a2a2a;
  border-color: #6a3a3a;
  color: #f0a0a0;
}
.numpad-clear:hover { background: #6a3a3a; }

.numpad-enter {
  background: #2a4a3a;
  border-color: #3a6a5a;
  color: #a0f0c0;
}
.numpad-enter:hover { background: #3a6a4a; }

#safe-result {
  color: #f08080;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 10px;
}

#safe-result.success { color: #80f080; }

#safe-close-btn, #memo-close-btn {
  padding: 8px 26px;
  font-size: 14px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  background: transparent;
  color: #a0a0c0;
  border: 2px solid #5a5a7a;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 2px;
}

#safe-close-btn:hover, #memo-close-btn:hover {
  background: rgba(80, 80, 120, 0.3);
  color: #c0c0e0;
}

/* ===== 絵画拡大モーダル ===== */
#painting-modal-content {
  text-align: center;
  max-width: 520px;
}

#painting-close-btn {
  padding: 8px 26px;
  font-size: 14px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  background: transparent;
  color: #a0a0c0;
  border: 2px solid #5a5a7a;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 2px;
  margin-top: 14px;
}

#painting-close-btn:hover {
  background: rgba(80, 80, 120, 0.3);
  color: #c0c0e0;
}

/* ===== 窓モーダル（覗き込み演出） ===== */
#window-modal-content {
  text-align: center;
  max-width: 520px;
}

#window-peek-frame {
  position: relative;
  border-radius: 50%;
  width: 360px;
  height: 360px;
  overflow: hidden;
  margin: 0 auto;
  border: 8px solid #b8a8d8;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(0, 0, 0, 0.3);
  animation: peekZoom 1.5s ease-out forwards;
}

#window-peek-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: peekPan 8s ease-in-out infinite alternate;
}

#window-peek-vignette {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
  z-index: 1;
  pointer-events: none;
}

@keyframes peekZoom {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes peekPan {
  0% { transform: scale(1.1) translate(3%, 3%); }
  100% { transform: scale(1.1) translate(-3%, -3%); }
}

#window-peek-text {
  color: #c0d0e0;
  font-size: 14px;
  margin-top: 14px;
  letter-spacing: 2px;
  opacity: 0;
  animation: fadeUp 1s 0.5s forwards;
}

#window-close-btn {
  padding: 8px 26px;
  font-size: 14px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  background: transparent;
  color: #a0a0c0;
  border: 2px solid #5a5a7a;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 2px;
  margin-top: 14px;
}

#window-close-btn:hover {
  background: rgba(80, 80, 120, 0.3);
  color: #c0c0e0;
}

/* ===== モーダル内セリフ ===== */
.modal-dialog-text {
  color: #e0d0f0;
  font-size: 13px;
  min-height: 18px;
  margin-top: 10px;
  line-height: 1.6;
  text-align: center;
}

/* ===== 金庫叩くボタン ===== */
#safe-smash-btn {
  display: block;
  margin: 12px auto 0;
  padding: 10px 24px;
  font-size: 15px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 900;
  background: linear-gradient(135deg, #ff4060, #ff6040);
  color: #fff;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  letter-spacing: 2px;
  animation: smashPulse 0.8s ease-in-out infinite;
}

#safe-smash-btn.hidden { display: none; }

@keyframes smashPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 64, 96, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(255, 64, 96, 0.7); }
}

#safe-smash-btn:hover {
  background: linear-gradient(135deg, #ff2040, #ff4020);
}

/* ===== アイテム調査モーダル ===== */
#item-inspect-content {
  text-align: center;
  min-width: 200px;
}

#item-inspect-icon {
  font-size: 80px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

#item-inspect-name {
  color: #e0d0f0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

#item-inspect-close-btn {
  padding: 8px 26px;
  font-size: 14px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 700;
  background: transparent;
  color: #a0a0c0;
  border: 2px solid #5a5a7a;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 2px;
}

#item-inspect-close-btn:hover {
  background: rgba(80, 80, 120, 0.3);
  color: #c0c0e0;
}

/* ===== 画像＋英語テキストオーバーレイ ===== */
.img-overlay-wrap {
  position: relative;
  display: inline-block;
  max-width: 500px;
  width: 100%;
}

.img-overlay-wrap img {
  width: 100%;
  border-radius: 4px;
  display: block;
}

.riddle-overlay {
  position: relative;
  width: 100%;
  pointer-events: none;
}

/* 英語翻訳パネル（画像の下に表示） */
.riddle-translation {
  background: linear-gradient(180deg, #fffef8 0%, #f8f0e0 100%);
  border: 2px solid #e0d0b8;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  text-align: center;
  font-family: 'Zen Maru Gothic', sans-serif;
}

.riddle-q {
  color: #3a3020;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 4px;
}

.riddle-flavor {
  color: #c88030;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.riddle-a {
  color: #3a3020;
  font-size: 20px;
  font-weight: 900;
}

/* ===== メモモーダル ===== */
#memo-modal-content { text-align: center; }

#memo-paper {
  background: linear-gradient(180deg, #fff8f0 0%, #f0e8d8 100%);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transform: rotate(-1deg);
  max-width: 500px;
  border: 1px solid #d8d0b8;
}

.memo-line {
  color: #3a3020;
  font-size: 15px;
  line-height: 2.2;
  text-align: left;
}

.memo-hint {
  color: #9a8060;
  font-size: 12px;
  margin-top: 10px;
  font-style: italic;
  text-align: center;
}

/* ===== クリア演出 ===== */
#clear-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 60px 16px 40px;
  overflow-y: auto;
  z-index: 500;
  animation: clearBg 3s forwards;
}

@keyframes clearBg {
  0% { background: rgba(0, 0, 0, 0); }
  30% { background: rgba(255, 240, 248, 0.92); }
  100% { background: rgba(255, 245, 250, 0.96); }
}

.clear-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 14px;
  color: transparent;
  background: linear-gradient(135deg, #f06090 0%, #f0a040 25%, #a060f0 50%, #40b0f0 75%, #f06090 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  opacity: 0;
  animation: clearTitleIn 1.5s 0.8s forwards, gradientShift 3s 0.8s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
}

@keyframes clearTitleIn {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  50% { opacity: 1; transform: scale(1.15) rotate(2deg); }
  70% { transform: scale(0.95) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.clear-sub {
  font-size: 18px;
  color: #a08090;
  letter-spacing: 6px;
  margin-top: 18px;
  opacity: 0;
  animation: fadeUp 1s 2s forwards;
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.clear-time {
  font-size: 14px;
  color: #b8a8b0;
  margin-top: 8px;
  opacity: 0;
  animation: fadeUp 1s 2.5s forwards;
}

.clear-rank {
  font-size: 28px;
  font-weight: 900;
  color: #e0d0f8;
  margin-top: 20px;
  letter-spacing: 4px;
  opacity: 0;
  animation: fadeUp 1s 3.2s forwards;
  text-shadow: 0 0 20px rgba(255, 160, 200, 0.6);
  text-align: center;
  max-width: 90%;
  word-break: keep-all;
  line-height: 1.5;
}

.clear-rank-comment {
  font-size: 14px;
  color: #c0a0b0;
  margin-top: 8px;
  opacity: 0;
  animation: fadeUp 1s 3.8s forwards;
  font-style: italic;
  text-align: center;
  max-width: 90%;
  line-height: 1.6;
}

.clear-dialog {
  max-width: 600px;
  width: 90%;
  margin-top: 28px;
  background: linear-gradient(180deg, rgba(60, 30, 50, 0.96) 0%, rgba(40, 20, 35, 0.98) 100%);
  border: 2px solid #b0789a;
  border-radius: 14px;
  padding: 16px 24px;
  text-align: left;
  opacity: 0;
  animation: fadeUp 1s 2.8s forwards;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.clear-dialog-name {
  color: #f0a0c0;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 3px;
}

.clear-dialog-text {
  color: #f8f0f4;
  font-size: 15px;
  line-height: 1.75;
}

.clear-story {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-bottom: 40px;
}

.clear-dialog--delay2 {
  animation-delay: 4.2s;
}

.clear-dialog--delay3 {
  animation-delay: 5.6s;
}

.clear-dialog--delay4 {
  animation-delay: 7.0s;
}

.clear-dialog--delay5 {
  animation-delay: 8.4s;
}

.clear-ending {
  margin-top: 36px;
  color: #ffd0e0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  opacity: 0;
  animation: fadeUp 1.2s 9.8s forwards;
  text-shadow: 0 0 20px rgba(255, 160, 200, 0.6);
}

/* 紙吹雪 */
.confetti {
  position: fixed;
  width: 10px; height: 10px;
  z-index: 501;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(-20px) rotate(0deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.5); }
}

.light-particle {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  z-index: 502;
  opacity: 0;
  pointer-events: none;
  animation: particleFloat 3s ease-out forwards;
}

@keyframes particleFloat {
  0% { opacity: 0; transform: scale(0); }
  20% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0) translateY(-200px); }
}

/* ===== モバイル対応 ===== */
@media screen and (max-width: 980px) {
  body {
    align-items: center;
    overflow-x: hidden;
  }

  #game-wrapper {
    flex-direction: column-reverse;
    align-items: center;
    max-width: 100%;
    padding: 0 4px;
  }

  #game-container {
    width: 100%;
    max-width: 100%;
    flex-shrink: 1;
  }

  #room {
    height: auto;
    aspect-ratio: 780 / 380;
  }

  .game-title {
    font-size: 16px;
    letter-spacing: 3px;
    margin-bottom: 4px;
  }

  /* アイテムボックスを横並びに */
  #item-box {
    width: 100%;
    margin-top: 0;
    margin-bottom: 2px;
    padding: 8px 8px 2px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
  }

  #item-box-label {
    margin-bottom: 0;
    white-space: nowrap;
    font-size: 12px;
  }

  #item-slots {
    display: flex;
    gap: 4px;
    flex: 1;
  }

  .item-slot {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  #selected-item-name {
    position: static;
    transform: none;
    margin-top: 4px;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    font-size: 12px;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    z-index: auto;
    min-height: 18px;
    color: #f5c6d0;
  }

  #selected-item-name:empty {
    visibility: hidden;
  }

  #lang-switch {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
  }

  /* セリフボックス */
  #dialog-box {
    margin-top: 4px;
    height: 75px;
  }

  #dialog-portrait {
    width: 56px;
  }

  #dialog-content {
    padding: 8px 12px;
  }

  #dialog-text {
    font-size: 13px;
    line-height: 1.6;
  }

  #dialog-name {
    font-size: 12px;
  }

  /* 部屋内の要素をスケーリング */
  #room {
    font-size: clamp(8px, 1.3vw, 16px);
  }

  #door {
    left: 6.4%;
    top: 7.9%;
    width: 14.1%;
    height: 51.3%;
  }

  #door-frame {
    border-width: 3px;
    padding: 4px;
  }

  #doorknob {
    right: 10%;
    top: 44%;
    width: 18%;
    height: 9%;
  }

  #keyhole {
    right: 12%;
    top: 54%;
    width: 10%;
    height: 8%;
  }

  #keyhole::before {
    width: 5px;
    height: 5px;
  }

  #keyhole::after {
    width: 2px;
    height: 5px;
  }

  #painting {
    left: 30%;
    top: 3%;
    width: 14%;
    height: 20%;
  }

  #painting-frame {
    border-width: 3px;
    padding: 3px;
  }

  #clock {
    right: 15.4%;
    top: 3.9%;
    width: 7%;
    height: 14%;
  }

  #clock-face {
    border-width: 2px;
  }

  #clock-center {
    width: 3px;
    height: 3px;
  }

  #clock-hand-hour {
    width: 7px;
    height: 2px;
  }

  #clock-hand-minute {
    width: 10px;
    height: 1px;
  }

  #window {
    left: 53.8%;
    top: 6.6%;
    width: 14.1%;
    height: 21.1%;
  }

  #window-speech {
    top: 30.3%;
    left: 60.9%;
    font-size: 9px;
  }

  #table {
    right: 6.4%;
    bottom: 7.9%;
    width: 17.9%;
    height: 23.7%;
  }

  #safe {
    right: 9%;
    bottom: 32.1%;
    width: 8.5%;
    height: 11.5%;
  }

  #safe-body {
    border-width: 2px;
    border-radius: 4px;
  }

  #safe-display {
    font-size: 8px;
    padding: 1px 5px;
    letter-spacing: 2px;
    top: 4px;
  }

  #safe-handle {
    width: 10px;
    height: 10px;
    border-width: 2px;
    right: 4px;
    bottom: 3px;
  }

  #memo-on-floor {
    left: 41%;
    bottom: 14.5%;
    width: 5.9%;
    height: 12.1%;
  }

  #flashlight-on-floor {
    left: 64.1%;
    bottom: 18.4%;
    width: 5.9%;
    height: 12.1%;
  }

  #dust-on-floor {
    left: 23.1%;
    bottom: 10.5%;
    width: 5.9%;
    height: 12.1%;
  }

  #bento-on-floor {
    left: 55.1%;
    bottom: 9.2%;
    width: 5.9%;
    height: 12.1%;
  }

  #hidden-message {
    left: 28.2%;
    top: 34.2%;
    font-size: 10px;
  }

  .memo-shape { font-size: 22px; }
  .flashlight-shape { font-size: 20px; }
  .dust-shape { font-size: 20px; }
  .bento-shape { font-size: 20px; }
  .item-sparkle { font-size: 11px; }

  /* モーダル調整 */
  #safe-modal-content {
    min-width: auto;
    width: 90vw;
    max-width: 320px;
    padding: 18px;
  }

  #window-peek-frame {
    width: 260px;
    height: 260px;
  }

  #memo-paper {
    max-width: 90vw;
  }

  /* クリア画面 */
  .clear-title { font-size: 32px; letter-spacing: 6px; }
  .clear-rank { font-size: 22px; letter-spacing: 2px; }
  .clear-rank-comment { font-size: 13px; line-height: 1.6; }
  .clear-dialog { width: 95%; }
  .clear-buttons { flex-direction: column; align-items: center; gap: 10px; }
  .clear-back-link { font-size: 14px; padding: 10px 24px; }
}

/* スマホ横向き時の微調整 */
@media screen and (max-height: 500px) and (orientation: landscape) {
  body {
    padding: 4px 0;
  }

  .game-title {
    font-size: 14px;
    margin-bottom: 2px;
  }

  #dialog-box {
    height: 85px;
    margin-top: 4px;
  }

  #dialog-portrait {
    width: 48px;
  }

  #dialog-text {
    font-size: 12px;
  }

  #item-box {
    padding: 4px 8px;
  }

  .item-slot {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
}

/* ===== トップに戻るリンク ===== */
.back-to-top-link {
  position: fixed;
  top: 12px;
  left: 12px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  z-index: 300;
  transition: color 0.2s;
}
.back-to-top-link:hover {
  color: #fff;
}

/* ===== クリア画面のボタン ===== */
.clear-buttons {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  opacity: 0;
  animation: fadeUp 1s 2s forwards;
}

.clear-back-link {
  display: inline-block;
  margin-top: 0;
  padding: 12px 32px;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #f0a0c0;
  background: linear-gradient(180deg, rgba(60, 30, 50, 0.96) 0%, rgba(40, 20, 35, 0.98) 100%);
  border: 2px solid #b0789a;
  cursor: pointer;
  border-radius: 24px;
  text-decoration: none;
  letter-spacing: 3px;
  transition: background 0.2s, color 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.clear-back-link:hover {
  background: rgba(80, 40, 60, 0.9);
  color: #fff;
}
