:root {
  --ink: #2b2430;
  --muted: #6d6075;
  --cream: #fff8ea;
  --paper: rgba(255, 250, 240, 0.94);
  --paper-strong: rgba(255, 250, 240, 0.98);
  --moon: #f4dca8;
  --berry: #8d5fa3;
  --berry-dark: #5f3f7f;
  --teal: #6ebdb5;
  --shadow: rgba(38, 28, 49, 0.23);
  --line: rgba(95, 63, 127, 0.18);
  --success: #2f7d67;
  --danger: #9c4d5f;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(244, 220, 168, 0.45), transparent 28%),
    linear-gradient(145deg, #3d3150, #75618d 55%, #a87990);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.start-screen {
  min-height: calc(100vh - 36px);
  display: none;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.start-screen.active { display: grid; }

.moon-glow {
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 242, 190, 0.7), rgba(255, 242, 190, 0.08) 58%, transparent 70%);
  top: -80px;
  right: -80px;
  filter: blur(2px);
}

.title-card,
.panel,
.scene-card,
.case-status,
.game-header {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 20px 55px var(--shadow);
  backdrop-filter: blur(10px);
}

.title-card {
  width: min(620px, 94vw);
  text-align: center;
  border-radius: 34px;
  padding: 30px 24px 26px;
  position: relative;
  z-index: 2;
}

.title-tofu {
  width: min(220px, 52vw);
  aspect-ratio: 1;
  object-fit: contain;
  margin: -10px auto 0;
  display: block;
  filter: drop-shadow(0 14px 16px rgba(55, 38, 72, 0.25));
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--berry-dark);
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 0.12em;
  font-weight: 800;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  font-size: clamp(2.2rem, 8vw, 4.45rem);
  line-height: 0.95;
  margin-bottom: 14px;
  color: #3a294c;
}

h2 { margin-bottom: 4px; }
h3 { margin-bottom: 12px; color: #3b2c4e; }

.case-line,
.case-subtitle,
.intro-copy,
.small-note {
  color: var(--muted);
}

.intro-copy {
  line-height: 1.55;
  max-width: 52ch;
  margin-inline: auto;
}

.small-note {
  font-size: 0.88rem;
  line-height: 1.42;
}

.primary-btn,
.accent-btn,
.ghost-btn,
.room-btn,
.action-btn {
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-btn {
  color: #fffaf0;
  background: linear-gradient(135deg, var(--berry-dark), var(--berry));
  box-shadow: 0 12px 22px rgba(95, 63, 127, 0.28);
}

.accent-btn {
  color: #fffaf0;
  background: linear-gradient(135deg, #2f8f86, var(--teal));
  box-shadow: 0 10px 18px rgba(47, 143, 134, 0.24);
}

.ghost-btn,
.room-btn,
.action-btn {
  color: var(--berry-dark);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(38, 28, 49, 0.16);
}

.game-header {
  border-radius: 26px;
  padding: 18px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.header-actions { flex: 0 0 auto; }

.case-status {
  border-radius: 22px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.case-status div {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid var(--line);
}

.case-status span {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
}

.case-status strong {
  display: block;
  margin-top: 4px;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.scene-card {
  border-radius: 28px;
  padding: 12px;
}

.scene-frame {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background: #463756;
  aspect-ratio: 1024 / 1820;
  max-height: min(72vh, 820px);
  margin: 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.room-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sprite-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tofu-sprite,
.suspect-sprite {
  position: absolute;
  bottom: 4%;
  transform: translateX(-50%);
  filter: drop-shadow(0 12px 10px rgba(33, 26, 40, 0.35));
}

.tofu-sprite {
  width: 33%;
  left: 22%;
  z-index: 5;
}

.suspect-button {
  pointer-events: auto;
  background: transparent;
  padding: 0;
  width: 32%;
  max-width: 190px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.55);
}

.suspect-button img {
  width: 100%;
  display: block;
}

.suspect-button span {
  display: inline-block;
  margin-top: -8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(64, 45, 82, 0.74);
  border: 1px solid rgba(255,255,255,0.35);
  font-size: 0.78rem;
  font-weight: 900;
}

.room-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.room-btn.active {
  background: var(--paper-strong);
  color: #2f7d67;
  outline: 2px solid rgba(110, 189, 181, 0.45);
}

.right-column {
  display: grid;
  gap: 12px;
}

.panel {
  border-radius: 24px;
  padding: 16px;
}

.dialogue-log {
  min-height: 82px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  line-height: 1.5;
}

.button-stack {
  display: grid;
  gap: 8px;
}

.action-btn {
  width: 100%;
  text-align: left;
  line-height: 1.35;
}

.action-btn small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.action-btn.done {
  opacity: 0.65;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notebook-content {
  display: grid;
  gap: 12px;
}

.note-category {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.note-category h4 {
  margin: 0 0 8px;
  color: var(--berry-dark);
}

.note-item {
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.note-item strong { display: block; }
.note-item p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }

.accuse-form {
  display: grid;
  gap: 10px;
}

.accuse-form label {
  display: grid;
  gap: 5px;
  font-weight: 800;
  color: var(--berry-dark);
}

select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffaf0;
  padding: 12px;
  color: var(--ink);
}

.result-panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  line-height: 1.5;
}

.result-panel.win {
  border-color: rgba(47, 125, 103, 0.38);
  background: rgba(234, 255, 247, 0.76);
}

.result-panel.miss {
  border-color: rgba(156, 77, 95, 0.32);
  background: rgba(255, 241, 245, 0.76);
}

@media (max-width: 860px) {
  .app-shell { padding: 10px; }
  .game-header {
    align-items: stretch;
    flex-direction: column;
    border-radius: 22px;
  }
  .header-actions { display: grid; }
  .case-status { grid-template-columns: 1fr; }
  .play-layout { grid-template-columns: 1fr; }
  .scene-frame { max-height: 66vh; }
  .room-nav { grid-template-columns: repeat(2, 1fr); }
  .panel-title-row { align-items: stretch; flex-direction: column; }
  .tofu-sprite { width: 32%; left: 20%; }
  .suspect-button { width: 34%; }
}

@media (max-width: 440px) {
  .title-card { padding: 22px 16px; }
  .room-nav { grid-template-columns: 1fr; }
  .primary-btn, .accent-btn, .ghost-btn, .room-btn, .action-btn { padding: 11px 13px; }
  .suspect-button span { font-size: 0.7rem; }
}
