*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ak-font-body);
  font-size: 16px;
  line-height: 1.2;
  color: var(--ak-ink);
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

button,
img {
  touch-action: manipulation;
}

button {
  font-family: inherit;
  margin: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

[hidden] {
  display: none !important;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.play {
  --pad-top: max(6px, env(safe-area-inset-top, 0px));
  --pad-bot: max(8px, env(safe-area-inset-bottom, 0px));
  --pad-x: max(8px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 390px);
  height: min(100dvh, 844px);
  max-height: 100dvh;
  padding: var(--pad-top) var(--pad-x) var(--pad-bot);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background-color: var(--ak-bg);
  color: var(--ak-ink);
}

.play.has-backdrop {
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.mute {
  position: absolute;
  z-index: 6;
  top: var(--pad-top);
  right: var(--pad-x);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: var(--ak-shadow);
}

.mute-icon {
  width: 26px;
  height: 26px;
}

.slash {
  opacity: 0;
}

.mute.is-muted .wave {
  opacity: 0;
}

.mute.is-muted .slash {
  opacity: 1;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 40px;
  padding-right: 52px;
}

.play-logo {
  height: min(36px, 6dvh);
  width: auto;
  max-width: 48%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px var(--ak-glow));
}

.turn {
  margin-left: auto;
  min-width: 0;
  text-align: right;
}

.turn-who,
.turn-sub {
  margin: 0;
  color: var(--ak-ink);
}

.turn-who {
  font-family: var(--ak-font-display);
  font-size: 14px;
  font-weight: var(--ak-title-weight);
  line-height: 1.1;
}

.turn-sub {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.1;
}

.goal {
  flex: 0 0 auto;
  margin: 0;
  color: var(--ak-ink);
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
}

.voice,
.why {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  color: var(--ak-ink);
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
}

.voice {
  min-height: 2.6em;
}

.hint,
.btn {
  min-height: 48px;
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: clamp(13px, 3.6vw, 16px);
  font-weight: var(--ak-title-weight);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.hint,
.btn-alt {
  background: var(--ak-surface);
  color: var(--ak-ink);
}

.btn-go {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-go:active:not(:disabled) {
  background: var(--ak-btn-active);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
  overflow: hidden;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow), inset 0 0 0 1px color-mix(in srgb, var(--ak-accent-2) 45%, transparent);
}

.stage::before {
  content: '';
  position: absolute;
  z-index: 2;
  left: 10px;
  right: 10px;
  top: 0;
  height: 3px;
  background: var(--ak-accent);
  box-shadow: 0 0 8px var(--ak-glow);
  pointer-events: none;
}

.case-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.clue-label {
  flex: 0 0 auto;
  margin: 2px 0 0;
  color: var(--ak-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

.clues {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: grid;
  gap: 4px;
}

.chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  max-height: 84px;
  padding: 8px 6px;
  overflow: hidden;
  background: var(--ak-bg);
}

.chip-art {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 290%;
  max-width: none;
  height: auto;
  transform: translate(-29%, -84%);
  pointer-events: none;
}

.chip-text {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 94%;
  padding: 3px 4px;
  background: var(--ak-ink);
  color: var(--ak-bg);
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
}

.chip.is-lit {
  filter: drop-shadow(0 0 6px var(--ak-accent-2));
}

.chip.is-lit .chip-text {
  outline: 2px solid var(--ak-accent-2);
}

.people {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.person {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.person:disabled {
  opacity: 1;
  cursor: default;
}

.screen {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ak-accent-2);
  border-radius: var(--ak-radius);
  background: var(--ak-bg);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ak-accent-2) 45%, transparent);
}

.face-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 36px;
  overflow: hidden;
  background: var(--ak-bg);
}

.face-wrap::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(
    115deg,
    color-mix(in srgb, var(--ak-ink) 22%, transparent) 0 10%,
    transparent 18% 100%
  );
  pointer-events: none;
}

.face-wrap::after {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    color-mix(in srgb, var(--ak-accent) 30%, transparent) 2px 3px
  );
  pointer-events: none;
}

.face {
  position: absolute;
  top: 0;
  left: 0;
  width: 300%;
  height: 161%;
  max-width: none;
  object-fit: fill;
}

.face-ben {
  left: -100%;
}

.face-chloe {
  left: -200%;
}

.name,
.line {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  padding: 0 3px;
  color: var(--ak-ink);
  text-align: center;
}

.name {
  padding-top: 3px;
  font-family: var(--ak-font-display);
  font-size: 12px;
  font-weight: var(--ak-title-weight);
  line-height: 1.1;
}

.line {
  min-height: 2.4em;
  padding-bottom: 4px;
  font-size: 12px;
  line-height: 1.15;
}

.mark {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 46%;
  width: 62%;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 0 6px var(--ak-btn-fill));
}

.press {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  height: 52px;
  min-height: 48px;
}

.press img {
  width: auto;
  height: 52px;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
}

.person.is-chosen .screen {
  outline: 3px solid var(--ak-accent-2);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--ak-accent-2), 0 0 18px var(--ak-accent-2);
}

.person.is-chosen .press img {
  filter: drop-shadow(0 0 8px var(--ak-accent-2));
}

.person.is-fault .screen {
  box-shadow: 0 0 0 3px var(--ak-btn-fill), 0 0 10px var(--ak-btn-fill);
}

.person.is-stamped .screen {
  box-shadow: 0 0 0 3px var(--ak-accent), 0 0 16px var(--ak-glow);
}

.people.is-point .screen {
  box-shadow: 0 0 0 2px var(--ak-accent-2), 0 0 12px var(--ak-glow);
}

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

.wire path {
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 4px var(--ak-glow));
}

.actions {
  flex: 0 0 auto;
  min-height: 48px;
}

.play.is-ended .actions {
  display: none;
}

.recap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recap-row {
  display: grid;
  flex: 1 1 0;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 4px 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.recap-row.is-caught {
  border-color: var(--ak-accent);
  box-shadow: 0 0 10px var(--ak-glow);
}

.recap-row.is-missed {
  border-color: var(--ak-btn-fill);
}

.mini {
  position: relative;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 2px solid var(--ak-outline);
  background: var(--ak-bg);
}

.mini .face {
  top: -42%;
  height: 230%;
}

.recap-name {
  min-width: 0;
  color: var(--ak-ink);
  font-size: 16px;
  line-height: 1.1;
}

.recap-tag {
  font-family: var(--ak-font-display);
  font-size: 12px;
  line-height: 1.1;
}

.is-caught .recap-tag {
  color: var(--ak-accent);
}

.is-missed .recap-tag {
  color: var(--ak-btn-fill);
}

.result {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
}

.result-card {
  padding: 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.play.is-win .result-card {
  border-color: var(--ak-accent);
  box-shadow: var(--ak-shadow), 0 0 16px var(--ak-glow);
}

.result-says {
  margin: 0 0 8px;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 13px;
  font-weight: var(--ak-title-weight);
  line-height: 1.35;
  text-align: center;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.person:focus-visible,
.hint:focus-visible,
.btn:focus-visible,
.mute:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.fx {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx i {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  opacity: 0;
}

@media (min-width: 480px) {
  .play {
    border: 2px solid var(--ak-outline);
    border-radius: var(--ak-radius);
    box-shadow: var(--ak-shadow), 0 0 24px color-mix(in srgb, var(--ak-accent-2) 28%, transparent);
  }
}

@media (max-height: 700px) {
  .play {
    gap: 4px;
  }

  .play-logo {
    height: 28px;
  }

  .goal,
  .voice,
  .why {
    font-size: 12px;
  }

  .voice,
  .why {
    padding: 4px 6px;
  }

  .stage {
    padding: 6px;
  }

  .press,
  .press img {
    height: 48px;
  }

  .line {
    font-size: 11px;
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn-go:hover:not(:disabled) {
    background: var(--ak-btn-hover);
  }

  .hint:hover,
  .btn-alt:hover,
  .mute:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stage::before {
    animation: bar 2.8s ease-in-out infinite;
  }

  .face-wrap::after {
    animation: crawl 1.8s linear infinite;
  }

  .person:not(.is-chosen):not(.is-stamped):not(.is-fault) .screen {
    animation: breathe 3.4s ease-in-out infinite;
  }

  .people.is-invite .person:not(.is-chosen) .press img {
    animation: idle-bob 1.8s ease-in-out infinite;
  }

  .people.is-invite .person:nth-child(2) .press img {
    animation-delay: 0.15s;
  }

  .people.is-invite .person:nth-child(3) .press img {
    animation-delay: 0.3s;
  }

  .voice.is-invite {
    animation: invite 1.6s ease-in-out infinite;
  }

  .screen.is-pop {
    animation: ring-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .press img.is-dip {
    animation: dip 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .person.is-shake {
    animation: shake 420ms ease-in-out;
  }

  .person.is-shake .press img {
    animation: blink 420ms ease-in-out;
  }

  .chip.is-pop {
    animation: chip-pop 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .mark.is-on {
    animation: stamp 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .wire path {
    stroke-dashoffset: 1;
    animation: zip 480ms ease-out forwards;
  }

  .stage.is-wipe::after {
    content: '';
    position: absolute;
    z-index: 4;
    left: 0;
    width: 100%;
    height: 18%;
    background: linear-gradient(to bottom, transparent, var(--ak-accent), transparent);
    animation: scan-wipe 460ms linear;
    pointer-events: none;
  }

  .case-view.is-in {
    animation: slide-in 420ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .turn.is-cue .turn-who {
    animation: pop-turn 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .recap.is-chase .recap-row {
    animation: chase 900ms ease-in-out infinite;
  }

  .recap.is-chase .recap-row:nth-child(2) { animation-delay: 120ms; }
  .recap.is-chase .recap-row:nth-child(3) { animation-delay: 240ms; }
  .recap.is-chase .recap-row:nth-child(4) { animation-delay: 360ms; }
  .recap.is-chase .recap-row:nth-child(5) { animation-delay: 480ms; }

  .person:active:not(:disabled) .press img {
    transform: translateY(4px) scale(0.92, 0.84);
  }

  .btn:active:not(:disabled),
  .hint:active {
    transform: translateY(2px);
  }

  .fx i {
    animation: burst 700ms ease-out forwards;
  }
}

@keyframes bar {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes crawl {
  from { transform: translateY(0); }
  to { transform: translateY(3px); }
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 4px color-mix(in srgb, var(--ak-accent-2) 35%, transparent); }
  50% { box-shadow: 0 0 14px var(--ak-accent-2); }
}

@keyframes idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes invite {
  0%, 100% { box-shadow: var(--ak-shadow); }
  50% { box-shadow: var(--ak-shadow), 0 0 12px var(--ak-glow); }
}

@keyframes ring-in {
  0% { box-shadow: 0 0 0 0 transparent; }
  70% { box-shadow: 0 0 0 5px var(--ak-accent-2), 0 0 18px var(--ak-accent-2); }
  100% { box-shadow: 0 0 0 3px var(--ak-accent-2), 0 0 14px var(--ak-accent-2); }
}

@keyframes dip {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(6px) scale(0.92, 0.8); }
  70% { transform: translateY(-3px) scale(1.06, 1.08); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes blink {
  0%, 100% { filter: none; }
  35%, 55% { filter: brightness(1.75); }
}

@keyframes chip-pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes stamp {
  0% { transform: translate(-50%, -50%) scale(1.45); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes zip {
  to { stroke-dashoffset: 0; }
}

@keyframes scan-wipe {
  from { top: -18%; }
  to { top: 100%; }
}

@keyframes slide-in {
  from { transform: translateY(-10px); opacity: 0.35; }
  to { transform: none; opacity: 1; }
}

@keyframes pop-turn {
  0% { transform: scale(0.86); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes chase {
  0%, 100% { box-shadow: var(--ak-shadow); }
  50% { box-shadow: 0 0 14px var(--ak-glow); }
}

@keyframes burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(0.6); opacity: 0; }
}
