:root {
  --ink: #2a241c;
  --forest: #2d4a36;
  --forest-deep: #1e3228;
  --paper: #f4eedf;
  --paper-warm: #ebe2cf;
  --wood: #5c4030;
  --brass: #b88848;
  --rust: #b84a32;
  --leaf: #c87830;
  --good: #3a7a52;
  --edge: #a89878;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Hiragino Sans", Meiryo, serif;
  color: var(--ink);
  background: var(--forest-deep);
  min-height: 100dvh;
  line-height: 1.4;
}

.forest-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 120% 60% at 50% 0%, #4a6a52 0%, transparent 55%),
    linear-gradient(180deg, #3d5a44 0%, #243828 45%, #1a2820 100%);
}

.lamp-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 50% at 50% 18%, rgba(255, 200, 120, 0.22), transparent 65%);
}

a {
  color: var(--paper);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.masthead {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.55rem 1rem 0;
  position: relative;
  z-index: 2;
}

.masthead .back {
  font-size: 0.84rem;
  font-family: "Hiragino Sans", sans-serif;
}

.case-board {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0.75rem 1.25rem;
  display: grid;
  gap: 0.45rem;
  position: relative;
}

.hero {
  padding: 0.15rem 0.1rem 0;
}

.case-file {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--brass);
  font-family: ui-monospace, Menlo, monospace;
}

.kicker {
  margin: 0;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: rgba(244, 238, 223, 0.65);
  font-family: "Hiragino Sans", sans-serif;
}

.hero h1 {
  margin: 0.08rem 0;
  font-size: 1.22rem;
  line-height: 1.15;
  font-weight: 800;
  color: var(--paper);
}

.hero h1 span {
  display: block;
  font-size: 0.98rem;
  color: #e8c8a0;
}

.catch {
  margin: 0.12rem 0 0;
  font-size: 0.78rem;
  color: rgba(244, 238, 223, 0.85);
  font-family: "Hiragino Sans", sans-serif;
}

.hud {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
}

.hud span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  background: var(--paper);
  border: 2px solid var(--wood);
  box-shadow: 0 2px 0 rgba(42, 36, 28, 0.2);
  font-size: 0.7rem;
  font-family: "Hiragino Sans", sans-serif;
}

.hud strong {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.time-chip {
  position: relative;
}

.penalty-float {
  position: absolute;
  right: 12%;
  top: 4.2rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--rust);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
  font-family: "Hiragino Sans", sans-serif;
}

.penalty-float.show {
  opacity: 1;
  transform: translateY(0);
}

.banner {
  margin: 0;
  text-align: center;
  font-weight: 700;
  padding: 0.38rem 0.5rem;
  border-radius: 8px;
  background: var(--paper);
  border: 2px solid var(--leaf);
  font-family: "Hiragino Sans", sans-serif;
  font-size: 0.82rem;
}

.banner.is-bad {
  border-color: var(--rust);
  color: var(--rust);
}

.banner.is-good {
  border-color: var(--good);
  color: var(--good);
}

.desk-stage {
  position: relative;
  background:
    linear-gradient(180deg, #6b5040 0%, #5a4030 8px, transparent 8px),
    var(--paper-warm);
  border: 3px solid var(--wood);
  border-radius: 4px 4px 12px 12px;
  padding: 0.55rem 0.5rem 0.6rem;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 248, 230, 0.5);
}

.desk-stage::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 18px;
  background: linear-gradient(180deg, var(--brass), #8a6838);
  border-radius: 4px 4px 0 0;
  border: 2px solid #6a5028;
}

.match-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.match-wires .wire {
  stroke: var(--rust);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.85;
}

.evidence-panel h2,
.suspect-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--wood);
  font-family: "Hiragino Sans", sans-serif;
}

.evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.32rem;
}

.evidence-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem;
  align-items: center;
  padding: 0.38rem 0.42rem;
  border-radius: 6px;
  background: #faf6ea;
  border: 2px solid var(--edge);
  font-size: 0.82rem;
  font-weight: 700;
  position: relative;
}

.evidence-card.kind-footprint {
  border-style: dashed;
  background: #f0e8d8;
}

.evidence-card.kind-item {
  border-color: #9a7a50;
}

.evidence-card.kind-direction {
  border-color: #6a8a6a;
}

.evidence-card.is-negative {
  border-color: var(--rust);
  box-shadow: inset 3px 0 0 var(--rust);
}

.evidence-card.is-negative .ev-text::after {
  content: "（否定）";
  font-size: 0.65rem;
  margin-left: 0.25rem;
  color: var(--rust);
  font-weight: 800;
}

.evidence-card.is-bonus {
  animation: slide-in 0.45s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.evidence-card.is-new {
  animation: card-in 0.35s ease;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bonus-tag {
  position: absolute;
  top: -6px;
  left: 8px;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  font-size: 0.58rem;
  font-weight: 800;
  color: #fff;
  background: var(--rust);
  font-family: "Hiragino Sans", sans-serif;
}

.ev-decor-wrap {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ev-decor {
  width: 28px;
  height: 28px;
}

.suspect-grid {
  display: grid;
  gap: 0.38rem;
  margin-top: 0.45rem;
}

.suspect-btn {
  width: 100%;
  min-height: 44px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.35rem 0.4rem;
  background: linear-gradient(180deg, #fffdf6, #f0e8d8);
  color: var(--ink);
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.35rem;
  align-items: center;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.suspect-btn:hover {
  box-shadow: 0 2px 0 rgba(42, 36, 28, 0.15);
}

.suspect-btn:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

.suspect-btn.is-wrong {
  border-color: var(--rust);
}

.suspect-btn.is-right {
  border-color: var(--good);
  box-shadow: 0 0 0 2px rgba(58, 122, 82, 0.35);
}

.portrait-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-svg {
  width: 48px;
  height: 48px;
}

.suspect-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 0.12rem;
  font-family: "Hiragino Sans", sans-serif;
}

.attr-row {
  display: grid;
  grid-template-columns: 3.2em 1fr;
  gap: 0.2rem;
  align-items: center;
  font-size: 0.62rem;
  font-family: "Hiragino Sans", sans-serif;
  margin-bottom: 0.08rem;
}

.attr-label {
  color: #6a5a48;
  font-weight: 700;
}

.attr-body {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.attr-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--forest);
}

.stamp {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.12rem 0.35rem;
  border: 2px solid;
  border-radius: 4px;
  transform: rotate(-8deg);
  font-family: "Hiragino Sans", sans-serif;
}

.match-stamp {
  color: var(--good);
  border-color: var(--good);
  background: rgba(255, 252, 245, 0.9);
}

.retry-stamp {
  color: var(--rust);
  border-color: var(--rust);
  background: rgba(255, 252, 245, 0.9);
}

.partner {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
  position: relative;
}

.partner .burapi {
  width: 48px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.partner .magnifier {
  position: absolute;
  right: 38px;
  bottom: 2px;
  width: 20px;
  height: 20px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 252, 245, 0.4);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.partner figcaption {
  font-size: 0.68rem;
  color: rgba(244, 238, 223, 0.8);
  font-family: "Hiragino Sans", sans-serif;
}

.live-msg {
  min-height: 1.1em;
  margin: 0;
  text-align: center;
  font-size: 0.76rem;
  color: rgba(244, 238, 223, 0.9);
  font-family: "Hiragino Sans", sans-serif;
}

.result-panel {
  text-align: center;
  padding: 0.85rem 0.6rem 1rem;
  border-radius: 8px;
  border: 3px double var(--wood);
  background: var(--paper);
  position: relative;
}

.result-panel[hidden] {
  display: none !important;
}

.closed-stamp {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--rust);
  border: 3px solid var(--rust);
  display: inline-block;
  padding: 0.2rem 0.55rem;
  transform: rotate(-4deg);
  font-family: ui-monospace, Menlo, monospace;
}

.result-rank {
  margin: 0.25rem 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--forest);
}

.result-files {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0;
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

.result-files li {
  font-size: 0.62rem;
  padding: 0.25rem 0.35rem;
  border: 2px solid var(--edge);
  border-radius: 4px;
  background: #e8e0d0;
  color: #8a8070;
  font-family: ui-monospace, Menlo, monospace;
}

.result-files li.is-solved {
  border-color: var(--good);
  background: #e8f4ec;
  color: var(--forest);
}

.result-stats {
  margin: 0.5rem auto;
  max-width: 280px;
  display: grid;
  gap: 0.25rem;
  text-align: left;
  font-family: "Hiragino Sans", sans-serif;
  font-size: 0.82rem;
}

.result-stats div {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 0.35rem;
}

.result-stats dt {
  font-weight: 700;
  color: #6a5a48;
}

.result-stats dd {
  margin: 0;
  font-weight: 800;
}

.result-detail {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.85rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.btn-primary,
.btn-share {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-weight: 800;
  border: 2px solid var(--ink);
  font-family: "Hiragino Sans", sans-serif;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(180deg, #e8c888, var(--brass));
}

.btn-share {
  background: var(--paper);
}

.result-partner {
  margin-top: 0.5rem;
  justify-content: center;
}

.is-page-turn .desk-stage {
  animation: page-turn 0.45s ease;
}

.is-page-in {
  animation: page-in 0.45s ease;
}

@keyframes page-turn {
  0% {
    transform: perspective(800px) rotateY(0);
    opacity: 1;
  }
  50% {
    transform: perspective(800px) rotateY(-12deg);
    opacity: 0.6;
  }
  100% {
    transform: perspective(800px) rotateY(0);
    opacity: 1;
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.is-foot-trail::after {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 20%;
  width: 60%;
  height: 4px;
  background: repeating-linear-gradient(90deg, #6a5040 0 8px, transparent 8px 14px);
  opacity: 0.5;
  animation: trail 0.5s ease;
}

@keyframes trail {
  from {
    opacity: 0;
    transform: scaleX(0.3);
  }
  to {
    opacity: 0.5;
    transform: scaleX(1);
  }
}

html[data-capture="1"] .capture-hide,
html[data-promo-shot="1"] .promo-hide {
  display: none !important;
}

html[data-capture="1"] .case-board {
  padding-top: max(env(safe-area-inset-top), 6px);
  gap: 0.35rem;
}

html[data-capture="1"] .hero h1 {
  font-size: 1.05rem;
}

html[data-capture="1"] .hero h1 span {
  font-size: 0.88rem;
}

html[data-capture="1"] .catch {
  display: none;
}

html[data-capture="1"] .suspect-btn {
  padding: 0.3rem 0.35rem;
}

html[data-capture="1"] .portrait-svg {
  width: 42px;
  height: 42px;
}

html[data-promo-shot="1"] body {
  margin: 0;
  width: 390px;
  height: 844px;
  min-height: 844px;
  max-height: 844px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 10px 14px;
}

html[data-promo-shot="1"] .case-board {
  max-width: 100%;
  width: 100%;
  padding: 0;
  gap: 0.32rem;
  flex: 0 0 auto;
  margin: auto 0;
}

html[data-promo-shot="1"] .hero h1 {
  font-size: 1.08rem;
}

html[data-promo-shot="1"] .desk-stage {
  padding: 0.45rem 0.42rem 0.5rem;
}

html[data-promo-shot="1"] .suspect-grid {
  gap: 0.3rem;
}

@media (prefers-reduced-motion: reduce) {
  .evidence-card.is-new,
  .evidence-card.is-bonus,
  .is-page-turn .desk-stage,
  .is-page-in,
  .is-foot-trail::after,
  .penalty-float {
    animation: none !important;
    transition: none !important;
  }

  .match-wires {
    display: none;
  }
}
