:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #111014;
  color: #eee9df;
}
[hidden] { display: none !important; }
body { margin: 0; }
main {
  box-sizing: border-box;
  width: min(100%, 90rem);
  height: 100vh;
  height: 100dvh;
  margin: auto;
  padding: clamp(.45rem, 1.2vw, 1rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
main > header { grid-row: 1; }
#title, #game { grid-row: 2; min-height: 0; }
#notice { grid-row: 3; }
header, nav { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
header { justify-content: space-between; margin-bottom: .8rem; }
.game-name { font-size: clamp(1rem, 3vw, 1.6rem); letter-spacing: .09em; margin: .5rem 0; }
button {
  font: inherit; color: inherit; cursor: pointer; border: 1px solid #6a6060;
  background: #252128; padding: .55rem .8rem; border-radius: .4rem;
}
button:hover, button:focus-visible, button[aria-pressed="true"] { border-color: #f0be86; }
button:focus-visible { outline: 2px solid #f0be86; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
#title {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  aspect-ratio: 1672 / 941;
  width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  align-self: center;
  overflow: hidden;
  background: #111320;
  border: 1px solid #2d2933;
}
.cover-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
  z-index: -2;
}
#title::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #0e101bee, #0e101b88 25%, transparent 52%);
  z-index: -1;
}
.cover-menu {
  width: 38%;
  padding-inline-start: 5%;
  box-sizing: border-box;
}
#cover-title {
  margin: 0 0 .55em;
  color: #e65450;
  font: bold clamp(1.45rem, 5.5vw, 4.6rem)/1.1 "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", serif;
  letter-spacing: .025em;
  word-break: keep-all;
  text-shadow: 0 2px 12px #07050b;
}
.cover-actions { display: flex; align-items: start; flex-direction: column; gap: .45rem; }
.cover-actions button {
  min-height: 44px;
  border: 1px solid #ad555b;
  border-radius: 0;
  padding: .5rem clamp(.6rem, 1.7vw, 1.3rem);
  background: #261821e8;
  color: #f9e4dc;
  letter-spacing: .08em;
}
.cover-actions button:hover, .cover-actions button:focus-visible { background: #56252e; }
@media (max-width: 34rem) {
  .cover-menu { width: 43%; padding-inline-start: 4%; }
  #cover-title { font-size: clamp(1.125rem, 4.7vw, 1.65rem); }
  .cover-actions button { font-size: .8rem; }
}
#game {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
  min-width: 0;
}
.scene-frame {
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  background: #14131a;
}
.scene-frame:has(.speaking) { align-items: end; }
@media (max-width: 40rem) and (orientation: portrait) {
  #game:has(.speaking) { align-self: center; grid-template-rows: auto auto auto auto auto; }
  .scene-frame:has(.speaking) { aspect-ratio: 1672 / 941; }
}
#stage {
  width: min(100cqw, calc(100cqh * 1672 / 941));
  max-width: 100%;
  position: relative; isolation: isolate; overflow: hidden;
  aspect-ratio: 1672 / 941; background: #18171c; touch-action: none;
}
#scene { width: 100%; height: 100%; display: block; }
.speaking #scene { filter: blur(5px) brightness(.68); }
.memory #scene { filter: grayscale(1) sepia(.7) blur(3px) brightness(.85); }
.memory #portrait { --portrait-brightness: .82; }
.backstage-memory:not(.speaking) #scene { filter: grayscale(1) sepia(.7) brightness(.85); }
#jammer-light {
  position: absolute; left: 80.5%; top: 54.7%;
  width: clamp(3px, .55%, 8px); aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: #ff6649; box-shadow: 0 0 .4rem #ff553f;
  pointer-events: none;
}
#jammer-light.off { width: 1.6%; background: #15181c; box-shadow: none; }
#lens {
  position: absolute; width: clamp(66px, 14vw, 156px); aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 2px #e9d8a9, 0 3px 15px #000b; background-repeat: no-repeat;
}
.hotspot {
  position: absolute; background: transparent; border: 1px solid transparent;
  color: transparent; padding: 0; font-size: .8rem;
}
.hotspot:focus:not(:focus-visible) { outline: none; }
.hotspot:focus-visible { color: white; background: #18151a66; }
.visible-hotspot { color: white; background: #18151abf; border-color: #807079; }
#scene-description {
  margin: 0;
  padding: .65rem .75rem;
  background: #1d1920;
  line-height: 1.5;
}
#dialogue {
  width: 100%; display: flex; align-items: center;
  min-height: 5rem; text-align: left; background: #1d1920;
}
#portrait {
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: block;
  width: auto;
  height: 94%;
  max-width: 85%;
  object-fit: contain;
  object-position: center bottom;
  filter: brightness(var(--portrait-brightness, 1)) drop-shadow(0 .25rem .65rem #08060ab0);
  pointer-events: none;
}
#speaker, #line { display: block; }
#speaker { color: #f0be86; }
.plot-controls { justify-content: space-between; margin-top: .5rem; }
#actions { margin-top: .5rem; }
#actions:empty, #notice:empty { display: none; }
#notice { margin: .35rem 0 0; color: #f0be86; }
.plot-controls button { min-height: 44px; }
@media (max-height: 520px) {
  header { margin-bottom: .35rem; }
  #dialogue { min-height: 3rem; padding-block: .3rem; }
}
dialog { width: min(36rem, 83vw); max-height: 80vh; background: #201b22; color: inherit; border: 1px solid #6a6060; border-radius: .5rem; }
dialog::backdrop { background: #0a090cbf; }
dialog form { float: right; }
dialog img { display: block; width: 100%; }
dialog img.phone-clue { max-height: min(58dvh, 29rem); object-fit: contain; }
.purse-actions { margin-top: .6rem; }
.purse-contents { position: relative; }
.clue-closeup { position: relative; overflow: hidden; }
.clue-closeup img { position: absolute; }
dialog li { padding: .25rem 0; }

.cast-panel {
  box-sizing: border-box;
  width: min(68rem, 94vw);
  max-width: none;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  gap: .7rem;
  margin-block: .7rem 1rem;
}
.cast-grid article {
  padding: .65rem;
  background: #302630;
  border: 1px solid #574752;
  border-radius: .4rem;
}
.cast-grid img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  object-position: center;
}
.cast-grid h3 { margin: .5rem 0 .25rem; color: #f0be86; }
.cast-grid p { margin: .3rem 0; line-height: 1.45; }

.suspect-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  flex: 1;
  min-height: 0;
  gap: .5rem;
}
.suspect-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: .3rem;
  background: #302630;
  border: 1px solid #574752;
}
.suspect-card img {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 0;
  object-fit: cover;
  object-position: center top;
}
.suspect-card span { display: block; margin-top: .4rem; }
.suspect-card:hover, .suspect-card:focus-visible { border-color: #f0be86; }
.solve-panel {
  width: min(36rem, 94vw);
  height: min(40rem, calc(100dvh - 2rem));
  padding: .75rem;
  overflow: hidden;
}
.solve-panel[open] {
  display: flex;
  flex-direction: column;
}
.solve-panel form { position: absolute; top: .75rem; right: .75rem; }
.solve-panel h2 { margin: .25rem 4rem .7rem 0; flex-shrink: 0; }
.solve-panel #panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.solve-panel #panel-body > p { margin: 0 0 .6rem; }
.solve-warning {
  flex: 1;
  display: grid;
  place-items: center;
  color: #ff4444;
  font-size: clamp(2rem, 7vw, 5rem);
  font-weight: 800;
  text-align: center;
}
@media (max-height: 480px) and (orientation: landscape) {
  .solve-panel { width: min(44rem, 94vw); }
  .suspect-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
}

.character-profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  align-items: start;
  gap: .8rem;
  margin-block: .7rem 1rem;
  line-height: 1.45;
}
.character-profile img { border-radius: .4rem; background: #302630; }
.character-profile p { margin: 0 0 .35rem; }
.character-profile h3 { margin: .8rem 0 .25rem; color: #f0be86; }
.character-profile ul { margin: 0; padding-inline-start: 1.25rem; }

/* The ending appears only after the player has read Miko's final silence. */
#ending { position: absolute; inset: 0; display: grid; place-items: center; background: #111014;
  font-size: clamp(1.5rem, 5vw, 3rem); letter-spacing: .3em; z-index: 5; animation: ending-fade 1.2s ease both; }
@keyframes ending-fade { from { opacity: 0; } to { opacity: 1; } }
.memory:not(.speaking) #scene { filter: grayscale(1) sepia(.7) brightness(.85); }
@media (prefers-reduced-motion: reduce) { #ending { animation: none; } }

#invite-form { display: flex; flex-direction: column; align-items: stretch; gap: .65rem; max-width: 20rem; }
#invite-form label { color: #f9e4dc; }
#invite-code { box-sizing: border-box; width: 100%; min-height: 44px; border: 1px solid #ad555b;
  border-radius: .25rem; padding: .55rem .65rem; background: #16121be8; color: #fff; font: inherit; }
#invite-code:focus-visible { outline: 2px solid #f0be86; outline-offset: 2px; }
#invite-code[aria-invalid="true"] { border-color: #ff8383; }
#invite-error { color: #ffaaaa; margin: 0; font-size: .85rem; }
@media (max-width: 34rem) { #invite-form { gap: .4rem; font-size: .8rem; } }
