:root {
  --primary: #6487fa;
  --bg: #ffffff;
  --bg-soft: #f8f8f8;
  --text: #1e1f24;
  --text-secondary: #848691;
  --text-tertiary: #b7b9c1;
  --stage-w: 788px;
  --stage-h: 492px;
  --card-w: 73px;
  --card-h: 106px;
  --card-gap: 18px;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #f2f6ff, #eef2ff 55%, #f8f8f8);
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  padding: 18px 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.page-header {
  width: min(980px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.hint-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 20px rgba(30, 31, 36, 0.15);
  text-align: center;
}

.hint-bar.is-warn {
  border: 1px solid rgba(224, 85, 85, 0.28);
}

.hint-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.hint-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.row-hint {
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-block {
  text-align: center;
}

.title-block h1 {
  margin: 6px 0 4px;
  font-size: 28px;
  font-weight: 700;
  font-family: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
}

.title-block p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.eyebrow {
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 2px;
}

.date-badge {
  background: var(--bg);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow: 0 8px 24px rgba(30, 31, 36, 0.08);
}

.stage-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.stage-shell {
  position: relative;
}

.stage-shell::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 30px;
  background: repeating-linear-gradient(
    105deg,
    #b37b48 0 9px,
    #9a673a 9px 18px,
    #845730 18px 27px,
    #a87243 27px 36px
  );
  box-shadow:
    inset 0 0 0 2px rgba(255, 228, 183, 0.24),
    inset 0 0 0 6px rgba(90, 56, 30, 0.34),
    0 14px 28px rgba(56, 35, 20, 0.24);
  pointer-events: none;
  z-index: 0;
}

.stage {
  width: var(--stage-w);
  height: var(--stage-h);
  border-radius: 20px;
  padding: 10px;
  background: radial-gradient(circle at 30% 20%, #3f8d7e, #1f5b4f 60%, #15443c);
  box-shadow: 0 24px 40px rgba(17, 34, 34, 0.35);
  overflow: hidden;
  transform-origin: top left;
  animation: stage-in 0.6s ease;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.landlord-zone {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.landlord-title {
  font-size: 12px;
  color: #ecf5ef;
  background: rgba(14, 39, 33, 0.45);
  border: 1px solid rgba(233, 245, 238, 0.28);
  border-radius: 999px;
  padding: 3px 8px;
}

.landlord-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.landlord-cards .card {
  box-shadow: 0 6px 12px rgba(16, 26, 30, 0.26);
}

.type-gallery {
  width: min(788px, 96vw);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 14px 28px rgba(30, 31, 36, 0.08);
}

.type-gallery--overlay {
  width: min(600px, 92vw);
  margin: 12px auto 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 24px rgba(30, 31, 36, 0.08);
  padding: 10px;

@media (max-width: 520px) {
  .page {
    padding-inline: 10px;
  }

  .page-header,
  .rules-panel,
  .type-gallery,
  .type-gallery--overlay,
  .start-panel {
    width: calc(100vw - 20px);
    max-width: 100%;
  }

  .rules-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .rules-text {
    text-align: center;
  }

  .rules-panel .btn {
    width: 100%;
  }
}
  border-radius: 12px;
}

.gallery-head {
  text-align: center;
}

.gallery-head h2 {
  margin: 0;
  font-size: 22px;
  color: var(--text);
  font-family: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
}

.gallery-head p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.type-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.type-gallery--overlay .type-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

.type-card {
  display: block;
  width: 100%;
  text-align: left;
  outline: none;
  border: none;
  background: transparent;
  padding: 0;
  perspective: 1600px;
  min-height: 148px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.35s ease;
}

.type-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.type-card.is-active {
  filter: drop-shadow(0 16px 24px rgba(34, 90, 82, 0.3));
}

.type-card:hover:not(.is-active) {
  filter: drop-shadow(0 12px 20px rgba(30, 31, 36, 0.18));
}

.type-card-inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 140px;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.2, 0.75, 0.15, 1.2);
  will-change: transform;
}

.type-card.is-flipped .type-card-inner {
  transform: rotateY(180deg) rotateX(10deg) translateZ(14px);
}

.type-card.is-active:not(.is-flipped) .type-card-inner {
  transform: rotateX(8deg) translateZ(12px);
}

.type-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 10px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 18px rgba(30, 31, 36, 0.1);
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.type-card:hover .type-face.front,
.type-card:hover .type-face.back {
  box-shadow: 0 16px 28px rgba(30, 31, 36, 0.2);
}

.type-card:hover:not(.is-active) .type-face.front,
.type-card:hover:not(.is-active) .type-face.back {
  border-color: rgba(100, 135, 250, 0.35);
}

.type-face.front {
  background: #ffffff;
  border: 1px solid #e4e8f4;
  transform: translateZ(18px);
}

.type-face.back {
  background: #f8f8f8;
  border: 1px solid #dfe4f6;
  transform: rotateY(180deg) translateZ(18px);
}

.type-card.is-active .type-face.front,
.type-card.is-active .type-face.back {
  border-color: rgba(100, 135, 250, 0.62);
  animation: type-card-glow 1.6s ease-in-out infinite;
}

.type-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.type-front-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.type-front-text {
  min-width: 0;
  flex: 1;
}

.type-example {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
}

.type-tip {
  font-size: 11px;
  color: var(--text-tertiary);
}

.type-detail {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.mini-cards {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-shrink: 0;
  min-height: 56px;
  max-width: 58%;
  transform-origin: right center;
  transition: transform 0.25s ease;
}

.mini-card {
  width: 34px;
  height: 50px;
  background: #ffffff;
  border: 1px solid #d7ddec;
  border-radius: 9px;
  box-shadow: 0 5px 10px rgba(30, 31, 36, 0.14);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 3px 1px;
  margin-left: -11px;
  transition: margin-left 0.25s ease, transform 0.25s ease;
}

.mini-card:first-child {
  margin-left: 0;
}

.type-card:hover .mini-cards {
  transform: translateX(-12px) scale(1.28);
}

.type-card:hover .mini-card {
  margin-left: 2px;
  transform: translateY(-3px);
}

.type-card:hover .mini-card:first-child {
  margin-left: 0;
}

.mini-card.red {
  color: #d85353;
}

.mini-card.joker {
  background: linear-gradient(160deg, #ffffff, #f2f5ff);
}

.mini-rank {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.mini-suit {
  font-size: 14px;
  line-height: 1;
}

.stage[data-size="compact"] {
  --stage-w: 380px;
  --stage-h: 456px;
  --card-w: 55px;
  --card-h: 80px;
  --card-gap: 12px;
}

.table {
  height: 100%;
  padding: 10px 14px 16px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
}

.stage[data-size="compact"] .table {
  padding: 8px 10px 12px;
  gap: 8px;
}

.row {
  display: grid;
  gap: 8px;
}

.row-middle {
  grid-template-columns: 1fr;
}

.row-bottom {
  grid-template-columns: 1fr;
}

.center-play {
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-area {
  display: grid;
  gap: 8px;
  width: 100%;
  justify-items: center;
}

.play-stack {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.opponent-hint {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 6px 10px;
  text-align: center;
  box-shadow: 0 10px 20px rgba(30, 31, 36, 0.15);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.opponent-hint.show {
  opacity: 1;
  transform: translateY(0);
}

.opponent-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.opponent-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.play-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.play-empty {
  font-size: 12px;
  color: var(--text-tertiary);
}

.play-empty.hidden {
  display: none;
}

.hand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: calc(var(--card-h) + 60px);
  gap: 8px;
}

.hand-cards {
  align-items: flex-end;
}

.card-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.card-row .card + .card {
  margin-left: calc(-1 * (var(--card-w) - var(--card-gap)));
}

.controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 16px rgba(100, 135, 250, 0.3);
}

.btn.ghost {
  background: #e9ecf7;
  color: var(--text);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.validation-text {
  font-size: 12px;
  color: #eef1ff;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 42px 10px 14px;
  min-width: 240px;
  max-width: min(420px, 90vw);
  box-shadow: 0 16px 32px rgba(30, 31, 36, 0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-6px);
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.toast-body {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.toast-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.2s ease;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 22, 0.45);
}

.modal-card {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 20px;
  width: min(340px, 86vw);
  box-shadow: 0 20px 36px rgba(30, 31, 36, 0.3);
  text-align: center;
  z-index: 1;
}

.start-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 22, 0.58);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  z-index: 20000;
  transition: opacity 0.36s ease;
}

.start-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.start-overlay.is-hiding {
  opacity: 0;
  pointer-events: none;
}

.start-panel {
  width: min(820px, 92vw);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 24px 46px rgba(12, 18, 28, 0.4);
  animation: panel-rise 0.32s ease;
  max-height: 86vh;
  overflow-y: auto;
}

.start-step.hidden {
  display: none;
}

.start-panel h2 {
  margin: 0;
  font-size: 22px;
  color: var(--text);
  font-family: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
}

.start-subtitle {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.intro-module {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 248, 255, 0.98));
  border: 1px solid rgba(147, 162, 196, 0.22);
  box-shadow: 0 10px 24px rgba(46, 58, 89, 0.06);
}

.intro-module h3 {
  margin: 0;
  font-size: 15px;
  color: var(--primary);
  font-family: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
}

.intro-module p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.intro-module ol {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.intro-module li + li {
  margin-top: 6px;
}

.role-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.role-card {
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(160deg, #ffffff, #f4f7ff);
  border: 1px solid #dfe5f6;
}

.role-card h3 {
  margin: 0;
  font-size: 14px;
  color: var(--primary);
}

.role-card p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.start-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.rules-panel {
  width: min(788px, 70vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 28px rgba(30, 31, 36, 0.08);
}

.rules-text h2 {
  margin: 0;
  font-size: 18px;
  font-family: "ZCOOL XiaoWei", "STKaiti", "KaiTi", serif;
  color: var(--text);
}

.rules-text p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--bg);
  border-radius: 11px;
  border: 1px solid #e2e4ee;
  padding: 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 6px 12px rgba(30, 31, 36, 0.12);
  user-select: none;
}

.card.facedown {
  background: linear-gradient(145deg, #3e618f, #2c476c);
  border-color: #233f63;
}

.card.facedown::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.12) 0 4px,
    rgba(255, 255, 255, 0.04) 4px 8px
  );
}

.card.small {
  width: 37px;
  height: 53px;
  padding: 4px;
  border-radius: 8px;
}

.card .card-corner {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.card.small .card-corner {
  font-size: 11px;
}

.card .card-center {
  font-size: 22px;
  text-align: center;
  opacity: 0.9;
}

.card.small .card-center {
  font-size: 16px;
}

.card.red .card-corner,
.card.red .card-center {
  color: #e05555;
}

.card.selected {
  border-color: var(--primary);
  transform: translateY(-20px);
}

.card:hover {
  transform: translateY(-13px);
  z-index: 2;
}

.card.selected:hover {
  transform: translateY(-22px);
}

.card.joker {
  background: linear-gradient(160deg, #ffffff, #f4f6ff);
}

.card.joker .card-center {
  font-size: 24px;
}

.card.wild {
  background: linear-gradient(160deg, #fff3e0, #ffe0b2);
  border: 2px solid #ffb74d;
  box-shadow: 0 6px 12px rgba(255, 152, 0, 0.2),
    inset 0 0 8px rgba(255, 193, 7, 0.1);
  animation: wild-glow 1.2s ease-in-out infinite;
}

.card.wild .card-corner,
.card.wild .card-center {
  color: #e65100;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}

.mini-card.wild {
  background: linear-gradient(160deg, #fff3e0, #ffe0b2);
  border: 1px solid #ffb74d;
}

.mini-card.wild .mini-rank,
.mini-card.wild .mini-suit {
  color: #e65100;
  font-weight: 700;
}

@keyframes wild-glow {
  0% {
    box-shadow: 0 6px 12px rgba(255, 152, 0, 0.2),
      inset 0 0 8px rgba(255, 193, 7, 0.1);
  }
  50% {
    box-shadow: 0 8px 16px rgba(255, 152, 0, 0.35),
      inset 0 0 12px rgba(255, 193, 7, 0.2);
  }
  100% {
    box-shadow: 0 6px 12px rgba(255, 152, 0, 0.2),
      inset 0 0 8px rgba(255, 193, 7, 0.1);
  }
}

.card-pass {
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.page-footer {
  font-size: 12px;
  color: var(--text-tertiary);
}

@keyframes stage-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

@keyframes type-card-glow {
  0% {
    box-shadow: 0 10px 20px rgba(100, 135, 250, 0.12);
  }
  50% {
    box-shadow: 0 16px 28px rgba(100, 135, 250, 0.3);
  }
  100% {
    box-shadow: 0 10px 20px rgba(100, 135, 250, 0.12);
  }
}

@media (max-width: 520px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .type-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .type-card,
  .type-card-inner {
    min-height: 138px;
  }

  .mini-cards {
    min-height: 49px;
    max-width: 56%;
  }

  .mini-card {
    width: 30px;
    height: 45px;
    margin-left: -10px;
  }

  .mini-rank {
    font-size: 10px;
  }

  .mini-suit {
    font-size: 12px;
  }

  .landlord-zone {
    left: 8px;
    top: 8px;
    gap: 4px;
  }

  .landlord-title {
    font-size: 11px;
    padding: 2px 6px;
  }

  .start-panel {
    padding: 14px 12px;
  }

  .start-panel h2 {
    font-size: 20px;
  }

  .role-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
