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

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

body {
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 600;
  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 {
  font-family: inherit;
  margin: 0;
  touch-action: manipulation;
}

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));
  --sheet-h: min(49dvh, calc((100vw - 20px) * 384 / 281));
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 420px);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  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);
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.can {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 50%;
  width: min(42%, 180px);
  height: 12px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--ak-accent), var(--ak-btn-fill));
  border: 2px solid var(--ak-outline);
  border-top: 0;
  clip-path: polygon(16% 0, 84% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.mute {
  position: absolute;
  z-index: 5;
  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);
  cursor: pointer;
}

.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: 48px;
  padding-right: 52px;
}

.play-logo {
  height: 40px;
  width: auto;
  max-width: 46%;
  object-fit: contain;
}

.turn {
  margin-left: auto;
  min-width: 0;
  padding: 4px 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.turn-who,
.turn-sub,
.shop,
.kind,
.voice,
.note,
.why,
.result-says {
  margin: 0;
}

.turn-who {
  font-family: var(--ak-font-display);
  font-weight: 900;
  font-size: 22px;
  line-height: 1;
}

.turn-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--ak-ink-muted);
}

.voice,
.note,
.why,
.hint,
.result {
  flex: 0 0 auto;
}

.voice,
.note,
.why {
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  text-align: center;
  font-size: 16px;
  line-height: 1.25;
}

.voice {
  margin-top: 4px;
}

.voice.is-point::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 4px auto 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--ak-accent);
}

.sheet.is-hold {
  opacity: 0;
}

.sheet.is-point::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 6% 4% 8%;
  pointer-events: none;
  border-radius: 40%;
}

.note,
.why {
  margin-top: 4px;
}

.hint {
  min-height: 48px;
  margin-top: 4px;
  padding: 8px 12px;
  border: 2px solid var(--ak-choice-border);
  border-radius: var(--ak-radius);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spot {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 44%;
  width: min(130%, 420px);
  height: 72%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    ellipse at center,
    color-mix(in srgb, var(--ak-surface) 78%, transparent) 0%,
    transparent 68%
  );
  pointer-events: none;
}

.sheet {
  position: relative;
  z-index: 1;
  flex: 0 1 auto;
  height: var(--sheet-h);
  width: calc(var(--sheet-h) * 281 / 384);
  max-width: 100%;
  transform: rotate(-2deg);
  transform-origin: 50% 8%;
  filter: drop-shadow(4px 6px 0 var(--ak-outline));
}

.paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.slip {
  position: absolute;
  z-index: 1;
  left: 8%;
  right: 7%;
  top: 32%;
  bottom: 3%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mast {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 22px;
  margin-bottom: 2px;
}

.shop {
  min-width: 0;
  padding: 1px 4px;
  background: color-mix(in srgb, var(--ak-surface) 92%, transparent);
  font-family: var(--ak-font-display);
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
  color: var(--ak-ink);
}

.kind {
  flex: 0 0 auto;
  padding: 1px 5px;
  border: 2px solid var(--ak-outline);
  background: var(--ak-accent);
  color: var(--ak-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.rows {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.line {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
}

.token {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 8px;
  border: 2px solid transparent;
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 88%, transparent);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.token-num {
  font-family: var(--ak-font-display);
  font-weight: 900;
  font-size: 22px;
}

.token-end {
  margin-left: auto;
}

.token-text {
  position: relative;
  z-index: 2;
}

.times {
  flex: 0 0 auto;
  font-family: var(--ak-font-display);
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  color: var(--ak-ink);
}

.ring {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 190%;
  height: auto;
  max-width: none;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.token.is-miss {
  border-color: var(--ak-accent-2);
}

.ladder {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  height: 52px;
  margin-top: 2px;
}

.bulb {
  height: 52px;
  width: auto;
  aspect-ratio: 229 / 384;
  filter: brightness(0.38) saturate(0.65);
}

.bulb.is-lit {
  filter: brightness(1.18) saturate(1.12) drop-shadow(0 0 6px var(--ak-accent)) drop-shadow(0 0 2px var(--ak-glow));
}

.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);
}

.result-says {
  margin-bottom: 8px;
  font-family: var(--ak-font-display);
  font-weight: 900;
  font-size: 20px;
  line-height: 1.1;
  text-align: center;
}

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

.btn {
  min-height: 48px;
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

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

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

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

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

.fx i,
.fx .puff {
  position: absolute;
  opacity: 0;
}

.fx i {
  top: 16%;
  width: 8px;
  height: 12px;
  background: var(--ak-accent);
}

.fx .puff {
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow: 0 0 0 2px var(--ak-surface);
}

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

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

@media (max-height: 760px) {
  .play-logo {
    height: 32px;
  }

  .turn-who {
    font-size: 18px;
  }

  .voice,
  .note,
  .why {
    padding: 6px 8px;
  }

  .ladder,
  .bulb {
    height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .spot {
    animation: breathe 4.8s ease-in-out infinite;
  }

  .sheet.is-idle {
    animation: idle-paper 3.6s ease-in-out infinite;
  }

  .sheet.is-in {
    animation: drop-in 560ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .sheet.is-shake {
    animation: shake-paper 420ms ease-in-out both;
  }

  .sheet.is-out {
    animation: tilt-off 340ms ease-in both;
  }

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

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

  .voice.is-point::after {
    animation: bob 1s ease-in-out infinite;
  }

  .sheet.is-point::after {
    animation: point-glow 1.6s ease-in-out infinite;
  }

  .token:active {
    transform: scale(0.96, 0.9);
  }

  .hint:active,
  .btn:active,
  .mute:active {
    transform: translateY(3px) scale(0.98, 0.94);
    box-shadow: none;
  }

  .ring.is-wait {
    animation: ring-wait 1.3s ease-in-out infinite;
  }

  .ring.is-stamp {
    animation: stamp 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

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

  .ladder.is-chase .bulb {
    animation-name: gold-pass;
    animation-duration: 480ms;
    animation-timing-function: ease-in-out;
    animation-iteration-count: 2;
    animation-delay: calc(var(--i) * 90ms);
  }

  .ladder.is-chase .bulb.is-lit {
    animation-name: gold-pass-lit;
  }

  .note.is-on,
  .why.is-on,
  .result.is-on .result-card {
    animation: rise-in 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .fx i {
    animation: confetti 980ms ease-out forwards;
  }

  .fx .puff {
    animation: puff 620ms ease-out forwards;
  }
}

@keyframes breathe {
  0%,
  100% { opacity: 0.45; }
  50% { opacity: 0.95; }
}

@keyframes idle-paper {
  0%,
  100% { transform: rotate(-2.2deg) translateY(0); }
  50% { transform: rotate(-1.1deg) translateY(-5px); }
}

@keyframes drop-in {
  0% { transform: translateY(-28%) rotate(-10deg) scale(0.88, 1.1); opacity: 0; }
  62% { transform: translateY(0) rotate(-1deg) scale(1.05, 0.92); opacity: 1; }
  100% { transform: rotate(-2deg) scale(1); opacity: 1; }
}

@keyframes shake-paper {
  0%,
  100% { transform: rotate(-2deg); }
  25% { transform: translateX(-8px) rotate(-4.5deg); }
  75% { transform: translateX(8px) rotate(0.5deg); }
}

@keyframes tilt-off {
  0% { transform: rotate(-2deg) scale(1); opacity: 1; }
  100% { transform: translateY(14%) rotate(11deg) scale(0.9); opacity: 0; }
}

@keyframes point-glow {
  0%,
  100% { box-shadow: 0 0 0 0 var(--ak-glow); }
  50% { box-shadow: 0 0 22px 6px var(--ak-accent); }
}

@keyframes cue {
  0% { transform: scale(0.92); }
  55% { transform: scale(1.06, 0.94); }
  100% { transform: scale(1); }
}

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

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

@keyframes ring-wait {
  0%,
  100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.06); }
}

@keyframes stamp {
  0% { transform: translate(-50%, -50%) scale(1.5) rotate(-12deg); opacity: 0; }
  68% { transform: translate(-50%, -50%) scale(0.92) rotate(3deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes bulb-pop {
  0% { transform: scale(0.55); }
  60% { transform: scale(1.14, 0.88); }
  100% { transform: scale(1); }
}

@keyframes gold-pass {
  0%,
  100% { filter: brightness(0.38) saturate(0.65); }
  40% { filter: brightness(1.5) saturate(1.2) drop-shadow(0 0 8px var(--ak-accent)) drop-shadow(0 0 2px var(--ak-glow)); }
}

@keyframes gold-pass-lit {
  0%,
  100% { filter: brightness(1.18) saturate(1.12) drop-shadow(0 0 6px var(--ak-accent)) drop-shadow(0 0 2px var(--ak-glow)); }
  40% { filter: brightness(1.65) saturate(1.3) drop-shadow(0 0 12px var(--ak-accent)) drop-shadow(0 0 3px var(--ak-glow)); }
}

@keyframes rise-in {
  0% { transform: translateY(8px) scale(0.96); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(62dvh) rotate(220deg); opacity: 0; }
}

@keyframes puff {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx, 0px), var(--dy, -24px)) scale(1.15); opacity: 0; }
}
