:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --ink: #171b22;
  --muted: #5c6676;
  --panel: #ffffff;
  --line: #d9e0ea;
  --teal: #15866f;
  --coral: #d65f42;
  --indigo: #4f58b8;
  --gold: #b98220;
  --shadow: 0 18px 45px rgba(28, 36, 52, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 28px 0;
}

.screen {
  width: 100%;
}

.screen[hidden] {
  display: none;
}

.brand-row,
.play-header,
.results-header,
.section-heading,
.score-row,
.action-row {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 22px;
  margin-bottom: 26px;
}

.brand-mark {
  width: clamp(78px, 12vw, 118px);
  flex: 0 0 auto;
}

.brand-mark svg {
  display: block;
  width: 100%;
  filter: drop-shadow(0 18px 18px rgba(41, 53, 76, 0.18));
}

.mark-card {
  stroke: #171b22;
  stroke-width: 4;
}

.mark-card-back {
  fill: #efad44;
}

.mark-card-front {
  fill: #ffffff;
}

.mark-spark {
  fill: #15866f;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(3.25rem, 8vw, 7rem);
  line-height: 0.88;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

h3 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.setup-grid,
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.results-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.deck-search {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.deck-search input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
}

.deck-search input:focus {
  border-color: var(--indigo);
  outline: 3px solid rgba(79, 88, 184, 0.16);
}

.empty-decks {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.pill {
  min-width: 72px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.deck-option {
  min-height: 96px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  transition:
    border-color 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.deck-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(28, 36, 52, 0.12);
}

.deck-option[aria-pressed="true"] {
  border-color: var(--deck-accent, var(--teal));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--deck-accent, var(--teal)) 22%, transparent);
}

.deck-dot {
  width: 18px;
  height: 54px;
  border-radius: 999px;
  background: var(--deck-accent, var(--teal));
}

.deck-name {
  display: block;
  margin-bottom: 4px;
  font-size: 1.05rem;
  font-weight: 900;
}

.deck-meta {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.control-panel {
  position: sticky;
  top: 28px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.primary-action,
.secondary-action,
.success-action,
.icon-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  font-weight: 950;
}

.primary-action {
  width: 100%;
  margin-top: 16px;
  background: var(--ink);
  color: #ffffff;
}

.secondary-action {
  background: #e8edf4;
  color: #27303d;
}

.success-action {
  background: var(--teal);
  color: #ffffff;
}

.play-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto auto auto minmax(260px, 1fr) auto;
  gap: 18px;
}

.play-header,
.results-header {
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 54px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.timer-bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe2ec;
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transition: width 250ms linear;
}

.score-row {
  justify-content: space-between;
  gap: 14px;
}

.score-row > div {
  min-width: 0;
  flex: 1;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(28, 36, 52, 0.08);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-row strong {
  display: block;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.95;
}

.clue-card {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 56px);
  border: 3px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.8)),
    repeating-linear-gradient(45deg, rgba(21, 134, 111, 0.12) 0 18px, rgba(214, 95, 66, 0.12) 18px 36px);
  box-shadow: var(--shadow);
}

.clue-card p {
  max-width: 900px;
  margin: 0;
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: 1000;
  line-height: 0.95;
  text-align: center;
  text-wrap: balance;
}

.taunt-character {
  position: absolute;
  right: clamp(12px, 2.5vw, 24px);
  bottom: clamp(12px, 2.5vw, 24px);
  z-index: 2;
  display: flex;
  align-items: end;
  gap: 10px;
  max-width: min(360px, calc(100% - 24px));
  pointer-events: none;
}

.taunt-character[hidden] {
  display: none;
}

.taunt-character.is-visible {
  animation: taunt-arrive 420ms ease-out both;
}

.taunt-bubble {
  max-width: 245px;
  padding: 9px 11px;
  border: 1px solid rgba(23, 27, 34, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(28, 36, 52, 0.12);
  color: #27303d;
  font-size: clamp(0.74rem, 1.6vw, 0.9rem);
  font-weight: 900;
  line-height: 1.16;
}

.taunt-person {
  --taunt-scale: 1;
  position: relative;
  width: 76px;
  height: 92px;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 14px rgba(28, 36, 52, 0.18));
  animation: taunt-float 1900ms ease-in-out infinite;
}

.taunt-head,
.taunt-hair,
.taunt-ear,
.taunt-brow,
.taunt-eye,
.taunt-nose,
.taunt-mouth,
.taunt-neck,
.taunt-body,
.taunt-arm,
.taunt-hand {
  position: absolute;
  display: block;
}

.taunt-head {
  top: 3px;
  left: 14px;
  z-index: 3;
  width: 50px;
  height: 56px;
  border: 2px solid #171b22;
  border-radius: 44% 44% 48% 48%;
  background: #f2be79;
}

.taunt-hair {
  top: -7px;
  left: -4px;
  width: 56px;
  height: 22px;
  border: 2px solid #171b22;
  border-bottom: 0;
  border-radius: 22px 22px 10px 8px;
  background: #3b2f2b;
}

.taunt-hair::after {
  position: absolute;
  top: 12px;
  left: 4px;
  width: 38px;
  height: 10px;
  border-radius: 0 0 12px 12px;
  background: #3b2f2b;
  content: "";
}

.taunt-ear {
  top: 22px;
  width: 9px;
  height: 14px;
  border: 2px solid #171b22;
  border-radius: 999px;
  background: #efb36d;
}

.taunt-ear-left {
  left: 8px;
}

.taunt-ear-right {
  right: 8px;
}

.taunt-brow,
.taunt-eye,
.taunt-nose,
.taunt-mouth,
.taunt-arm,
.taunt-hand {
  background: #171b22;
}

.taunt-brow {
  top: 19px;
  left: 11px;
  width: 29px;
  height: 3px;
  border-radius: 999px;
  transform: rotate(-9deg);
  transform-origin: center;
  animation: taunt-brow 1700ms ease-in-out infinite;
}

.taunt-eye {
  top: 30px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.taunt-eye-left {
  left: 14px;
}

.taunt-eye-right {
  right: 14px;
}

.taunt-nose {
  top: 34px;
  left: 24px;
  width: 5px;
  height: 12px;
  border-radius: 999px;
  opacity: 0.72;
}

.taunt-mouth {
  right: 13px;
  bottom: 9px;
  width: 21px;
  height: 4px;
  border-radius: 999px;
  transform: rotate(-11deg);
}

.taunt-neck {
  top: 55px;
  left: 31px;
  z-index: 2;
  width: 16px;
  height: 14px;
  border: 2px solid #171b22;
  border-top: 0;
  background: #e8a862;
}

.taunt-body {
  left: 10px;
  bottom: 0;
  z-index: 1;
  width: 58px;
  height: 34px;
  border: 2px solid #171b22;
  border-radius: 18px 18px 8px 8px;
  background: #4f58b8;
}

.taunt-body::after {
  position: absolute;
  top: 10px;
  left: 26px;
  width: 2px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  content: "";
}

.taunt-arm {
  right: 7px;
  bottom: 23px;
  z-index: 4;
  width: 31px;
  height: 8px;
  border-radius: 999px;
  transform: rotate(-31deg);
}

.taunt-hand {
  right: 32px;
  bottom: 37px;
  z-index: 5;
  width: 11px;
  height: 11px;
  border: 2px solid #171b22;
  border-radius: 50%;
  background: #f2be79;
}

@keyframes taunt-arrive {
  from {
    opacity: 0;
    transform: translate3d(12px, 8px, 0) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes taunt-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg) scale(var(--taunt-scale));
  }

  50% {
    transform: translateY(-4px) rotate(1deg) scale(var(--taunt-scale));
  }
}

@keyframes taunt-brow {
  0%,
  100% {
    transform: rotate(-9deg) translateY(0);
  }

  50% {
    transform: rotate(-14deg) translateY(-1px);
  }
}

.action-row {
  gap: 14px;
}

.action-row button {
  flex: 1;
  min-width: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
}

.results-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.final-score {
  min-width: 138px;
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  text-align: center;
}

.final-score span {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.final-score strong {
  display: block;
  font-size: clamp(2.4rem, 7vw, 4.75rem);
  line-height: 0.95;
}

.result-list {
  min-height: 160px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-list li,
.empty-result {
  padding: 8px 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: #27303d;
  font-size: 0.94rem;
  font-weight: 800;
}

.empty-result {
  color: var(--muted);
}

.results-actions {
  margin-top: 18px;
}

.motion-debug {
  position: fixed;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(620px, calc(100vw - 20px));
  padding: 8px 10px;
  border: 1px solid rgba(23, 27, 34, 0.18);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.9);
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  pointer-events: none;
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    overscroll-behavior: none;
  }

  .app-shell {
    width: min(100vw - 22px, 680px);
    height: 100dvh;
    min-height: 100svh;
    align-items: stretch;
    overflow: hidden;
    padding:
      max(10px, env(safe-area-inset-top))
      0
      max(10px, env(safe-area-inset-bottom));
  }

  .screen.is-active {
    min-height: 0;
  }

  .setup-screen.is-active {
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .brand-row {
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
  }

  .brand-mark {
    width: 58px;
  }

  .setup-screen h1 {
    font-size: clamp(2.2rem, 12vw, 3.4rem);
  }

  .setup-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .setup-grid {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: stretch;
  }

  .setup-grid > .panel:first-child {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
    padding: 12px;
  }

  .section-heading {
    margin-bottom: 10px;
  }

  .deck-search {
    margin-bottom: 10px;
  }

  .deck-search input {
    min-height: 44px;
  }

  .deck-grid {
    min-height: 0;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 9px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 3px;
    -webkit-overflow-scrolling: touch;
  }

  .deck-option {
    min-height: 66px;
    padding: 10px 12px;
  }

  .deck-dot {
    width: 14px;
    height: 34px;
  }

  .deck-name {
    margin-bottom: 2px;
    font-size: 0.98rem;
  }

  .deck-meta {
    font-size: 0.82rem;
  }

  .control-panel {
    position: static;
    padding: 12px;
    box-shadow: 0 -8px 26px rgba(28, 36, 52, 0.1);
  }

  .control-panel .field {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  select {
    min-height: 46px;
  }

  .primary-action {
    min-height: 50px;
    margin-top: 10px;
  }

  .play-screen {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 10px;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
  }

  .score-row > div {
    padding: 10px 12px;
  }

  .clue-card {
    min-height: 0;
    padding: 16px;
  }

  .clue-card p {
    font-size: clamp(2.8rem, 16vw, 5.5rem);
  }

  .taunt-character {
    right: 10px;
    bottom: 10px;
    gap: 7px;
    max-width: calc(100% - 20px);
  }

  .taunt-bubble {
    max-width: min(190px, 58vw);
    padding: 7px 9px;
  }

  .taunt-person {
    --taunt-scale: 0.86;
    width: 58px;
    height: 72px;
    transform-origin: bottom right;
  }

  .play-screen .action-row {
    display: none;
  }

  .results-screen.is-active {
    height: 100%;
    overflow: auto;
  }
}

@media (max-width: 560px) {
  .deck-grid,
  .score-row,
  .action-row {
    grid-template-columns: 1fr;
  }

  .deck-grid {
    display: grid;
  }

  .score-row,
  .action-row {
    display: grid;
  }

  .play-header,
  .results-header {
    align-items: flex-start;
  }

  h1 {
    font-size: clamp(2.8rem, 18vw, 4.25rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .taunt-character.is-visible,
  .taunt-person,
  .taunt-brow {
    animation: none;
  }
}
