:root {
  --bg: #14101c;
  --panel: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f4f0fa;
  --muted: #a99fbd;
  --accent: #ff3d7f;
  --gold: #ffd84a;
  --cyan: #5ee6ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b0810;
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

#app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 61, 127, 0.22), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 12px, transparent 12px 24px),
    var(--bg);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---- 画面の切り替え ---- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } }

.screen-title {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--gold);
}
.hint { margin: 4px 0 14px; color: var(--muted); font-size: 14px; text-align: center; line-height: 1.6; }

.btn-main {
  margin-top: 18px;
  padding: 14px 36px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #ff7a3d);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 6px 20px rgba(255, 61, 127, 0.35);
}
.btn-main:active { transform: scale(0.97); }
.btn-main:disabled { opacity: 0.5; }

/* ---- HUD ---- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 60px 10px 14px; /* 右端はミュートボタンの場所 */
  background: linear-gradient(rgba(11, 8, 16, 0.9), transparent);
}
#hud[hidden] { display: none; }
#trust { font-size: 18px; color: var(--accent); letter-spacing: 2px; }
#trust small { color: var(--muted); font-size: 11px; letter-spacing: 0; margin-right: 6px; }
#open-file {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
}

/* ---- タイトル ---- */
#title { justify-content: center; text-align: center; }
.title-faces { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.title-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 300px; }
.title-faces img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--line);
  filter: grayscale(0.4) brightness(0.8);
}
.title-faces img.hero {
  width: 84px;
  height: 84px;
  border: 3px solid var(--cyan);
  filter: none;
}
.title-sub { margin: 0; color: var(--accent); font-size: 12px; letter-spacing: 0.4em; font-weight: 700; }
.title-logo {
  margin: 6px 0 4px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
}
.title-logo span {
  display: inline-block;
  font-size: 52px;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--accent);
  transform: skew(-6deg);
}
.title-case { margin: 6px 0 20px; font-size: 16px; color: var(--text); }
.credit { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); margin: 0; font-size: 11px; color: var(--muted); }

/* ---- 会話 ---- */
#vn { justify-content: flex-end; cursor: pointer; }
.portrait {
  width: min(62vw, 250px);
  height: min(62vw, 250px);
  margin: auto 0 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--cyan);
  box-shadow: 0 0 40px rgba(94, 230, 255, 0.25);
  animation: pop 0.25s ease;
}
.portrait[hidden] { display: block; visibility: hidden; }
@keyframes pop { from { transform: scale(0.92); opacity: 0.4; } }
.dialog {
  position: relative;
  width: 100%;
  min-height: 150px;
  padding: 22px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 8, 16, 0.85);
}
.nameplate {
  position: absolute;
  top: -15px;
  left: 14px;
  padding: 4px 14px;
  border-radius: 6px;
  background: var(--accent);
  font-weight: 800;
  font-size: 14px;
}
.nameplate:empty { display: none; }
#vn-text { margin: 0; font-size: 16px; line-height: 1.75; white-space: pre-wrap; }
.next-mark {
  position: absolute;
  right: 14px;
  bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- 捜査 ---- */
.spots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  overflow-y: auto;
}
.spot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 14px;
  font-weight: 700;
}
.spot-icon { font-size: 30px; }
.spot.done { opacity: 0.55; }
.spot .check {
  position: absolute;
  top: 6px;
  right: 8px;
  color: var(--gold);
}

/* ---- 議論 ---- */
.timer {
  width: 100%;
  height: 4px;
  margin: 6px 0 14px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
#timer-bar { height: 100%; background: var(--accent); transform-origin: left; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.statement {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 8, 16, 0.75);
  animation: slide-in 0.3s ease;
}
.statement.shake { animation: shake 0.4s ease; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.st-face {
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--line);
}
.st-body { flex: 1; min-width: 0; }
.st-name { margin-bottom: 6px; font-size: 13px; font-weight: 800; }
.st-text { margin: 0; font-size: 17px; line-height: 1.8; font-weight: 700; }
.weak {
  padding: 1px 3px;
  border-radius: 4px;
  color: var(--gold);
  background: rgba(255, 216, 74, 0.14);
  box-shadow: inset 0 -2px 0 var(--gold);
  cursor: pointer;
  animation: glow 1.4s ease-in-out infinite;
}
@keyframes glow { 50% { background: rgba(255, 216, 74, 0.32); } }
.st-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 10px;
}
.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--gold); }
#st-next {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
}
.ev-desc {
  min-height: 66px;
  width: 100%;
  margin: auto 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.tray {
  display: flex;
  gap: 8px;
  width: 100%;
  padding-bottom: 4px;
  overflow-x: auto;
}
.card {
  flex: none;
  width: 92px;
  padding: 10px 6px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.card .card-icon { display: block; font-size: 24px; margin-bottom: 4px; }
.card.selected {
  border-color: var(--gold);
  background: rgba(255, 216, 74, 0.16);
  transform: translateY(-4px);
}

/* ---- 推理のまとめ ---- */
.quiz-q {
  width: 100%;
  margin: 10px 0 18px;
  padding: 18px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--panel);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.6;
}
.choices { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.choice {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(11, 8, 16, 0.75);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}
.choice:active { background: rgba(255, 61, 127, 0.25); }

/* ---- 犯人の指名 ---- */
.suspects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; overflow-y: auto; }
.suspect {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 8, 16, 0.75);
  font-size: 14px;
  font-weight: 800;
}
.suspect img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.suspect:active { border-color: var(--accent); }

/* ---- 結果 ---- */
#result, #gameover { justify-content: center; text-align: center; }
.result-head { margin: 8px 0; font-size: 36px; color: var(--gold); }
.result-head.bad { color: var(--accent); font-size: 28px; }
.rank {
  margin: 14px 0 6px;
  font-size: 96px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  text-shadow: 4px 4px 0 var(--gold);
}

/* ---- 演出 ---- */
.flash {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 61, 127, 0.25);
  font-size: 46px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 4px 4px 0 var(--accent), -2px -2px 0 #000;
  animation: flash-in 1.3s ease forwards;
  pointer-events: none;
}
.flash[hidden] { display: none; }
@keyframes flash-in {
  0% { transform: scale(2.4) rotate(-8deg); opacity: 0; }
  20% { transform: scale(1) rotate(-6deg); opacity: 1; }
  80% { transform: scale(1.05) rotate(-6deg); opacity: 1; }
  100% { transform: scale(1.1) rotate(-6deg); opacity: 0; }
}
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  z-index: 15;
  max-width: 88%;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  transform: translateX(-50%);
}
.toast[hidden] { display: none; }
.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
}
.modal[hidden] { display: none; }
.modal-box {
  width: 100%;
  max-height: 80%;
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #1f1830;
  text-align: center;
}
.modal-box h3 { margin: 0 0 10px; color: var(--gold); font-size: 15px; }
.ev-item { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); text-align: left; font-size: 13px; line-height: 1.6; }
.ev-item .card-icon { font-size: 26px; }
.ev-big { font-size: 52px; }

#mute {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  right: 12px;
  z-index: 6;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 16px;
}
