:root {
  --bg: #7f9bd2;
  --bg-deep: #6f87c1;
  --panel: rgba(113, 136, 199, 0.78);
  --panel-strong: rgba(105, 124, 190, 0.94);
  --ink: #fff8e8;
  --ink-dark: #321a3e;
  --muted: #e9edf9;
  --line: #f6a929;
  --orange: #ffa51f;
  --orange-deep: #d77510;
  --magenta: #b41458;
  --magenta-dark: #781647;
  --gold: #ffc94a;
  --cream: #fff2bd;
  --blue-card: #6f8bc8;
  --shadow: 0 18px 36px rgba(38, 47, 92, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 215, 104, .24) 0 2px, transparent 3px),
    radial-gradient(circle at 83% 20%, rgba(255, 215, 104, .2) 0 3px, transparent 4px),
    radial-gradient(circle at 26% 76%, rgba(255, 255, 255, .16) 0 2px, transparent 3px),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  display: none;
  position: fixed;
  left: 50%;
  width: min(720px, calc(100% - 32px));
  height: 4px;
  transform: translateX(-50%);
  background: var(--magenta);
  border-radius: 999px;
  opacity: .78;
  pointer-events: none;
}

body::before {
  content: none;
}

body::after {
  bottom: 34px;
}

button,
input,
a,
select {
  font: inherit;
}

.shell {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 46px;
}

main,
main > section:not([hidden]) {
  animation: pageEnter 420ms ease-out both;
}

.stacked-actions .button,
.vote-choice {
  animation: cardEnter 300ms ease-out both;
  animation-delay: calc(var(--enter-index, 0) * 45ms);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-toggle {
  min-width: 116px;
}

.sound-toggle.is-on {
  color: #fffaf0;
  background: var(--magenta);
  box-shadow: 0 4px 0 var(--magenta-dark);
}

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

h1 {
  color: var(--gold);
  font-size: clamp(38px, 6vw, 68px);
  line-height: .95;
  text-shadow: 0 4px 0 rgba(116, 28, 76, .45);
}

h2 {
  color: var(--ink);
  font-size: clamp(25px, 4vw, 40px);
  line-height: 1.25;
  text-shadow: 0 2px 0 rgba(68, 42, 103, .32);
}

h3 {
  color: var(--cream);
  font-size: 20px;
  text-shadow: 0 2px 0 rgba(68, 42, 103, .32);
}

.eyebrow {
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 3px dashed var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, .14);
  padding: 20px;
  animation: cardEnter 360ms ease-out both;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 6px;
  pointer-events: none;
}

.hero {
  min-height: 340px;
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 28px;
  background:
    linear-gradient(135deg, rgba(126, 20, 82, .28), transparent 46%),
    var(--panel-strong);
}

.hero-copy {
  display: grid;
  gap: 16px;
}

.hero .button {
  grid-column: 2;
}

.hero-box-art {
  width: min(220px, 46vw);
  justify-self: center;
  filter: drop-shadow(0 14px 18px rgba(58, 40, 91, .35));
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, .92fr);
  gap: 18px;
  align-content: start;
}

.tabs {
  display: grid;
  gap: 8px;
}

.admin-tabs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  grid-auto-rows: max-content;
  align-items: stretch;
  align-self: start;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
  overflow: hidden;
}

.admin-tabs.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.tabs-toggle-wrapper {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  z-index: 2;
}

.toggle-tabs-btn {
  background: linear-gradient(180deg, #fff4c7 0%, #f4d189 100%);
  color: var(--magenta-dark);
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 0 #c68522;
  transition: transform 120ms ease, filter 120ms ease;
}

.toggle-tabs-btn:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

.toggle-icon {
  transition: transform 0.3s ease;
}

.toggle-tabs-btn.collapsed .toggle-icon {
  transform: rotate(-180deg);
}

.tab-button {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  border: 2px solid rgba(255, 255, 255, .28);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  color: var(--magenta-dark);
  background: linear-gradient(180deg, #fff4c7 0%, #f4d189 100%);
  box-shadow: 0 4px 0 #c68522;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-badge {
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  direction: ltr;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.tab-button.active {
  color: #fffaf0;
  background: linear-gradient(180deg, #ffbc35 0%, var(--orange) 52%, #f08a15 100%);
  text-shadow: 0 2px 0 rgba(116, 44, 22, .35);
  box-shadow: 0 5px 0 var(--orange-deep), 0 12px 18px rgba(76, 47, 102, .25);
}

.new-room-tab {
  color: #fffaf0;
  background: var(--magenta);
  box-shadow: 0 4px 0 var(--magenta-dark);
}

#roomState.admin-tab-room #adminPlayersPanel,
#roomState.admin-tab-room #adminRoundPanel,
#roomState.admin-tab-room #resultsPanel,
#roomState.admin-tab-players #adminRoomPanel,
#roomState.admin-tab-players #adminRoundPanel,
#roomState.admin-tab-players #resultsPanel,
#roomState.admin-tab-round #adminRoomPanel,
#roomState.admin-tab-round #adminPlayersPanel,
#roomState.admin-tab-round #resultsPanel,
#roomState.admin-tab-results #adminRoomPanel,
#roomState.admin-tab-results #adminPlayersPanel,
#roomState.admin-tab-results #adminRoundPanel {
  display: none;
}

#adminRoomPanel,
#adminPlayersPanel,
#adminRoundPanel,
#resultsPanel {
  grid-column: 1 / -1;
}

.tab-button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.control-panel,
.results {
  grid-column: 1 / -1;
}

.room-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 2px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: var(--magenta);
  color: var(--cream);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(95, 18, 61, .45);
}

.join-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-link-tools {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
}

.qr-button {
  min-width: 112px;
}

.join-by-code {
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 20px;
  border-top: 2px dashed var(--sand);
  width: 100%;
  max-width: 400px;
  justify-self: center;
}

.join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.host-choice {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compact-actions {
  margin-top: 0;
  grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(74, 44, 116, .32);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink-dark);
  background: rgba(255, 244, 199, .95);
  direction: ltr;
  text-align: left;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55);
}

select {
  direction: rtl;
  text-align: right;
}

.name-input {
  direction: rtl;
  text-align: right;
}

.button {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 17px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  white-space: nowrap;
  transition: transform 120ms ease, filter 120ms ease;
}

.button::after,
.tab-button::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(120%) skewX(-18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .34), transparent);
  pointer-events: none;
}

.button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.button:active,
.tab-button:active,
.toggle-tabs-btn:active {
  transform: translateY(2px) scale(.985);
  filter: saturate(1.1);
}

.button:hover::after,
.tab-button:hover::after {
  animation: buttonShine 760ms ease-out;
}

.button.primary {
  background: linear-gradient(180deg, #ffbc35 0%, var(--orange) 52%, #f08a15 100%);
  color: #fffaf0;
  text-shadow: 0 2px 0 rgba(116, 44, 22, .35);
  box-shadow: 0 5px 0 var(--orange-deep), 0 12px 18px rgba(76, 47, 102, .25);
}

.button.secondary {
  background: linear-gradient(180deg, #fff4c7 0%, #f4d189 100%);
  color: var(--magenta-dark);
  box-shadow: 0 4px 0 #c68522;
}

.button.warning {
  background: var(--magenta);
  color: white;
  box-shadow: 0 4px 0 var(--magenta-dark);
}

.button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.notice {
  margin-top: 12px;
  color: #fff4c7;
  background: rgba(180, 20, 88, .82);
  border-radius: 8px;
  padding: 9px 12px;
  line-height: 1.6;
}



.setup-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: rgba(86, 104, 177, .5);
}

.setup-field {
  display: grid;
  gap: 6px;
}

.setup-field span {
  color: var(--cream);
  font-size: 13px;
  font-weight: 900;
}

.reveal-button {
  justify-self: start;
}

.vote-choice.selected {
  background: linear-gradient(180deg, #ffe177, #ffad2e);
  color: var(--magenta-dark);
  outline: 3px solid var(--cream);
  animation: scorePop 260ms ease-out both;
}

.enter-animate {
  animation: cardEnter 340ms ease-out both;
  animation-delay: calc(var(--enter-index, 0) * 45ms);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100dvh;
  z-index: 50;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(50, 26, 62, .58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-panel {
  width: min(440px, calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  max-height: calc(100dvh - 36px);
  display: grid;
  gap: 12px;
  background: var(--panel-strong);
  border: 3px dashed var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.reveal-backdrop {
  z-index: 70;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 201, 74, .22), transparent 34%),
    rgba(50, 26, 62, .72);
}

.reveal-panel {
  width: min(560px, calc(100% - 24px));
  justify-items: center;
  text-align: center;
  overflow: hidden;
}

.reveal-panel h3 {
  color: var(--gold);
  font-size: clamp(28px, 6vw, 44px);
}

.reveal-wheel {
  position: relative;
  width: 100%;
  min-height: 170px;
  display: grid;
  place-items: center;
  padding: 34px 14px 20px;
  border: 3px dashed var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 165, 31, .22), transparent 44%),
    rgba(89, 108, 184, .84);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13);
}

.reveal-pointer {
  position: absolute;
  top: 10px;
  color: var(--magenta);
  font-size: 28px;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(255, 242, 189, .42);
  animation: revealPointerPulse 620ms ease-in-out infinite;
}

.reveal-name {
  width: min(100%, 390px);
  min-height: 76px;
  display: grid;
  place-items: center;
  padding: 14px 18px;
  border: 2px solid rgba(255, 255, 255, .28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff4c7 0%, #f4d189 100%);
  color: var(--ink-dark);
  font-size: clamp(28px, 8vw, 46px);
  font-weight: 900;
  overflow-wrap: anywhere;
  box-shadow: 0 7px 0 #c68522, 0 18px 28px rgba(38, 47, 92, .28);
}

.reveal-name.is-spinning {
  animation: revealNameShake 110ms linear infinite;
}

.reveal-name.is-revealed {
  color: var(--cream);
  background: var(--magenta);
  box-shadow: 0 7px 0 var(--magenta-dark), 0 18px 28px rgba(38, 47, 92, .32);
  animation: revealPop 560ms cubic-bezier(.2, 1.35, .28, 1);
}

.reveal-targets {
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.reveal-panel .muted.is-waiting {
  color: var(--cream);
  opacity: .92;
}

.reveal-target-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--cream);
  background: var(--magenta);
  font-weight: 900;
  box-shadow: 0 4px 0 var(--magenta-dark);
  animation: revealChipIn 260ms ease-out;
}

.reveal-actions {
  width: min(100%, 280px);
  grid-template-columns: 1fr;
  justify-content: center;
  justify-self: center;
  margin-inline: auto;
  margin-top: 6px;
}

.reveal-actions .button {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  font-size: 18px;
  justify-self: center;
}

@keyframes revealPointerPulse {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(4px) scale(1.08);
  }
}

@keyframes revealNameShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@keyframes revealPop {
  0% {
    transform: scale(.72) rotate(-2deg);
  }
  62% {
    transform: scale(1.08) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes revealChipIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.details-modal-panel {
  width: min(640px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(92dvh, 780px);
  overflow: hidden;
}

.details-modal-body,
.modal-game-stack {
  display: grid;
  gap: 12px;
}

.details-modal-body {
  max-height: calc(92dvh - 98px);
  overflow: auto;
  padding-inline-end: 4px;
}

.qr-modal-content {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.qr-code {
  width: min(280px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(120, 22, 71, .32), 0 18px 28px rgba(38, 47, 92, .24);
}

.qr-code svg {
  width: 100%;
  height: auto;
  display: block;
}

.qr-link-input {
  direction: ltr;
  text-align: left;
}

.small-button {
  min-height: 36px;
  padding: 7px 12px;
}

.players {
  display: grid;
  gap: 9px;
}

.player-row,
.result-row,
.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 9px 11px;
  background: rgba(255, 242, 189, .9);
  color: var(--ink-dark);
}

.player-details {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.player-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.player-meta {
  color: #6f658f;
  direction: ltr;
  font-size: 12px;
  text-align: right;
}

.score {
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  text-align: center;
  color: white;
  background: var(--magenta);
  font-weight: 900;
}

.round-details,
.actions,
#resultsBody,
#playerResultsBody {
  display: grid;
  gap: 11px;
}

.actions {
  margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));
}

.muted {
  color: var(--muted);
  line-height: 1.75;
  font-weight: 700;
}

.question-card {
  display: grid;
  gap: 12px;
  border: 3px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 200, 74, .14), transparent 45%),
    rgba(107, 129, 197, .88);
}

.question-label {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.question-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.question-flow strong {
  overflow-wrap: anywhere;
  font-size: clamp(21px, 3vw, 31px);
  line-height: 1.2;
}

.question-flow strong:first-child {
  text-align: right;
}

.question-flow strong:last-child {
  text-align: left;
}

.question-arrow {
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--magenta);
  color: var(--cream);
  font-weight: 900;
  box-shadow: 0 4px 0 var(--magenta-dark);
}

.secret-card {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 150px;
  border: 3px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 164, 31, .16), transparent 48%),
    var(--blue-card);
}

.secret-card::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: 12px;
  width: 72px;
  height: 92px;
  background: url("/assets/category-card.svg") center / contain no-repeat;
  opacity: .34;
  pointer-events: none;
}

.secret-card.outsider {
  background:
    linear-gradient(135deg, rgba(255, 231, 104, .25), transparent 44%),
    rgba(143, 76, 139, .9);
}

.secret-card strong {
  color: var(--cream);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.15;
  text-shadow: 0 3px 0 rgba(88, 37, 94, .38);
}

.secret-card p {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.55;
  max-width: min(100%, 620px);
}

.section-title {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 4px solid var(--magenta);
  color: var(--gold);
}

.detail-list,
.detail-stack {
  display: grid;
  gap: 8px;
}

.result-row {
  align-items: flex-start;
}

.result-row span {
  min-width: 0;
  line-height: 1.5;
}

.result-row span:first-child {
  font-weight: 900;
}

.result-row span:last-child {
  color: #6d2857;
  text-align: left;
  font-weight: 800;
}

.result-row.tone-good {
  border-color: rgba(108, 167, 117, .6);
  background: #dff4cb;
}

.result-row.tone-good span:last-child {
  color: #256833;
}

.result-row.tone-bad {
  border-color: rgba(180, 20, 88, .55);
  background: #ffe0ec;
}

.result-row.tone-bad span:last-child {
  color: var(--magenta);
}

.result-row.tone-warn {
  border-color: var(--gold);
  background: #fff0ad;
}

.result-row.tone-warn span:last-child {
  color: #a45b00;
}

.progress-wrap {
  width: 100%;
  height: 13px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  background: rgba(68, 56, 126, .45);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  transition: width 180ms ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 242, 189, .92);
  color: var(--ink-dark);
}

.stat span {
  display: block;
  color: #7a6a8f;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.stat strong {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.results {
  background:
    url("/assets/result-medal.svg") left 18px top 16px / 92px auto no-repeat,
    linear-gradient(135deg, rgba(180, 20, 88, .24), transparent 42%),
    var(--panel-strong);
  animation: resultEnter 460ms ease-out both;
}

.results::after {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: 0;
  background:
    radial-gradient(circle, rgba(255, 201, 74, .42) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, .28) 0 2px, transparent 3px);
  background-size: 86px 86px, 121px 121px;
  opacity: 0;
  pointer-events: none;
  animation: resultSparkle 1400ms ease-out 120ms;
}

.results > * {
  position: relative;
  z-index: 1;
}

.results.is-personal-win {
  animation: resultEnter 460ms ease-out both, winnerBurst 1050ms ease-out 420ms;
}

.results.is-personal-loss {
  animation: resultEnter 460ms ease-out both, loserShake 420ms ease-in-out 480ms;
}

.score-pop,
.score,
.status {
  animation: scorePop 300ms ease-out both;
}

.winner-burst {
  animation: winnerBurst 900ms ease-out both;
}

.loser-shake {
  animation: loserShake 420ms ease-in-out both;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes resultEnter {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(.98);
  }
  70% {
    opacity: 1;
    transform: translateY(-3px) scale(1.01);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes buttonShine {
  from {
    transform: translateX(120%) skewX(-18deg);
  }
  to {
    transform: translateX(-140%) skewX(-18deg);
  }
}

@keyframes scorePop {
  0% {
    transform: scale(.86);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes winnerBurst {
  0%, 100% {
    transform: scale(1);
    box-shadow: none;
  }
  45% {
    transform: scale(1.025);
    box-shadow: 0 0 0 4px rgba(255, 201, 74, .34), 0 10px 20px rgba(58, 40, 91, .18);
  }
}

@keyframes loserShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes resultSparkle {
  0% {
    opacity: 0;
    transform: translateY(18px) rotate(0);
  }
  35% {
    opacity: .85;
  }
  100% {
    opacity: 0;
    transform: translateY(-16px) rotate(10deg);
  }
}

@media (max-width: 760px) {
  body::before,
  body::after {
    width: calc(100% - 20px);
  }

  body::before {
    top: 74px;
  }

  .shell {
    width: min(100% - 18px, 1040px);
    padding-top: 18px;
  }

  .topbar,
  .room-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-direction: column;
  }

  .sound-toggle {
    width: 100%;
  }

  .hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .hero .button {
    grid-column: auto;
  }

  .room-grid {
    grid-template-columns: 1fr;
  }

  .join-box,
  .join-form {
    grid-template-columns: 1fr;
  }

  .admin-link-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-link-tools input {
    grid-column: 1 / -1;
  }

  .create-qr-button {
    grid-column: 1 / -1;
  }

  .button {
    width: 100%;
    white-space: normal;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .question-flow {
    grid-template-columns: 1fr;
  }

  .question-flow strong,
  .question-flow strong:first-child,
  .question-flow strong:last-child {
    text-align: right;
  }

  .question-arrow {
    justify-self: start;
  }

  .results {
    background:
      linear-gradient(135deg, rgba(180, 20, 88, .24), transparent 42%),
      var(--panel-strong);
  }

  body.compact-play {
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.compact-play.modal-open {
    overflow: hidden;
  }

  body.compact-play .shell {
    width: 100%;
    max-width: 100vw;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 8px 10px calc(88px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: visible;
  }

  body.compact-play main {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
  }

  body.compact-play .topbar {
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 0;
    overflow: hidden;
  }

  body.compact-play .topbar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  body.compact-play .top-actions {
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
    gap: 6px;
  }

  body.compact-play h1 {
    max-width: 100%;
    font-size: clamp(28px, 8vw, 38px);
    line-height: 1;
    overflow-wrap: anywhere;
  }

  body.compact-play h2 {
    font-size: clamp(24px, 8vw, 34px);
  }

  body.compact-play h3 {
    font-size: 17px;
  }

  body.compact-play .eyebrow {
    font-size: 10px;
    margin-bottom: 2px;
  }

  body.compact-play .room-grid {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: visible;
  }

  body.compact-play .panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px;
    border-width: 2px;
    box-shadow: 0 10px 20px rgba(38, 47, 92, .2), inset 0 0 0 1px rgba(255, 255, 255, .12);
  }

  body.compact-play .panel::before {
    inset: 6px;
  }

  body.compact-play .room-head,
  body.compact-play .section-head {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  body.compact-play .status,
  body.compact-play .score {
    min-height: 28px;
    padding: 4px 9px;
    font-size: 12px;
    box-shadow: 0 3px 0 rgba(95, 18, 61, .45);
  }

  body.compact-play .button {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
    white-space: normal;
  }

  body.compact-play .admin-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  body.compact-play .tab-button {
    min-height: 36px;
    padding: 7px 6px;
    font-size: 12px;
    box-shadow: 0 3px 0 #c68522;
  }

  body.compact-play .tab-button.active {
    box-shadow: 0 4px 0 var(--orange-deep);
  }

  body.compact-play .top-actions .button {
    width: auto;
    min-height: 32px;
    padding: 6px 9px;
  }

  body.compact-play .actions,
  body.compact-play .compact-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
  }

  body.compact-play .admin-link-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body.compact-play .qr-button {
    min-width: 0;
  }

  body.compact-play .round-details,
  body.compact-play #resultsBody,
  body.compact-play #playerResultsBody {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 7px;
  }

  body.compact-play .muted {
    font-size: 12px;
    line-height: 1.35;
  }

  body.compact-play .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 6px;
  }

  body.compact-play .stat {
    min-height: 0;
    padding: 7px 8px;
    border-width: 1px;
  }

  body.compact-play .stat span {
    font-size: 10px;
    margin-bottom: 2px;
  }

  body.compact-play .stat strong {
    font-size: 14px;
    line-height: 1.15;
  }

  body.compact-play .question-card {
    gap: 5px;
    padding: 8px 10px;
    border-width: 2px;
  }

  body.compact-play .question-label {
    font-size: 10px;
  }

  body.compact-play .question-flow {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 6px;
  }

  body.compact-play .question-flow strong {
    font-size: clamp(17px, 5vw, 24px);
  }

  body.compact-play .question-arrow {
    justify-self: center;
    padding: 5px 9px;
    font-size: 12px;
    box-shadow: 0 3px 0 var(--magenta-dark);
  }

  body.compact-play .secret-card {
    min-height: 104px;
    gap: 5px;
    padding: 12px;
    border-width: 2px;
  }

  body.compact-play .secret-card::after {
    display: none;
  }

  body.compact-play .secret-card strong {
    font-size: clamp(24px, 8vw, 34px);
  }

  body.compact-play .secret-card p {
    font-size: 14px;
    line-height: 1.35;
  }

  body.compact-play .reveal-button {
    justify-self: stretch;
  }

  body.compact-play .progress-wrap {
    height: 10px;
  }

  body.compact-play .result-row,
  body.compact-play .player-row,
  body.compact-play .vote-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }

  body.compact-play .result-row span,
  body.compact-play .player-row span,
  body.compact-play .vote-row span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body.compact-play .section-title {
    margin-top: 2px;
    padding-top: 8px;
    border-top-width: 2px;
    font-size: 15px;
  }

  body.compact-play #playerState.is-player-compact #playerRoomSummaryPanel {
    display: none;
  }

  body.compact-play #adminRoomPanel {
    min-height: 0;
  }

  body.compact-play #adminRoundPanel,
  body.compact-play #playerGamePanel,
  body.compact-play .results {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
  }

  body.compact-play #playerState.is-player-compact {
    grid-template-rows: minmax(0, 1fr);
  }

  body.compact-play #playerState.is-player-compact.is-results-compact {
    grid-template-rows: minmax(0, 1fr);
  }

  body.compact-play #playerState.is-player-compact.is-results-compact #playerGamePanel {
    display: none;
  }

  body.compact-play #playerGamePanel {
    height: auto;
  }

  body.compact-play .host-player-panel.is-compact-host-player .round-details {
    display: none;
  }

  body.compact-play .stacked-actions {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .modal-backdrop {
    width: 100vw;
    height: 100vh;
    min-height: 100dvh;
    padding: 12px;
    align-items: center;
    justify-items: center;
  }

  .modal-panel {
    width: min(440px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .details-modal-panel {
    width: min(640px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    padding: 14px;
  }

  .details-modal-body {
    max-height: calc(92dvh - 82px);
  }

  .reveal-panel {
    width: calc(100% - 18px);
    padding: 14px;
  }

  .reveal-wheel {
    min-height: 145px;
    padding: 30px 10px 16px;
  }

  .reveal-name {
    min-height: 66px;
    font-size: clamp(25px, 9vw, 38px);
  }

  .reveal-actions {
    width: min(100%, 260px);
  }

  body.compact-play .reveal-actions,
  body.compact-play .actions.reveal-actions,
  .reveal-panel .reveal-actions {
    grid-template-columns: 1fr;
    justify-self: center;
    justify-content: center;
    margin-inline: auto;
  }

  .reveal-actions .button {
    min-height: 50px;
    font-size: 17px;
  }
}

@media (max-width: 360px) {
  .admin-tabs,
  body.compact-play .admin-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .reveal-pointer,
  .reveal-name.is-spinning,
  .reveal-name.is-revealed,
  .reveal-target-chip {
    animation: none;
  }
}

.stacked-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
