:root {
  --ink: #0b1020;
  --paper: #f6efe4;
  --gold: #f2c14e;
  --blue-1: #1d4ed8;
  --blue-2: #1e3a8a;
  --red-1: #dc2626;
  --red-2: #991b1b;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: Outfit, "Segoe UI", sans-serif;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  html,
  body {
    height: 100%;
    height: 100dvh;
  }
}

button {
  font: inherit;
  cursor: pointer;
}

input {
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
}

body[data-view="game"] #flowScreen {
  display: none !important;
}

body:not([data-view="game"]) #app {
  display: none !important;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.flow-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  gap: 0.35rem;
}

.flow-panel {
  position: relative;
  flex: 1 1 50%;
  min-height: 0;
  overflow: hidden;
}

.flow-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1.15rem 1.1rem;
  overflow-y: auto;
}

.flow-panel.player-blue .flow-inner {
  transform: rotate(180deg);
  padding: 0.9rem 1.15rem calc(1.1rem + env(safe-area-inset-top, 0px));
}

.flow-panel.player-red .flow-inner {
  padding: calc(0.9rem + env(safe-area-inset-bottom, 0px)) 1.15rem 1.1rem;
}

.flow-content {
  width: min(20rem, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.flow-kicker {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.78;
}

.flow-title {
  margin: 0.2rem 0 0.85rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
}

.flow-lead {
  margin: 0 0 0.85rem;
  font-size: 0.98rem;
  line-height: 1.35;
  opacity: 0.92;
}

.flow-name {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  margin: 0 0 0.85rem;
  text-align: left;
}

.flow-name span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.78;
}

.flow-name input {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 1rem;
  padding: 0.5rem 0.85rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--paper);
  background: rgba(11, 16, 32, 0.28);
  text-align: center;
  color-scheme: dark;
  caret-color: var(--gold);
}

.flow-name input::placeholder {
  color: rgba(255, 255, 255, 0.42);
  font-weight: 600;
}

.flow-name input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.flow-choices,
.flow-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.btn-difficulty,
.btn-flow,
.btn-flow-ghost {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 1rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: rgba(11, 16, 32, 0.22);
}

.btn-difficulty[data-difficulty="tutoriel"] {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.55);
}

.btn-difficulty[data-difficulty="facile"] {
  background: #15803d;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-difficulty[data-difficulty="moyen"] {
  background: #7c3aed;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-difficulty[data-difficulty="difficile"] {
  background: #ea580c;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-difficulty[data-difficulty="tres-difficile"] {
  background: #111827;
  color: var(--gold);
  border-color: rgba(242, 193, 78, 0.45);
}

.btn-difficulty[data-difficulty="libre"] {
  background: #0f766e;
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-flow {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.55);
}

.btn-flow-ghost {
  background: transparent;
  min-height: 2.6rem;
  font-size: 1rem;
}

.btn-difficulty:active,
.btn-flow:active,
.btn-flow-ghost:active {
  transform: scale(0.98);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.38rem;
  width: 100%;
  margin: 0.15rem 0 0.85rem;
}

.flow-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  margin: 0.2rem 0 1rem;
}

.flow-stepper-value {
  min-width: 3.4rem;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 2.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.flow-stepper .btn-stepper {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.55rem;
}

.card-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  border-radius: 0.7rem;
  background: rgba(11, 16, 32, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: Fredoka, Outfit, sans-serif;
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.flow-scores {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.2rem 0 1rem;
}

.flow-score {
  min-width: 6.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 1rem;
  background: rgba(11, 16, 32, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.flow-score strong {
  display: block;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
}

.flow-score span {
  font-size: 0.85rem;
  opacity: 0.85;
}

.player {
  position: relative;
  flex: 1 1 50%;
  min-height: 0;
  overflow: hidden;
  transition: filter 180ms ease, box-shadow 180ms ease;
}

.player-stereo-bg {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: min(78%, 18rem);
  height: min(78%, 18rem);
  pointer-events: none;
  background: center / contain no-repeat url("/icons/vrglasses.svg");
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition: opacity 220ms ease, transform 220ms ease;
}

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

.puzzle-brief {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: min(92%, 16.8rem);
  transform: translate(-50%, -50%);
  padding: 0.85rem 1rem 0.95rem;
  border-radius: 1.15rem;
  background: rgba(11, 16, 32, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 28px rgba(11, 16, 32, 0.28);
  text-align: center;
  backdrop-filter: blur(10px);
}

.puzzle-brief-type {
  margin: 0;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.puzzle-brief-detail {
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  line-height: 1.35;
  opacity: 0.9;
}

.puzzle-brief-rows {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-top: 0.7rem;
}

.puzzle-brief-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.puzzle-brief-row span {
  opacity: 0.82;
}

.puzzle-brief-row strong {
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.12rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.player.is-active .player-stereo-bg,
.player.is-starter .player-stereo-bg {
  opacity: 0.28;
  transform: translate(-50%, -50%) scale(1);
}

.player-blue {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(180deg, var(--blue-1), var(--blue-2));
}

.player-red {
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(180deg, var(--red-1), var(--red-2));
}

.player.is-idle:not(.is-starter)::before,
.player:not(.is-active):not(.is-starter):not(.is-finished):not(.is-winner-choice)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(11, 16, 32, 0.18);
}

.player.is-idle:not(.is-starter) .player-inner > :not(.btn-done),
.player:not(.is-active):not(.is-starter):not(.is-finished):not(.is-winner-choice) .player-inner > :not(.btn-done) {
  filter: saturate(0.85) brightness(0.82);
}

.player.is-active,
.player.is-starter {
  filter: none;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.88), inset 0 0 48px rgba(255, 255, 255, 0.18);
  z-index: 1;
}

.player.is-finished:not(.is-winner-choice) {
  filter: saturate(0.55) brightness(0.72);
}

.player.is-winner-choice {
  filter: none;
}

#app[data-phase="disposition"] .player {
  flex: 0 0 auto;
  overflow: visible;
  filter: none;
}

#app[data-phase="disposition"] .player::before {
  content: none;
}

#app[data-phase="disposition"] .player-inner {
  position: relative;
  inset: auto;
  height: auto;
  gap: 0.45rem;
  filter: none;
}

#app[data-phase="disposition"] .player-inner > * {
  filter: none;
}

#app[data-phase="disposition"] .player-blue .player-inner {
  padding: 0.45rem 0.75rem calc(0.5rem + env(safe-area-inset-top, 0px));
}

#app[data-phase="disposition"] .player-red .player-inner {
  padding: 0.45rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

#app[data-phase="disposition"] .countdown-stage,
#app[data-phase="disposition"] .stereo-hint,
#app[data-phase="disposition"] .handicap-pill,
#app[data-phase="disposition"] .starter-callout,
#app[data-phase="disposition"] .btn-done {
  display: none !important;
}

#app[data-phase="disposition"] .player-name {
  font-size: 1.25rem;
}

#app[data-phase="disposition"] .player-score {
  min-width: 2.8rem;
  font-size: 1.55rem;
  padding: 0.28rem 0.55rem;
}

#app[data-phase="disposition"] .total-time {
  min-width: 4.6rem;
  font-size: 1.05rem;
}

.solution-stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background: rgb(200, 200, 200);
}

.solution-viewport {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.solution-stage.is-picking .solution-viewport {
  visibility: hidden;
}

.solution-2d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgb(200, 200, 200);
}

.solution-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

.solution-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.solution-3d > div {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Outfit, sans-serif;
  font-weight: 700;
  color: #1b1b1b;
}

.solution-missing {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  background: rgb(200, 200, 200);
}

.solution-mode {
  display: flex;
  width: 100%;
  gap: 0.4rem;
}

.btn-solution-mode {
  flex: 1;
  min-height: 2.35rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.85rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: rgba(11, 16, 32, 0.22);
}

.btn-solution-mode.is-active {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.5);
}

.btn-solution-mode:disabled {
  opacity: 0.35;
}

.btn-solution-mode:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-solution-picker {
  width: 100%;
  min-height: 2.35rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.85rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: rgba(11, 16, 32, 0.22);
}

.btn-solution-picker.is-open {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.5);
}

.btn-solution-picker:active {
  transform: scale(0.98);
}

.solution-picker {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: #0b1020;
}

.solution-picker-panel {
  flex: 1 1 50%;
  min-height: 0;
  overflow: hidden;
}

.solution-picker-panel + .solution-picker-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.solution-picker-inner {
  height: 100%;
  overflow-y: auto;
  padding: 0.55rem 0.7rem 0.7rem;
}

.solution-picker-panel:first-child .solution-picker-inner {
  transform: rotate(180deg);
}

.solution-picker-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.solution-picker-title {
  margin: 0;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.82;
}

.puzzle-pick-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}

.puzzle-pick-grid button {
  min-height: 2.15rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.65rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
}

.puzzle-pick-grid button.is-match:not(.is-viewed) {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.puzzle-pick-grid button.is-viewed {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.5);
}

.puzzle-pick-grid button:active {
  transform: scale(0.97);
}

.btn-solution-picker-close {
  width: 100%;
  min-height: 2.2rem;
  border: 0;
  border-radius: 0.75rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--paper);
  background: transparent;
}

.player-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) 1.1rem 1.15rem;
}

.player-blue .player-inner {
  transform: rotate(180deg);
  padding: 0.9rem 1.1rem calc(1.15rem + env(safe-area-inset-top, 0px));
}

.player-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.total-time,
.player-score {
  min-width: 3.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(11, 16, 32, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.total-time {
  min-width: 5.6rem;
}

.player-score {
  min-width: 3.6rem;
  padding: 0.42rem 0.85rem;
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
}

.player-id {
  flex: 1;
  text-align: center;
}

.player-name {
  display: block;
  overflow: hidden;
  max-width: 100%;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-status {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.starter-callout {
  margin: 0;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.94);
}

.countdown {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: clamp(4.8rem, 18vh, 8.2rem);
  font-weight: 700;
  line-height: 0.9;
  opacity: 0;
  transform: scale(0.92);
  text-shadow: 0 8px 24px var(--shadow);
}

.countdown.is-visible {
  opacity: 1;
  transform: scale(1);
}

.player.is-active .countdown.is-visible {
  animation: pulse 1s ease-in-out infinite;
}

.handicap-pill {
  align-self: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(11, 16, 32, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.95rem;
  font-weight: 700;
}

.stereo-hint {
  align-self: center;
  margin-top: -0.35rem;
  margin-bottom: 0.15rem;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: rgba(246, 239, 228, 0.92);
}

.btn-done,
.btn-winner {
  width: 100%;
  min-height: 4.1rem;
  border: 0;
  border-radius: 1.15rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  box-shadow: 0 10px 24px var(--shadow);
}

.btn-done {
  background: var(--paper);
  color: var(--ink);
}

.btn-winner {
  background: var(--gold);
  color: var(--ink);
}

.btn-done:disabled {
  opacity: 0.42;
  box-shadow: none;
}

.btn-done:not(:disabled):active,
.btn-winner:active {
  transform: scale(0.98);
}

.center-strip {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: var(--ink);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.35);
}

.puzzle-number {
  justify-self: start;
  width: 2.7rem;
  height: 4.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.puzzle-number span {
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  transform: rotate(-90deg);
  white-space: nowrap;
}

.center-mid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.center-mid-balance {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  pointer-events: none;
  visibility: hidden;
}

.btn-start {
  width: 6.2rem;
  height: 6.2rem;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transform: rotate(-45deg);
  box-shadow: 0 8px 18px rgba(242, 193, 78, 0.28);
}

.btn-swap,
.btn-settings {
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(246, 239, 228, 0.28);
  background: transparent;
  color: var(--paper);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-settings {
  justify-self: end;
}

.btn-swap svg {
  width: 1.55rem;
  height: 1.55rem;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transform: rotate(90deg);
}

.btn-settings-icon {
  display: block;
  width: 1.45rem;
  height: 1.45rem;
  background-color: currentColor;
  -webkit-mask: url('/icons/gear.svg') center / contain no-repeat;
  mask: url('/icons/gear.svg') center / contain no-repeat;
}

.btn-start:active {
  transform: scale(0.97) rotate(-45deg);
}

.btn-swap:active,
.btn-settings:active {
  transform: scale(0.97);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 16, 32, 0.72);
}

.settings-panel {
  position: relative;
  z-index: 1;
  width: min(22rem, 100%);
  max-height: calc(100dvh - 2.4rem);
  overflow-y: auto;
  border-radius: 1.25rem;
  background: #151c33;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
  padding: 1.1rem 1.15rem 1.25rem;
  color: var(--paper);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.settings-header h2 {
  margin: 0;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.btn-settings-close {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font-size: 1.6rem;
  line-height: 1;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.settings-label small {
  font-family: Outfit, sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.75;
  line-height: 1.3;
}

.settings-toggle {
  position: relative;
  cursor: pointer;
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  flex: 0 0 auto;
  width: 3.2rem;
  height: 1.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 160ms ease;
}

.toggle-ui::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 160ms ease;
}

.settings-toggle input:checked + .toggle-ui {
  background: var(--gold);
}

.settings-toggle input:checked + .toggle-ui::after {
  transform: translateX(1.35rem);
  background: var(--ink);
}

.settings-name-row input[type="text"] {
  width: 8.8rem;
  min-height: 2.4rem;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.85rem;
  padding: 0.4rem 0.7rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
  color-scheme: dark;
  caret-color: var(--gold);
}

.settings-name-row input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.38);
  font-weight: 600;
}

.settings-name-row input[type="text"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.settings-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.settings-stepper-value {
  min-width: 3.6rem;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
}

.btn-stepper {
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-stepper:active {
  transform: scale(0.96);
}

.btn-stepper:disabled {
  opacity: 0.35;
}

.btn-settings-action {
  width: 100%;
  min-height: 3.2rem;
  margin-top: 0.55rem;
  border: 0;
  border-radius: 1rem;
  background: var(--paper);
  color: var(--ink);
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.btn-settings-action:active {
  transform: scale(0.98);
}

.btn-settings-secondary {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.settings-confirm-title {
  margin: 0 0 0.45rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.settings-confirm-lead {
  margin: 0 0 1.15rem;
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0.82;
}

.disposition {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.disposition-title {
  margin: 0;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.disposition-title[hidden] {
  display: none;
}

.disposition-buttons {
  width: 100%;
  display: flex;
  gap: 0.75rem;
}

.disposition-buttons[hidden] {
  display: none;
}

.btn-disposition {
  flex: 1;
  min-height: 3.4rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 1.15rem;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  background: rgba(11, 16, 32, 0.18);
  color: var(--paper);
  box-shadow: none;
}

.btn-disposition.is-selected[data-choice="correct"] {
  background: var(--gold);
  color: var(--ink);
  border-color: rgba(242, 193, 78, 0.5);
  box-shadow: 0 10px 24px var(--shadow);
}

.btn-disposition.is-selected[data-choice="incorrect"] {
  background: var(--red-1);
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 24px var(--shadow);
}

.btn-disposition:active {
  transform: scale(0.98);
}

#transitionOverlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 32, 0.7);
  padding: 1.2rem;
  cursor: pointer;
}

.transitionText {
  max-width: 90vw;
  text-align: center;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: clamp(1.35rem, 5vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  padding: 1rem 1.2rem;
  border-radius: 1.25rem;
  background: rgba(11, 16, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.35);
  animation: transitionSpin 4.5s ease-in-out both;
  pointer-events: none;
}

.transitionText.is-infinite {
  animation: matchWinnerSpin 5s linear infinite;
  opacity: 1;
}

@keyframes transitionSpin {
  0% {
    transform: scale(0.96) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

@keyframes matchWinnerSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

#scoreFly {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1100;
  margin: 0;
  font-family: Fredoka, Outfit, sans-serif;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--gold);
  text-shadow:
    0 0 16px rgba(242, 193, 78, 0.9),
    0 4px 12px rgba(11, 16, 32, 0.45);
  pointer-events: none;
  user-select: none;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform, opacity;
}

@media (max-height: 700px) {
  .flow-title {
    font-size: 1.4rem;
    margin-bottom: 0.55rem;
  }

  .flow-name {
    margin-bottom: 0.55rem;
  }

  .flow-name input {
    min-height: 2.45rem;
  }

  .btn-difficulty,
  .btn-flow {
    min-height: 2.55rem;
    font-size: 1.02rem;
  }

  .card-grid span {
    min-height: 2.15rem;
    font-size: 0.98rem;
  }

  .btn-start {
    width: 5.1rem;
    height: 5.1rem;
    font-size: 1.2rem;
  }

  .puzzle-number {
    width: 2.3rem;
    height: 4.1rem;
  }

  .puzzle-number span {
    font-size: 1.4rem;
  }

  .puzzle-pick-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.28rem;
  }

  .puzzle-pick-grid button {
    min-height: 1.85rem;
    font-size: 0.82rem;
  }

  .solution-picker-title {
    font-size: 0.8rem;
  }

  .player-name {
    font-size: 1.35rem;
  }

  .player-score {
    min-width: 3.2rem;
    font-size: 1.9rem;
  }

  .countdown {
    font-size: clamp(3.4rem, 16vh, 6rem);
  }

  .puzzle-brief {
    width: min(94%, 15.5rem);
    padding: 0.65rem 0.8rem 0.7rem;
  }

  .puzzle-brief-type {
    font-size: 1.2rem;
  }

  .puzzle-brief-detail {
    font-size: 0.8rem;
  }

  .puzzle-brief-rows {
    margin-top: 0.5rem;
  }

  .puzzle-brief-row {
    font-size: 0.85rem;
  }

  .puzzle-brief-row strong {
    font-size: 1rem;
  }

  .btn-done,
  .btn-winner {
    min-height: 3.4rem;
    font-size: 1.3rem;
  }
}