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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ak-ink);
  background:
    radial-gradient(90vw 52vh at 50% -8%, var(--ak-choice-bg), transparent 68%),
    var(--ak-bg);
}

[hidden] {
  display: none !important;
}

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

.play {
  --chrome: 7.25rem;
  --disc-red: var(--ak-accent);
  --disc-red-lit: color-mix(in srgb, var(--ak-bg) 38%, var(--ak-accent));
  --disc-red-rim: var(--ak-btn-active);
  --disc-yellow: var(--ak-choice-border);
  --disc-yellow-lit: color-mix(in srgb, var(--ak-bg) 42%, var(--ak-choice-border));
  --disc-yellow-rim: var(--ak-ink-muted);
  --frame: color-mix(in srgb, var(--ak-ink) 78%, var(--ak-accent));
  --frame-lit: color-mix(in srgb, var(--ak-ink-muted) 42%, var(--ak-accent));
  --frame-lip: color-mix(in srgb, var(--ak-ink) 92%, var(--ak-accent));
  --hole: var(--ak-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 100dvh;
  min-height: 100svh;
  padding: 12px 12px 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

.play.is-card {
  --chrome: 14.5rem;
}

.voice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 520px);
  min-height: 44px;
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 5.4vw, 28px);
  font-weight: var(--ak-title-weight);
  line-height: 1.15;
  text-align: center;
}

.voice.is-quiet {
  opacity: 0;
}

.voice-pip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--ak-ink) 22%, transparent);
}

.voice-pip.is-red {
  background: radial-gradient(circle at 32% 28%, var(--disc-red-lit), var(--disc-red));
}

.voice-pip.is-yellow {
  background: radial-gradient(circle at 32% 28%, var(--disc-yellow-lit), var(--disc-yellow));
}

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100%, 520px, calc((100dvh - var(--chrome)) * 7 / 6.7));
  min-height: 0;
}

.ghosts {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  padding: 0 10px;
  min-height: 36px;
}

.ghost {
  display: grid;
  place-items: center;
}

.ghost-disc {
  width: min(42px, 78%);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  transform: translateY(6px);
  background: radial-gradient(circle at 32% 28%, var(--disc-red-lit), var(--disc-red));
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--ak-ink) 20%, transparent);
}

.ghost.is-yellow .ghost-disc {
  background: radial-gradient(circle at 32% 28%, var(--disc-yellow-lit), var(--disc-yellow));
}

.ghost.is-on .ghost-disc {
  opacity: 0.92;
  transform: translateY(0);
}

.rack {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  padding: 12px 10px 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--frame-lit) 55%, var(--frame)), var(--frame));
  border: 3px solid var(--frame-lip);
  border-bottom-width: 8px;
  border-radius: var(--ak-radius);
  overflow: hidden;
  box-shadow:
    inset 0 2px 0 color-mix(in srgb, var(--ak-bg) 28%, transparent),
    0 14px 28px color-mix(in srgb, var(--ak-ink) 18%, transparent);
}

.column {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.column:disabled {
  cursor: default;
}

.column:hover:not(:disabled),
.column.is-aimed:not(:disabled) {
  background: color-mix(in srgb, var(--ak-bg) 16%, transparent);
}

.column:focus {
  outline: none;
}

.column:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.hole {
  position: relative;
  aspect-ratio: 1;
  pointer-events: none;
  border-radius: 50%;
  background: var(--hole);
  box-shadow:
    inset 0 3px 5px color-mix(in srgb, var(--ak-ink) 28%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ak-bg) 40%, transparent);
}

.hole.is-next {
  box-shadow:
    inset 0 3px 5px color-mix(in srgb, var(--ak-ink) 22%, transparent),
    0 0 0 2px color-mix(in srgb, var(--ak-focus) 45%, transparent);
}

.disc {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
}

.disc.is-red {
  background: radial-gradient(circle at 32% 28%, var(--disc-red-lit), var(--disc-red));
  box-shadow:
    inset 0 -3px 0 var(--disc-red-rim),
    inset 0 3px 0 color-mix(in srgb, var(--ak-bg) 28%, transparent);
}

.disc.is-yellow {
  background: radial-gradient(circle at 32% 28%, var(--disc-yellow-lit), var(--disc-yellow));
  box-shadow:
    inset 0 -3px 0 var(--disc-yellow-rim),
    inset 0 3px 0 color-mix(in srgb, var(--ak-bg) 45%, transparent);
}

.disc.is-falling {
  animation: disc-fall var(--fall-ms) cubic-bezier(0.2, 0.85, 0.2, 1);
}

.disc.is-win {
  z-index: 1;
  animation: win-pulse 520ms ease-in-out infinite;
}

.disc.is-tumble {
  animation: disc-tumble 480ms cubic-bezier(0.45, 0, 1, 1) var(--tumble-delay, 0ms) forwards;
}

.result {
  width: min(100%, 520px);
  flex: 0 0 auto;
}

.result-card {
  padding: 16px 16px 14px;
  background: var(--ak-choice-bg);
  color: var(--ak-ink);
  border: 2px solid var(--ak-choice-border);
  border-radius: var(--ak-radius);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--ak-ink) 12%, transparent);
  text-align: center;
}

.result-says {
  margin: 0 0 14px;
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 5vw, 26px);
  font-weight: var(--ak-title-weight);
  line-height: 1.2;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.btn-go,
.btn-alt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 132px;
  padding: 0 18px;
  border-radius: var(--ak-radius);
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

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

.btn-go:hover {
  background: var(--ak-btn-hover);
}

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

.btn-alt {
  border: 2px solid var(--ak-choice-border);
  background: var(--ak-bg);
  color: var(--ak-choice-ink);
}

.btn-alt:hover {
  border-color: var(--ak-choice-selected-border);
}

.btn-go:focus,
.btn-alt:focus {
  outline: none;
}

.btn-go:focus-visible,
.btn-alt:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

@keyframes disc-fall {
  0% {
    transform: translateY(var(--fall-from));
  }
  82% {
    transform: translateY(3px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes win-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow:
      0 0 0 3px var(--ak-bg),
      0 0 14px var(--ak-focus);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.12);
    box-shadow:
      0 0 0 5px var(--ak-bg),
      0 0 22px var(--ak-accent);
  }
}

@keyframes disc-tumble {
  to {
    transform: translateY(130%);
    opacity: 0;
  }
}

@media (max-width: 420px) {
  .play {
    padding: 8px 8px 12px;
    gap: 8px;
  }

  .rack {
    gap: 4px;
    padding: 8px 6px 10px;
  }

  .column {
    gap: 4px;
    padding: 2px 1px;
  }

  .ghosts {
    gap: 4px;
    padding: 0 6px;
    min-height: 28px;
  }
}

@media (max-height: 620px) {
  .ghosts {
    min-height: 24px;
  }

  .voice {
    font-size: 20px;
    min-height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ghost-disc,
  .disc.is-falling,
  .disc.is-win,
  .disc.is-tumble {
    animation: none;
    transition: none;
  }

  .ghost.is-on .ghost-disc {
    transform: none;
  }

  .disc.is-win {
    box-shadow:
      0 0 0 3px var(--ak-bg),
      0 0 12px var(--ak-focus);
  }

  .disc.is-tumble {
    opacity: 0;
  }
}
