:root {
  color-scheme: dark;
  --night: #17211f;
  --night-deep: #101816;
  --panel: #24322c;
  --panel-light: #2c3b33;
  --line: rgba(229, 222, 196, 0.18);
  --ink: #f3ecdc;
  --muted: #c3c0ad;
  --gold: #f2d8a1;
  --gold-deep: #c99f68;
  --mint: #b8d5bd;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--night-deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 0, rgba(123, 130, 96, 0.22), transparent 43%),
    radial-gradient(ellipse at 92% 100%, rgba(169, 117, 71, 0.13), transparent 45%),
    linear-gradient(135deg, #1b2722, #111b19 78%);
}

button { font: inherit; }
button:focus-visible { outline: 3px solid #ffe4aa; outline-offset: 3px; }
[hidden] { display: none !important; }

.app {
  width: min(100%, 1710px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 30px) clamp(14px, 2.4vw, 38px) 18px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(14px, 1.8vw, 26px);
}

.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.identity-glyph {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(246, 222, 178, 0.32);
  border-radius: 12px;
  color: var(--gold);
  font-size: 26px;
  box-shadow: inset 0 0 18px rgba(242, 216, 161, 0.08);
}
.identity h1, .cover h2, .ending-card h2 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.09em;
}
.identity h1 { margin: 2px 0 0; font-size: clamp(18px, 2vw, 28px); line-height: 1.25; }
.eyebrow, .section-label, .cover-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.masthead-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.text-button, .quiet-button {
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 9px 11px;
  transition: background 0.15s ease, color 0.15s ease;
}
.text-button:hover, .quiet-button:hover { background: rgba(255,255,255,0.08); color: var(--ink); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
  align-items: start;
  gap: clamp(14px, 1.6vw, 26px);
}

.stage { min-width: 0; }
.scene {
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 243, 209, 0.23);
  border-radius: 16px;
  background: #9a8b69;
  box-shadow: 0 26px 55px rgba(0, 0, 0, 0.36), 0 0 0 4px rgba(252, 233, 185, 0.035);
}
.scene > img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; }
.scene-tone {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 44%, rgba(20, 22, 16, 0.2) 100%);
}
.door-light {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  left: 35%; bottom: 7%; width: 36%; height: 23%;
  background: radial-gradient(ellipse at 50% 98%, rgba(255, 225, 148, 0.72), rgba(255, 217, 142, 0.2) 34%, transparent 72%);
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.5s ease;
}
.scene[data-footsteps="near"] .door-light { opacity: 0.9; }
.scene[data-footsteps="middle"] .door-light { opacity: 0.35; }

.hotspot {
  position: absolute;
  z-index: 4;
  top: var(--y);
  left: var(--x);
  width: clamp(44px, 5.5vw, 72px);
  height: clamp(44px, 5.5vw, 72px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hotspot::before {
  position: absolute;
  top: 50%; left: 50%;
  width: 11px; height: 11px;
  transform: translate(-50%, -50%);
  border: 1px solid #fff5d9;
  border-radius: 50%;
  background: rgba(239, 215, 155, 0.82);
  box-shadow: 0 0 0 7px rgba(26, 33, 27, 0.33), 0 0 0 8px rgba(255, 245, 212, 0.56), 0 0 20px rgba(255, 232, 158, 0.7);
  content: "";
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.hotspot:hover::before, .hotspot.is-selected::before, .hotspot:focus-visible::before {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 0 8px rgba(25, 33, 27, 0.48), 0 0 0 10px #ffe6aa, 0 0 28px rgba(255, 230, 170, 0.95);
}
.hotspot::after {
  position: absolute;
  top: calc(50% + 26px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  border: 1px solid rgba(255, 246, 209, 0.25);
  border-radius: 20px;
  color: white;
  background: rgba(22, 31, 26, 0.82);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  content: attr(data-label);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.hotspot:hover::after, .hotspot:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.app[data-phase="title"] .hotspot, .app[data-phase="escaped"] .hotspot { pointer-events: none; }
.scene-status {
  position: absolute;
  z-index: 5;
  top: 14px; right: 14px;
  border: 1px solid rgba(255, 239, 199, 0.25);
  border-radius: 999px;
  padding: 8px 12px;
  color: #fff7e5;
  background: rgba(24, 34, 29, 0.74);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.ripple {
  position: absolute;
  z-index: 6;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 246, 212, 0.94);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255, 218, 143, 0.55);
  opacity: 0;
  pointer-events: none;
}
.ripple.is-active { animation: ripple 0.68s ease-out both; }
@keyframes ripple { 0% { opacity: 0.96; width: 18px; height: 18px; } 100% { opacity: 0; width: 140px; height: 140px; } }

.cover {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  align-items: center;
  justify-items: start;
  padding: clamp(18px, 4.5vw, 70px);
  background: linear-gradient(90deg, rgba(12, 23, 19, 0.85) 0%, rgba(14, 25, 22, 0.66) 42%, rgba(17, 27, 24, 0.08) 100%);
  backdrop-filter: blur(1.5px);
}
.cover-card { max-width: 430px; }
.cover-rule { display: block; width: 53px; height: 2px; background: var(--gold); margin-bottom: 18px; }
.cover h2 { margin: 12px 0 6px; font-size: clamp(31px, 4.1vw, 64px); line-height: 1.18; text-shadow: 0 3px 22px rgba(0,0,0,.24); }
.cover-subtitle { margin: 0; color: var(--gold); font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif; font-size: clamp(14px, 1.3vw, 19px); letter-spacing: .1em; }
.cover-intro, .ending-card p:not(.cover-kicker) { max-width: 36ch; color: #f0e8d9; font-size: clamp(12px, 1.05vw, 15px); line-height: 1.85; }
.cover-intro { margin: 22px 0 24px; }
.primary-button {
  min-width: 180px;
  border: 1px solid #ffe4ac;
  border-radius: 10px;
  padding: 13px 23px;
  color: #293129;
  background: linear-gradient(135deg, #f8e7bb, #d9b879);
  box-shadow: 0 8px 26px rgba(0,0,0,.23), inset 0 1px rgba(255,255,255,.38);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .08em;
  transition: transform .16s ease, filter .16s ease;
}
.primary-button:hover { transform: translateY(-2px); filter: brightness(1.05); }
.ending { background: linear-gradient(100deg, rgba(17, 31, 25, .9), rgba(26, 42, 30, .78) 45%, rgba(74, 62, 37, .22)); }
.ending-card h2 { font-size: clamp(29px, 3.7vw, 58px); }

.scene-caption {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #bfc6b4;
  padding: 10px 3px 0;
  font-size: 11px;
  letter-spacing: .08em;
}
.caption-mark { color: var(--gold); }
.caption-divider { height: 1px; width: 16px; background: rgba(255,255,255,.26); }

.control-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.app[data-phase="title"] .control-panel { opacity: .57; pointer-events: none; }
.story-card, .selection-card, .action-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(45, 61, 49, .95), rgba(31, 45, 39, .96));
  box-shadow: inset 0 1px rgba(255,255,255,.05), 0 10px 28px rgba(0,0,0,.11);
}
.story-card { padding: 18px 19px 15px; min-height: 178px; }
.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.ambient-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(238, 224, 187, .24);
  border-radius: 999px;
  padding: 5px 9px;
  color: #efdec2;
  background: rgba(12, 26, 19, .18);
  white-space: nowrap;
  font-size: 10px;
}
.ambient-pill::before { width: 5px; height: 5px; border-radius: 50%; background: #c8d6ad; content: ""; }
.story-text { min-height: 72px; margin: 19px 0 12px; font-size: 15px; line-height: 1.75; letter-spacing: .03em; }
.story-rule { height: 1px; background: rgba(238, 225, 193, .17); }
.clue-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.clue-row strong { color: var(--ink); font-size: 12px; }
.selection-card, .action-card { padding: 16px 18px 18px; }
.selection-card .section-label { margin-bottom: 12px; }
.object-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.object-chip {
  border: 1px solid rgba(238, 223, 188, .21);
  border-radius: 8px;
  padding: 8px 11px;
  color: #d7d8c6;
  background: rgba(9, 25, 19, .2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.object-chip:hover, .object-chip.is-selected { border-color: #e6ca90; color: #fff3d6; background: rgba(189, 139, 68, .2); }
.action-card { padding-top: 18px; }
.target-name { margin: 8px 0 6px; font-size: 25px; font-weight: 600; letter-spacing: .07em; font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif; }
.target-hint { min-height: 47px; margin: 0 0 16px; color: #cbd0bd; font-size: 12px; line-height: 1.7; }
.action-label { margin-bottom: 9px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-button {
  min-height: 43px;
  border: 1px solid rgba(231, 224, 198, .2);
  border-radius: 8px;
  padding: 9px 10px;
  color: #eee8d9;
  background: rgba(10, 24, 18, .28);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.action-button:hover { transform: translateY(-1px); border-color: #ddc08b; background: rgba(141, 107, 60, .22); }
.action-accent { color: #292f27; background: linear-gradient(135deg, #f0dcad, #d8bb83); border-color: #e0c391; }
.action-accent:hover { background: linear-gradient(135deg, #ffe7b6, #e9c991); }
.listen-button { color: #dce8d3; border-color: rgba(195, 230, 188, .34); }
.signal-track { display: flex; gap: 6px; margin-top: 17px; }
.signal-track span { flex: 1; height: 3px; border-radius: 3px; background: rgba(243, 222, 173, .19); transition: background .18s ease, box-shadow .18s ease; }
.signal-track span.is-lit { background: #f0d9a8; box-shadow: 0 0 12px rgba(255,230,170,.72); }
.key-hint { margin: 13px 0 0; color: #9eaa9d; font-size: 10px; line-height: 1.6; }
.panel-bottom { display: flex; align-items: center; justify-content: space-between; min-height: 31px; }
.dev-hud { color: #f5d79a; font: 10px ui-monospace, SFMono-Regular, monospace; }
.page-footer { max-width: 960px; margin: 20px 0 0; color: #839387; font-size: 10px; line-height: 1.6; letter-spacing: .03em; }

.help-dialog {
  width: min(520px, calc(100vw - 30px));
  border: 1px solid rgba(248, 224, 177, .35);
  border-radius: 15px;
  padding: 25px;
  color: var(--ink);
  background: #26352e;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.help-dialog::backdrop { background: rgba(9, 17, 14, .68); backdrop-filter: blur(4px); }
.dialog-topline { display: flex; align-items: center; justify-content: space-between; }
.help-dialog h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif; font-weight: 500; letter-spacing: .04em; }
.help-dialog p { line-height: 1.8; font-size: 14px; }
.help-dialog .help-keys { color: #bcc6b6; font-size: 12px; }

@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .story-card { grid-column: 1 / -1; min-height: 0; }
  .story-text { min-height: 0; }
  .panel-bottom { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .app { padding: 12px 10px max(18px, env(safe-area-inset-bottom)); }
  .masthead { margin-bottom: 12px; align-items: flex-start; }
  .identity-glyph { width: 32px; height: 32px; font-size: 20px; }
  .identity { gap: 7px; }
  .identity h1 { font-size: 17px; }
  .eyebrow { font-size: 8px; letter-spacing: .11em; }
  .masthead-actions { gap: 0; max-width: 165px; }
  .text-button { padding: 5px 6px; font-size: 10px; }
  .scene { border-radius: 9px; }
  .hotspot { width: 44px; height: 44px; }
  .hotspot::before { width: 8px; height: 8px; box-shadow: 0 0 0 5px rgba(26,33,27,.4), 0 0 0 6px rgba(255,245,212,.65), 0 0 13px rgba(255,232,158,.7); }
  .scene-status { top: 6px; right: 6px; padding: 5px 7px; font-size: 8px; }
  .cover { padding: 13px 18px; background: linear-gradient(90deg, rgba(12, 23, 19, .88), rgba(14, 25, 22, .66) 60%, rgba(17, 27, 24, .1)); }
  .cover-rule, .cover-kicker, .cover-intro { display: none; }
  .cover h2 { margin: 0 0 5px; font-size: 26px; }
  .cover-subtitle { font-size: 11px; }
  .primary-button { min-width: 0; margin-top: 10px; padding: 7px 13px; font-size: 11px; }
  .ending-card h2 { font-size: 24px; }
  .ending-card p:not(.cover-kicker) { margin: 3px 0; font-size: 10px; line-height: 1.35; }
  .scene-caption { padding-top: 7px; font-size: 9px; }
  .control-panel { display: flex; gap: 8px; }
  .story-card, .selection-card, .action-card { border-radius: 10px; }
  .story-card { padding: 11px 13px; }
  .story-text { margin: 8px 0; font-size: 12px; min-height: 0; }
  .clue-row { margin-top: 7px; }
  .selection-card, .action-card { padding: 12px 13px; }
  .selection-card .section-label { margin-bottom: 8px; }
  .object-chip { padding: 8px 10px; }
  .target-name { font-size: 21px; margin: 5px 0; }
  .target-hint { min-height: 0; margin-bottom: 10px; }
  .action-button { min-height: 42px; }
  .key-hint { display: none; }
  .page-footer { margin-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
