:root {
  color-scheme: dark;
  --ink: #211a1c;
  --paper: #f0d7a4;
  --paper-deep: #d5ae72;
  --paper-light: #fae8be;
  --wood: #56351f;
  --wood-dark: #2d1b17;
  --night: #10142e;
  --night-soft: #262653;
  --plum: #4d315b;
  --berry: #a8454e;
  --leaf: #7b9b62;
  --gold: #dba74b;
  --fog: rgba(216, 221, 228, 0.16);
  --shadow: rgba(15, 10, 18, 0.42);
  --serif: "Libre Baskerville", Georgia, serif;
  --display: "Rye", Georgia, serif;
  --hand: "Caveat", "Comic Sans MS", cursive;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--paper-light);
  background: var(--night);
  font-family: var(--serif);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus {
  outline: none;
}

.loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  font-family: var(--hand);
  font-size: 2rem;
}

.scene {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(11, 15, 39, 0.26), rgba(12, 16, 37, 0.48)),
    url("./assets/backyard-court.webp") center / cover no-repeat,
    var(--night);
}

.scene::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 50% 42%, transparent 14%, rgba(10, 11, 28, 0.14) 60%, rgba(7, 9, 24, 0.48) 100%),
    linear-gradient(180deg, transparent 58%, rgba(13, 16, 31, 0.26));
  pointer-events: none;
}

.paper {
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 246, 213, 0.48), rgba(255, 246, 213, 0.12)),
    var(--paper);
  border: 1px solid rgba(86, 53, 31, 0.58);
  box-shadow: 0 20px 50px var(--shadow);
}

.title-sign,
.briefing-file {
  width: min(760px, 100%);
  padding: clamp(24px, 5vw, 54px);
  text-align: center;
  rotate: -1deg;
}

.title-sign::before {
  display: block;
  width: 124px;
  height: 24px;
  margin: -64px auto 30px;
  content: "";
  background: rgba(231, 207, 148, 0.72);
  box-shadow: 0 2px 4px rgba(52, 31, 19, 0.26);
  rotate: 2deg;
}

h1 {
  margin: 10px 0 14px;
  color: #3c2630;
  font-family: var(--display);
  font-size: clamp(2.7rem, 10vw, 6rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
}

.briefing-file h1 {
  font-size: clamp(2rem, 7vw, 4rem);
}

.kicker,
.stamp {
  margin: 0;
  color: #70414b;
  font-family: var(--hand);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.stamp {
  display: inline-block;
  padding: 2px 8px;
  color: #8b333b;
  border: 2px solid #8b333b;
  rotate: -5deg;
}

.subtitle,
.objective,
.briefing-copy {
  line-height: 1.7;
}

.paper-button {
  min-height: 44px;
  margin-top: 12px;
  padding: 12px 22px;
  color: var(--paper-light);
  cursor: pointer;
  background: #6d3b3f;
  border: 2px solid #4d272c;
  box-shadow: 3px 4px 0 #3c2722;
  font-family: var(--hand);
  font-size: 1.45rem;
  font-weight: 700;
}

.paper-button:hover {
  background: #87494e;
}

.fireflies i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #eed470;
  border-radius: 50%;
  box-shadow: 0 0 14px #eed470;
  animation: drift 4s ease-in-out infinite alternate;
}

.fireflies i:nth-child(1) { top: 24%; left: 16%; }
.fireflies i:nth-child(2) { top: 34%; left: 25%; animation-delay: -2s; }
.fireflies i:nth-child(3) { top: 18%; right: 22%; animation-delay: -1s; }
.fireflies i:nth-child(4) { bottom: 24%; left: 13%; animation-delay: -3s; }
.fireflies i:nth-child(5) { bottom: 19%; right: 30%; animation-delay: -1.5s; }

.owl-note {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 26px 0 18px;
  padding: 14px;
  text-align: left;
  background: rgba(255, 246, 213, 0.34);
  border-left: 5px solid var(--berry);
}

.owl-note p {
  margin: 5px 0 0;
  font-family: var(--hand);
  font-size: 1.45rem;
}

.owl-note__portrait {
  width: 82px;
  height: 82px;
  flex: 0 0 auto;
  object-fit: cover;
  object-position: center 28%;
  border: 2px solid rgba(86, 53, 31, 0.58);
  border-radius: 50%;
}

@keyframes drift {
  to { translate: 16px -10px; }
}

.scene--desk {
  align-content: start;
  overflow-x: clip;
  overflow-y: visible;
  padding: 22px clamp(12px, 3vw, 40px) 42px;
}

.desk-heading {
  z-index: 1;
  width: min(840px, 100%);
  padding: 14px 20px;
  text-align: center;
  rotate: -0.5deg;
}

.desk-heading h1 {
  margin: 5px;
  font-size: clamp(1.8rem, 5vw, 3.4rem);
}

.court-desk {
  position: relative;
  width: min(1120px, 100%);
  min-height: 520px;
  margin-top: 20px;
  padding: 22px;
  background:
    repeating-linear-gradient(92deg, transparent 0 38px, rgba(34, 19, 16, 0.16) 39px 41px),
    linear-gradient(#69472e, #4e3022);
  border: 8px solid #38231b;
  box-shadow: 0 24px 45px var(--shadow);
}

.desk-panel {
  position: relative;
}

.desk-panel[aria-label="Clue files"] {
  padding-top: 42px;
}

.clue-moon {
  position: absolute;
  top: -8px;
  left: 16px;
  color: var(--gold);
  font-size: 3.25rem;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 22px rgba(219, 167, 75, 0.5);
}

.desk-tabs {
  display: flex;
  gap: 8px;
  align-items: end;
  margin: -54px 0 20px 18px;
}

.desk-tab {
  min-height: 48px;
  padding: 10px 16px;
  color: #39241e;
  cursor: pointer;
  background: #d2ad74;
  border: 1px solid #795636;
  box-shadow: 2px 3px 0 rgba(47, 27, 22, 0.45);
  font-family: var(--hand);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  rotate: -1deg;
}

.desk-tab:nth-child(2) { rotate: 1deg; }
.desk-tab:nth-child(3) { rotate: -0.5deg; }
.desk-tab.is-active { background: var(--paper-light); }
.desk-tab.is-locked { background: #bc9465; text-decoration: line-through; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 16px;
}

.file-card {
  position: relative;
  min-height: 164px;
  padding: 18px 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  border: 1px solid #8a603d;
  transition: translate 160ms ease, rotate 160ms ease;
}

.file-card:nth-child(odd) { rotate: -0.6deg; }
.file-card:nth-child(even) { rotate: 0.7deg; }
.file-card:hover { translate: 0 -5px; }

.file-card strong,
.file-card span,
.file-card small {
  display: block;
}

.file-card small {
  margin-top: 14px;
  color: #70414b;
  font-family: var(--hand);
  font-size: 1.18rem;
}

.file-card__icon,
.suspect-card__portrait-fallback {
  margin-bottom: 12px;
  color: var(--berry);
  font-size: 2.4rem;
}

.suspect-card__portrait,
.suspect-select__portrait,
.filing-portrait-card__portrait {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: center 30%;
  padding: 3px;
  background: var(--paper-deep);
  border: 2px solid #713845;
  border-radius: 9px 3px 9px 3px;
  box-shadow:
    inset 0 0 0 1px rgba(250, 232, 190, 0.72),
    0 2px 4px rgba(45, 27, 23, 0.28);
}

.suspect-card__portrait {
  margin-bottom: 12px;
}

.suspect-card__portrait-fallback[hidden],
.suspect-select__portrait-fallback[hidden] {
  display: none;
}

.file-card.is-reviewed::after {
  position: absolute;
  right: 8px;
  bottom: 9px;
  padding: 2px 6px;
  color: #8b333b;
  content: "REVIEWED";
  border: 2px solid #8b333b;
  font-family: var(--hand);
  font-size: 1rem;
  font-weight: 700;
  rotate: -8deg;
}

.checklist {
  width: min(1120px, 100%);
  margin-top: 16px;
  padding: 12px 18px;
  rotate: 0.3deg;
}

.checklist h2,
.detail-modal h2,
.accusation-panel h2 {
  margin: 0 0 8px;
  font-family: var(--hand);
  font-size: 2rem;
}

.checklist p {
  display: inline-block;
  margin: 4px 26px 4px 0;
  font-family: var(--hand);
  font-size: 1.4rem;
}

.checklist__mark {
  display: inline-block;
  width: 1em;
  color: #8b333b;
  font-size: 1.15em;
  font-weight: 700;
  rotate: -7deg;
}

.court-notice {
  width: min(840px, 100%);
  min-height: 48px;
  margin-top: 15px;
  padding: 13px 18px;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.35rem;
}

.filing-help {
  width: min(1120px, 100%);
  margin-top: 12px;
  padding: 10px 14px;
  color: var(--ink);
  border-left: 5px solid var(--berry);
  font-family: var(--hand);
  font-size: 1.25rem;
}

.campaign-strip {
  display: flex;
  z-index: 2;
  gap: 12px;
  align-items: center;
  width: min(840px, 100%);
  margin-bottom: 14px;
  padding: 9px 14px;
  rotate: 0.4deg;
}

.campaign-strip__portrait {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 1px solid rgba(86, 53, 31, 0.58);
}

.campaign-strip strong,
.campaign-strip span {
  display: block;
}

.campaign-strip__case {
  margin-left: auto;
  font-family: var(--hand);
  font-size: 1.35rem;
  font-weight: 700;
}

.new-question {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 3px 7px;
  color: #8b333b;
  background: #f6dea5;
  border: 2px solid #8b333b;
  font-family: var(--hand);
  font-size: 1.05rem;
  rotate: 5deg;
}

.transcript {
  margin: 16px 0;
  padding: 4px 14px;
  background: rgba(255, 246, 213, 0.38);
  border-left: 4px solid var(--berry);
}

.question-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 10px 0;
  padding: 10px 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  background: #e6c487;
  border: 2px dashed #8a603d;
  font-family: var(--hand);
  font-size: 1.3rem;
  font-weight: 700;
}

.candidate-file {
  width: min(980px, 100%);
  padding: clamp(20px, 4vw, 42px);
  rotate: -0.5deg;
}

.candidate-file h1 {
  font-size: clamp(2rem, 6vw, 4rem);
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
}

.candidate-option {
  min-height: 172px;
  padding: 9px;
  color: var(--ink);
  cursor: pointer;
  background: rgba(255, 246, 213, 0.55);
  border: 2px dashed #8a603d;
  font-family: var(--hand);
  font-size: 1.25rem;
}

.candidate-option.is-selected {
  background: #e3bd7d;
  border-color: var(--berry);
  box-shadow: 0 0 0 3px rgba(168, 69, 78, 0.24);
}

.candidate-option__portrait,
.candidate-confirmed__portrait {
  display: block;
  width: 100%;
  height: 130px;
  margin-bottom: 7px;
  object-fit: cover;
  border: 1px solid rgba(86, 53, 31, 0.58);
}

.candidate-confirmed__portrait {
  width: min(240px, 100%);
  height: auto;
  margin: 20px auto;
}

.candidate-name {
  display: block;
  margin-top: 18px;
  font-family: var(--hand);
  font-size: 1.45rem;
  font-weight: 700;
}

.candidate-name input {
  display: block;
  width: min(420px, 100%);
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--paper-light);
  border: 2px solid #8a603d;
  font: inherit;
}

.approval-result {
  display: inline-block;
  padding: 5px 9px;
  color: #8b333b;
  border: 2px solid #8b333b;
  font-family: var(--hand);
  font-size: 1.5rem;
  font-weight: 700;
  rotate: -3deg;
}

.accusation-panel,
.verdict-file {
  color: var(--ink);
}

.accusation-panel {
  max-width: 760px;
  margin: 18px auto;
  padding: clamp(18px, 4vw, 34px);
  rotate: -0.8deg;
}

.accusation-panel h2 {
  margin: 4px 0;
  font-size: clamp(2rem, 5vw, 3rem);
}

.accusation-panel p,
.verdict-file > p {
  line-height: 1.7;
}

.accusation-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.suspect-select {
  min-height: 172px;
  padding: 10px;
  color: var(--ink);
  cursor: pointer;
  background: rgba(255, 246, 213, 0.55);
  border: 2px dashed #8a603d;
  font-family: var(--hand);
  font-size: 1.5rem;
}

.suspect-select__portrait,
.suspect-select__portrait-fallback,
.suspect-select strong {
  display: block;
}

.suspect-select__portrait {
  margin-bottom: 8px;
}

.suspect-select__portrait-fallback {
  margin-bottom: 8px;
  font-size: 2.3rem;
}

.suspect-select.is-selected {
  background: #e3bd7d;
  border-color: var(--berry);
  box-shadow: 0 0 0 3px rgba(168, 69, 78, 0.24);
}

.paper-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.paper-button:disabled:hover {
  background: #6d3b3f;
}

.verdict-file {
  width: min(760px, 100%);
  padding: clamp(24px, 5vw, 48px);
  rotate: 0.7deg;
}

.verdict-file h1 {
  font-size: clamp(2.1rem, 7vw, 4.4rem);
}

.completion-card {
  margin-top: 22px;
  padding: 14px 18px;
  background: rgba(255, 246, 213, 0.45);
  border: 2px dashed #8a603d;
}

.completion-card p {
  margin-bottom: 0;
  line-height: 1.6;
}

.modal-backdrop {
  position: fixed;
  z-index: 4;
  display: grid;
  inset: 0;
  place-items: center;
  padding: 20px;
  background: rgba(15, 10, 18, 0.62);
}

.detail-modal {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: clamp(20px, 5vw, 38px);
  color: var(--ink);
  rotate: -0.8deg;
}

.detail-modal p {
  line-height: 1.7;
}

.filing-portrait-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 16px;
  margin: 20px 0;
}

.filing-portrait-grid.is-single {
  grid-template-columns: minmax(0, 280px);
  justify-content: center;
}

.filing-portrait-card {
  margin: 0;
  text-align: center;
}

.filing-portrait-card figcaption {
  margin-top: 8px;
  font-family: var(--hand);
  font-size: 1.35rem;
  font-weight: 700;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hand-note {
  padding: 10px;
  background: rgba(255, 246, 213, 0.38);
  border-left: 4px solid var(--berry);
  font-family: var(--hand);
  font-size: 1.45rem;
}

@media (max-width: 640px) {
  .owl-note {
    align-items: flex-start;
  }

  .owl-note__portrait {
    width: 66px;
    height: 66px;
  }

  .desk-tabs {
    flex-wrap: wrap;
    margin-top: -44px;
    margin-left: 0;
  }

  .desk-tab {
    flex: 1 1 140px;
  }

  .court-desk {
    padding: 14px;
    border-width: 6px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .accusation-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clue-moon {
    top: -5px;
    right: 2px;
    left: auto;
    font-size: 3rem;
  }

  .campaign-strip {
    align-items: flex-start;
  }

  .campaign-strip__case {
    font-size: 1.12rem;
    text-align: right;
  }

  .candidate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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