:root {
  --bg: #1a1230;
  --panel: #2a1f47;
  --panel-light: #3b2d63;
  --accent: #ffd166;
  --text: #efe6ff;
  --muted: #b3a5d6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12px;
}

#topbar {
  width: min(960px, 96vw);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
#topbar h1 { font-size: 17px; letter-spacing: 1px; color: var(--accent); }
#topbar .sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
#roomName { font-size: 13px; color: var(--muted); }
#btnMute {
  background: var(--panel); border: 1px solid var(--panel-light);
  border-radius: 8px; font-size: 16px; padding: 4px 10px; cursor: pointer;
}

/* ===== ステージ ===== */
#stage {
  position: relative;
  width: min(960px, 96vw);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0a22;
}
#roomView { position: absolute; inset: 0; }
#roomView img.bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
#roomView.noimg img.bg { display: none; }

/* ホットスポット */
.hs {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 8px;
}
.hs:hover { background: rgba(255, 209, 102, 0.10); box-shadow: inset 0 0 0 2px rgba(255, 209, 102, 0.35); }
/* 画像なし or デバッグ時：枠とラベルを常時表示 */
#roomView.noimg .hs, #roomView.debug .hs {
  border: 2px dashed rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.06);
}
#roomView.noimg .hs::after, #roomView.debug .hs::after {
  content: attr(data-label);
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: var(--text);
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  pointer-events: none;
}

/* ===== オーバーレイ共通 =====
   スマホでステージ枠が小さくてもモーダルが操作できるよう、
   ステージ内ではなくビューポート全体に重ねる */
.overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 25, 0.75);
  z-index: 10;
}
.overlay.show { display: flex; }

/* タイトル */
#title { background: radial-gradient(ellipse at 50% 30%, #3b2d63 0%, #0d081f 80%); }
#title.has-bg { background-size: cover; background-position: center; }
.title-box {
  background: rgba(10, 5, 25, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 209, 102, 0.4);
  border-radius: 16px;
  padding: 28px 44px;
  text-align: center;
}
.title-box h2 { color: var(--accent); font-size: 26px; letter-spacing: 3px; margin-bottom: 6px; }
.title-box .subtitle { color: var(--muted); margin-bottom: 22px; letter-spacing: 6px; }
.title-box button {
  display: block;
  width: 200px;
  margin: 10px auto;
  background: var(--accent); color: #1a1230;
  border: none; border-radius: 10px;
  padding: 10px 0; font-size: 16px; font-weight: bold;
  cursor: pointer;
}
.title-box button:hover { filter: brightness(1.1); }
.title-box .note { font-size: 11px; color: var(--muted); margin-top: 16px; }

/* モーダル */
.modal-box {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 22px 30px;
  text-align: center;
  max-width: 86%;
  max-height: 86%;
  overflow-y: auto;
}
.modal-box p { margin-bottom: 14px; line-height: 1.8; }
.modal-box .dim { color: var(--muted); font-size: 13px; }
.modal-box .row { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.modal-box select {
  background: var(--panel-light); color: var(--text);
  border: 1px solid #5a4a8a; border-radius: 8px;
  font-size: 18px; padding: 6px 10px;
}
.modal-box .act {
  background: var(--accent); color: #1a1230;
  border: none; border-radius: 10px;
  padding: 8px 24px; font-size: 15px; font-weight: bold;
  cursor: pointer; margin: 4px;
}
.modal-box .quiet {
  background: none; border: 1px solid var(--muted); color: var(--muted);
  border-radius: 8px; padding: 7px 16px; cursor: pointer; margin: 4px;
}
.modal-box .bigbtn {
  width: 76px; height: 76px;
  font-size: 34px;
  background: var(--panel-light);
  border: 2px solid #5a4a8a;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s;
}
.modal-box .bigbtn:hover { transform: scale(1.07); border-color: var(--accent); }
.modal-box .bigbtn.lit { background: #4a3a2a; border-color: var(--accent); box-shadow: 0 0 12px var(--accent); }
.modal-box .wordbtn {
  background: var(--panel-light); color: var(--text);
  border: 2px solid #5a4a8a; border-radius: 10px;
  padding: 8px 18px; font-size: 16px; cursor: pointer;
}
.modal-box .wordbtn:hover { border-color: var(--accent); }
.modal-box .letter {
  text-align: left;
  background: #efe6d0; color: #3a2a10;
  border-radius: 8px;
  padding: 18px 22px;
  line-height: 2;
  font-size: 14px;
  max-width: 480px;
}

/* エンディング */
#ending { background-size: cover; background-position: center; align-items: flex-end; padding-bottom: 20px; }
.clear-box {
  background: rgba(10, 5, 25, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 209, 102, 0.4);
  border-radius: 14px;
  padding: 14px 30px;
  text-align: center;
  max-width: 88%;
  animation: fadein 1.5s ease-out;
}
@keyframes fadein { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.clear-box h2 { color: var(--accent); font-size: 24px; margin-bottom: 8px; letter-spacing: 3px; text-shadow: 0 2px 8px #000; }
.clear-box p { color: var(--text); margin-bottom: 10px; line-height: 1.7; text-shadow: 0 1px 4px #000; font-size: 14px; }
#endBadges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
#endBadges span {
  background: rgba(255, 209, 102, 0.15);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 12px;
}
.clear-box button {
  background: var(--accent); color: #1a1230;
  border: none; border-radius: 10px;
  padding: 8px 26px; font-size: 15px; font-weight: bold;
  cursor: pointer;
}

/* ===== 部屋ナビ・メッセージ・インベントリ ===== */
#roomNav {
  width: min(960px, 96vw);
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
#roomNav button {
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--panel-light);
  border-radius: 10px;
  padding: 7px 18px; font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
#roomNav button.cur { color: var(--accent); border-color: var(--accent); }
#roomNav button.new { animation: pulse 1.2s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 rgba(255,209,102,0); } to { box-shadow: 0 0 10px rgba(255,209,102,0.7); } }

#msg {
  width: min(960px, 96vw);
  background: var(--panel);
  border: 1px solid var(--panel-light);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 10px;
  min-height: 52px;
  font-size: 15px;
  line-height: 1.6;
}

#inv {
  width: min(960px, 96vw);
  display: flex;
  gap: 8px;
  margin-top: 10px;
  min-height: 68px;
  flex-wrap: wrap;
}
.item {
  width: 64px; height: 64px;
  background: var(--panel);
  border: 2px solid var(--panel-light);
  border-radius: 10px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 24px;
  user-select: none;
}
.item small { font-size: 9px; color: var(--muted); margin-top: 2px; }
.item.sel { border-color: var(--accent); background: #4a3a2a; box-shadow: 0 0 8px var(--accent); }
#invLabel { color: var(--muted); font-size: 12px; align-self: center; }

@media (max-width: 600px) {
  #topbar h1 { font-size: 13px; }
  #topbar .sub { display: none; }
  .title-box { padding: 20px 24px; }
  .title-box h2 { font-size: 19px; }
  #msg { font-size: 13px; }
  #roomNav { gap: 5px; overflow-x: auto; }
  #roomNav button { padding: 6px 8px; font-size: 12px; flex-shrink: 0; }
  .modal-box { padding: 16px 12px; max-width: 94%; }
  .modal-box .bigbtn { width: 58px; height: 58px; font-size: 26px; }
  .modal-box .row { gap: 8px; }
  .modal-box .letter { padding: 14px 16px; font-size: 13px; }
  .clear-box { padding: 12px 16px; }
  .clear-box h2 { font-size: 19px; }
  .clear-box p { font-size: 12px; }
  .item { width: 56px; height: 56px; font-size: 20px; }
}
