:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8f73ff;
  --text: #fff;
  --muted: #aaadbe;
  --secondary: #2a2b3d;
  --red: #e5243f;
  --black: #1d1f33;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px;
  overflow-x: hidden;
}
.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.fc-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- HUD ---------- */
.fc-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.fc-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(18px, 2.6vw, 23px);
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.fc-logo {
  position: relative;
  width: 30px;
  height: 28px;
}
.fc-logo i {
  position: absolute;
  top: 2px;
  left: 8px;
  width: 16px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(160deg, #fff, #e6e3f5);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  transform-origin: 50% 100%;
}
.fc-logo i:nth-child(1) {
  transform: rotate(-22deg);
  background: linear-gradient(160deg, #ff6b83, #d61e41);
}
.fc-logo i:nth-child(2) {
  transform: rotate(0deg);
  background: linear-gradient(160deg, #a58cff, #6842ff);
}
.fc-logo i:nth-child(3) {
  transform: rotate(22deg);
  background:
    radial-gradient(circle at 50% 50%, #e5243f 0 3px, transparent 3.5px),
    linear-gradient(160deg, #fff, #e6e3f5);
}
.fc-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 rgba(0, 0, 0, 0.35);
  font-weight: 800;
}
.chip span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.chip strong {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chip-deal {
  background: linear-gradient(180deg, #7a58ff, #5632f0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 0 #3b1fb8;
}
.chip-deal span {
  color: #ddd4ff;
}
.chip.bump strong {
  display: inline-block;
  animation: bump 0.32s ease;
}
@keyframes bump {
  40% {
    transform: scale(1.3);
  }
}

/* ---------- stage & board ---------- */
.fc-stage {
  position: relative;
  border-radius: 20px;
  padding: 12px;
  background:
    radial-gradient(
      ellipse at 50% 0%,
      rgba(104, 66, 255, 0.28),
      transparent 60%
    ),
    radial-gradient(
      ellipse at 50% 120%,
      rgba(30, 180, 140, 0.18),
      transparent 60%
    ),
    linear-gradient(180deg, #1c1d2e, #16172a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  touch-action: none;
}
.fc-board {
  position: relative;
  margin: 0 auto;
  --cw: 70px;
  --ch: 98px;
  --r: calc(var(--cw) * 0.1);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.slot {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.slot-cell,
.slot-found {
  background: rgba(8, 9, 22, 0.45);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.07),
    inset 0 6px 14px rgba(0, 0, 0, 0.35);
}
.slot-found {
  background:
    radial-gradient(
      circle at 50% 45%,
      rgba(104, 66, 255, 0.3),
      transparent 70%
    ),
    rgba(8, 9, 22, 0.45);
  box-shadow:
    inset 0 0 0 2px rgba(143, 115, 255, 0.35),
    inset 0 6px 14px rgba(0, 0, 0, 0.35);
}
.slot-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--cw) * 0.42);
  font-weight: 900;
  color: rgba(196, 181, 255, 0.35);
  pointer-events: none;
}
.cell-mark::before {
  content: "";
  width: 36%;
  height: 26%;
  border-radius: 6px;
  border: 2px dashed rgba(255, 255, 255, 0.14);
}
.slot-col::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--r);
  background: rgba(8, 9, 22, 0.35);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
}
.slot:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
  z-index: 900;
}
.slot-col:focus-visible {
  outline-offset: 2px;
}
.slot.selected::before,
.slot-cell.selected,
.slot.hint-dst {
  box-shadow:
    0 0 0 3px #ffd166,
    0 0 18px rgba(255, 209, 102, 0.6);
}
.slot.hint-dst {
  animation: hintPulse 0.9s ease-in-out infinite;
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--r);
  transition: transform 0.24s cubic-bezier(0.25, 0.9, 0.3, 1.1);
  cursor: grab;
  touch-action: none;
  will-change: transform;
}
.card.no-anim {
  transition: none !important;
}
.card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.28s ease;
}
.card.facedown .card-inner {
  transform: rotateY(180deg);
}
.face,
.back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.face {
  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.9),
      rgba(255, 255, 255, 0) 40%
    ),
    linear-gradient(180deg, #ffffff, #efedf8);
  box-shadow:
    inset 0 0 0 1px rgba(20, 20, 50, 0.12),
    inset 0 -3px 0 rgba(20, 20, 60, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(0, 0, 0, 0.25);
}
.back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.09) 0 3px,
      transparent 3px 9px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.09) 0 3px,
      transparent 3px 9px
    ),
    linear-gradient(160deg, #8a6bff, #5a36f0 55%, #3f1fc4);
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.06) #fff,
    inset 0 0 0 calc(var(--cw) * 0.08) rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.35);
}
.back i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 22%;
  background: radial-gradient(circle at 35% 35%, #ffe08a, #ffb020 60%, #e08600);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.85),
    0 3px 8px rgba(0, 0, 0, 0.35);
}
.card.red {
  color: var(--red);
}
.card.black {
  color: var(--black);
}
.card svg {
  fill: currentColor;
  display: block;
}
.corner {
  position: absolute;
  top: calc(var(--ch) * 0.035);
  left: calc(var(--cw) * 0.07);
  display: flex;
  align-items: center;
  gap: calc(var(--cw) * 0.03);
  line-height: 1;
}
.corner b {
  font-size: calc(var(--cw) * 0.3);
  font-weight: 900;
  letter-spacing: -0.06em;
}
.corner-suit {
  width: calc(var(--cw) * 0.24);
  height: calc(var(--cw) * 0.24);
}
.corner-br {
  top: auto;
  left: auto;
  right: calc(var(--cw) * 0.07);
  bottom: calc(var(--ch) * 0.035);
  transform: rotate(180deg);
  opacity: 0.85;
}
.pip {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.12));
}
.pip-ace {
  width: 62%;
}
.pip svg {
  width: 100%;
  height: 100%;
}
.court {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 40%;
  bottom: 12%;
  border-radius: calc(var(--cw) * 0.1);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.card.red .court {
  background: linear-gradient(170deg, #ff7a8f, #e5243f);
}
.card.black .court {
  background: linear-gradient(170deg, #5b5f8a, #23253d);
}
.court-J {
  filter: hue-rotate(0deg);
}
.court b {
  font-size: calc(var(--cw) * 0.36);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.court .crown {
  position: absolute;
  top: -16%;
  width: 50%;
  fill: #ffc53d;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}
.court-J .crown {
  width: 36%;
  top: -10%;
}
.court-suit {
  position: absolute;
  bottom: 8%;
  width: 26%;
  height: auto;
  aspect-ratio: 1;
  fill: rgba(255, 255, 255, 0.85) !important;
}
.card.selected .face,
.card.hint-src .face {
  box-shadow:
    inset 0 0 0 1px rgba(20, 20, 50, 0.12),
    0 0 0 3px #ffd166,
    0 6px 16px rgba(255, 209, 102, 0.45);
}
.card.selected {
  filter: brightness(1.03);
}
.card.hint-src .face,
.card.hint-dst .face {
  animation: hintPulse 0.9s ease-in-out infinite;
}
.card.hint-dst .face {
  box-shadow:
    inset 0 0 0 1px rgba(20, 20, 50, 0.12),
    0 0 0 3px #5ee6c8,
    0 0 18px rgba(94, 230, 200, 0.6);
}
@keyframes hintPulse {
  50% {
    filter: brightness(1.12);
    transform: translateY(-2px);
  }
}
.card.dragging {
  cursor: grabbing;
}
.card.dragging .card-inner {
  transform: scale(1.05) rotate(-1.5deg);
}
.card.dragging .face {
  box-shadow:
    inset 0 0 0 1px rgba(20, 20, 50, 0.12),
    0 14px 26px rgba(0, 0, 0, 0.5);
}
.card.pop .card-inner {
  animation: pop 0.3s ease;
}
@keyframes pop {
  45% {
    transform: scale(1.08);
  }
}
.card.shake .card-inner {
  animation: shake 0.4s ease;
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}
.fc-board.won .card .card-inner {
  animation: hop 0.6s ease 2;
}
@keyframes hop {
  40% {
    transform: translateY(-14px) rotate(-4deg);
  }
}

/* ---------- fx ---------- */
.fc-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1500;
}
.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  animation: spark 0.6s ease-out forwards;
}
@keyframes spark {
  to {
    transform: translate(var(--tx), var(--ty)) scale(0.2);
    opacity: 0;
  }
}
.ring {
  position: absolute;
  border-radius: 14px;
  border: 3px solid #ffd166;
  transform: translate(-50%, -50%) scale(0.8);
  animation: ring 0.55s ease-out forwards;
}
@keyframes ring {
  to {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0;
  }
}
.fc-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1600;
}
.fc-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 1700;
  max-width: calc(100% - 24px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 21, 38, 0.94);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.08),
    0 8px 20px rgba(0, 0, 0, 0.45);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.fc-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.fc-toast.warn {
  box-shadow:
    0 0 0 2px rgba(255, 179, 71, 0.55),
    0 8px 20px rgba(0, 0, 0, 0.45);
}

/* ---------- overlay ---------- */
.fc-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 11, 26, 0.62);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s,
    visibility 0.25s;
}
.fc-overlay.show {
  opacity: 1;
  visibility: visible;
}
.fc-card {
  width: min(400px, 100%);
  padding: 22px 22px 18px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #25263a, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.55);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.fc-overlay.show .fc-card {
  transform: scale(1);
}
.fc-card h2 {
  margin: 6px 0 6px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.fc-overlay[data-mode="win"] .fc-card h2 {
  background: linear-gradient(180deg, #ffe08a, #ff9f1c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fc-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.45;
}
.fc-card-art {
  position: relative;
  height: 74px;
  margin: 0 auto;
  width: 120px;
}
.mini {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 46px;
  height: 64px;
  margin-left: -23px;
  border-radius: 7px;
  transform-origin: 50% 110%;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}
.mini-a {
  transform: rotate(-18deg) translateX(-6px);
  background:
    radial-gradient(circle at 50% 55%, #1d1f33 0 9px, transparent 9.5px),
    linear-gradient(160deg, #fff, #e7e4f4);
}
.mini-b {
  z-index: 1;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.12) 0 3px,
      transparent 3px 8px
    ),
    linear-gradient(160deg, #8a6bff, #4d2ae0);
  box-shadow:
    inset 0 0 0 3px #fff,
    0 6px 14px rgba(0, 0, 0, 0.45);
}
.mini-c {
  z-index: 2;
  transform: rotate(18deg) translateX(6px);
  background:
    radial-gradient(circle at 50% 55%, #e5243f 0 9px, transparent 9.5px),
    linear-gradient(160deg, #fff, #e7e4f4);
}
.fc-overlay.show .fc-card-art .mini {
  animation: fan 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
@keyframes fan {
  from {
    transform: rotate(0deg) translateY(10px);
  }
}
.fc-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}
.fc-results div {
  padding: 8px 6px;
  border-radius: 14px;
  background: var(--panel-2);
}
.fc-results dt {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.fc-results dd {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 900;
}
.fc-card-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.fc-picker {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.fc-picker label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.fc-picker-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.fc-picker input {
  width: 120px;
  min-width: 0;
  flex: 0 1 120px;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #0f1020;
  color: #fff;
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}
.fc-picker input:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 2px;
}
.btn-ghost {
  margin-top: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

/* ---------- buttons ---------- */
.fc-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 3px 0 #17182a;
  transition:
    transform 0.12s,
    filter 0.12s,
    box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 0 #17182a;
}
.btn:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-primary {
  background: linear-gradient(180deg, #7d5cff, #6842ff 60%, #5a33f5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 3px 0 #3b1fb8,
    0 8px 18px rgba(104, 66, 255, 0.35);
}
.btn-primary:active:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #3b1fb8;
}
.btn-big {
  min-height: 54px;
  padding: 0 44px;
  font-size: 20px;
}
.btn-icon {
  padding: 0 12px;
  font-size: 18px;
}
.btn-ico {
  font-size: 16px;
  line-height: 1;
}

.fc-help {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.6;
}
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #14152a;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 560px) {
  body {
    padding: 8px;
  }
  .fc-stage {
    padding: 8px 6px;
    border-radius: 16px;
  }
  .chip {
    padding: 5px 9px;
    gap: 4px;
  }
  .chip span {
    font-size: 9.5px;
  }
  .chip strong {
    font-size: 14px;
  }
  .chip-streak {
    display: none;
  }
  .fc-actions {
    gap: 6px;
  }
  .fc-actions .btn {
    padding: 0 12px;
    font-size: 14px;
  }
  .fc-help {
    font-size: 11.5px;
  }
  .corner b {
    font-size: calc(var(--cw) * 0.34);
  }
  .corner-suit {
    width: calc(var(--cw) * 0.26);
    height: calc(var(--cw) * 0.26);
  }
  .corner-br {
    display: none;
  }
}

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