:root {
  --red: #ee293d;
  --orange: #f36e3e;
  --yellow: #fee74b;
  --pink: #e987b7;
  --blue: #4abeee;
  --navy: #424ca0;
  --cream: #fff3e7;
  --black: #000000;
  --shadow: rgba(66, 76, 160, 0.18);
  --card-ratio: 211 / 299;
  --title-font: "ringold-soft", "Arial Rounded MT Bold", sans-serif;
  --body-font: "national-park", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--blue);
  color: var(--black);
  font-family: var(--body-font);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 243, 231, 0.18), transparent 18%),
    radial-gradient(circle at 88% 20%, rgba(254, 231, 75, 0.12), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(66, 76, 160, 0.16), transparent 28%);
}

body::after {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 28%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.06), transparent 24%);
  opacity: 0.8;
}

.page {
  position: relative;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.hero {
  max-width: 980px;
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 10px;
  color: var(--yellow);
  font-family: var(--title-font);
  font-size: clamp(3rem, 6vw, 5.6rem);
  line-height: 0.92;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hero p {
  margin: 0;
  max-width: 960px;
  color: var(--cream);
  font-size: clamp(0.92rem, 1.05vw, 1.08rem);
  line-height: 1.45;
}

.panel {
  border: 16px solid var(--navy);
  border-radius: 34px;
  background: var(--cream);
  box-shadow: 0 16px 34px var(--shadow);
}

.panel.hidden {
  display: none;
}

.setup {
  padding: 0;
  overflow: hidden;
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
}

.setup-form,
.setup-roster {
  padding: 42px 42px 36px;
}

.setup-form {
  min-height: 460px;
  border-right: 16px solid var(--navy);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.setup-roster {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-heading h2,
.roster-top h2 {
  margin: 0 0 12px;
  color: var(--navy);
  font-family: var(--title-font);
  font-size: clamp(1.95rem, 3vw, 2.9rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.section-heading p {
  margin: 0;
  font-size: 0.98rem;
}

.player-input {
  display: grid;
  gap: 22px;
  max-width: 620px;
  margin-top: 28px;
}

.player-input input {
  width: 100%;
  min-height: 60px;
  padding: 14px 22px;
  border: 2px solid var(--black);
  border-radius: 999px;
  background: transparent;
  color: var(--black);
  font-family: var(--body-font);
  font-size: 1.02rem;
  font-style: italic;
}

.player-input input::placeholder {
  color: rgba(0, 0, 0, 0.9);
}

.action-button {
  min-height: 60px;
  padding: 12px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: var(--yellow);
  font-family: var(--title-font);
  font-size: clamp(1.3rem, 1.6vw, 1.9rem);
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.12);
}

.action-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.action-button:disabled {
  background: #b3adad;
  color: var(--yellow);
  cursor: not-allowed;
  opacity: 1;
  box-shadow: none;
  transform: none;
}

.player-input .action-button {
  justify-self: center;
  min-width: 280px;
}

.roster-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.roster-top .action-button {
  min-width: 210px;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.player-list li {
  min-height: 64px;
  padding: 14px 16px 14px 24px;
  border-radius: 999px;
  background: var(--pink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 1.18rem;
}

.player-list button {
  min-width: 36px;
  height: 36px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--cream);
  color: var(--navy);
  font-family: var(--title-font);
  font-size: 0.95rem;
  cursor: pointer;
}

.game {
  padding: 16px 18px;
}

.game-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.info-rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 8px 8px 14px;
}

.turn-label {
  font-size: 0.94rem;
  line-height: 1.2;
}

.turn-block h2 {
  margin: 2px 0 0;
  font-size: clamp(2rem, 2.4vw, 2.8rem);
  line-height: 0.95;
  font-weight: 700;
}

.deck-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.deck {
  position: relative;
  width: min(170px, 100%);
  aspect-ratio: var(--card-ratio);
  margin-bottom: 34px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.deck:disabled {
  cursor: not-allowed;
}

.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: center / cover no-repeat url("asset/ui/ui_cardback.png");
  box-shadow: none;
}

.deck-card:nth-child(1) {
  transform: translateY(24px);
}

.deck-card:nth-child(2) {
  transform: translateY(16px);
}

.deck-card:nth-child(3) {
  transform: translateY(8px);
}

.deck-card.top {
  transform: translateY(0);
}

.deck.is-shuffling .deck-card:nth-child(1) {
  animation: shuffleA 0.6s ease;
}

.deck.is-shuffling .deck-card:nth-child(2) {
  animation: shuffleB 0.6s ease;
}

.deck.is-shuffling .deck-card:nth-child(3) {
  animation: shuffleC 0.6s ease;
}

.deck-hint {
  max-width: 220px;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.3;
}

.next-button {
  width: 100%;
  margin-top: auto;
}

.play-stage {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 4px 8px 8px 0;
}

.stage-top {
  display: flex;
  justify-content: center;
}

.phase-badge {
  display: inline-block;
  padding: 0;
  background: transparent;
  font-size: 1.32rem;
  font-weight: 700;
  text-align: center;
}

.card-area {
  min-width: 0;
}

.card-carousel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.carousel-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-top: min(38vw, 170px);
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: var(--cream);
  font-size: 1.6rem;
  cursor: pointer;
}

.carousel-arrow:disabled {
  background: #b3adad;
  color: rgba(255, 255, 255, 0.75);
  cursor: not-allowed;
}

.card-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}

.card-track {
  display: contents;
}

.card-choice {
  position: relative;
  width: 100%;
  aspect-ratio: var(--card-ratio);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 0;
}

.card-choice:hover:not(.is-disabled) {
  transform: translateY(-6px);
}

.card-choice.is-disabled {
  pointer-events: none;
}

.card-choice.is-muted {
  opacity: 0.28;
}

.card-choice.is-selected {
  z-index: 2;
  aspect-ratio: auto;
  min-height: 100%;
}

.card-choice.is-hidden {
  display: none;
}

.card-choice.is-selected .card-motion,
.card-choice.is-selected .card,
.card-choice.is-selected .card-face {
  position: static;
  inset: auto;
  height: 100%;
}

.card-choice.is-selected .card {
  box-shadow: none;
}

.card-choice.is-selected .card-face {
  overflow: visible;
}

.card-choice.is-selected .card-front {
  background: transparent;
  border: 0;
  padding: 4px 6px 4px 0;
}

.card-choice.is-selected .card-copy {
  justify-content: flex-start;
}

.card-choice.is-selected .card-question-en {
  margin-top: 18px;
}

.card-choice.is-selected .card-title-vi {
  font-size: clamp(1.35rem, 1.9vw, 2rem);
}

.card-choice.is-selected .card-title-en {
  font-size: clamp(1.1rem, 1.45vw, 1.5rem);
}

.card-choice.is-selected .card-question-vi {
  font-size: clamp(1.3rem, 1.95vw, 2.05rem);
  line-height: 1.24;
}

.card-choice.is-selected .card-question-en {
  font-size: clamp(1.05rem, 1.4vw, 1.38rem);
  line-height: 1.32;
}

.card-motion {
  position: absolute;
  inset: 0;
}

.card-motion.is-exit {
  animation: cardExit 0.45s ease forwards;
}

.card-motion.is-enter {
  animation: cardEnter 0.5s ease forwards;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  transform: rotateY(0deg);
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
  box-shadow: 0 16px 28px rgba(66, 76, 160, 0.18);
}

.card.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  overflow: hidden;
}

.card-back {
  background: center / cover no-repeat url("asset/ui/ui_cardback.png");
}

.card-front {
  background: var(--cream);
  border: 6px solid #3737d7;
  padding: clamp(16px, 1.6vw, 26px);
  transform: rotateY(180deg);
}

.card-copy {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title-vi {
  margin: 0;
  font-size: clamp(1rem, 1.4vw, 1.55rem);
  line-height: 1.05;
  font-weight: 700;
}

.card-title-en {
  margin: 0 0 12px;
  font-size: clamp(0.92rem, 1.1vw, 1.3rem);
  line-height: 1.15;
  font-style: italic;
}

.card-question-vi {
  margin: 0;
  font-size: clamp(0.98rem, 1.18vw, 1.35rem);
  line-height: 1.3;
  font-weight: 700;
}

.card-question-en {
  margin: auto 0 0;
  font-size: clamp(0.88rem, 1vw, 1.1rem);
  line-height: 1.35;
  font-style: italic;
}

.round-panel {
  min-height: 100%;
  padding: 10px 10px 8px;
  border-radius: 22px;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.round-panel.hidden {
  display: none;
}

.round-panel.in-grid {
  grid-column: 2 / span 2;
  grid-row: 1;
}

.round-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  font-size: 0.94rem;
}

.round-pill {
  display: none;
}

.checklist {
  display: grid;
  gap: 10px;
}

.answer-item {
  min-height: 52px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--pink);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.92rem;
}

.answer-item input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--navy);
}

.round-panel.is-complete .answer-item {
  background: #d2f3cc;
}

@keyframes shuffleA {
  0% {
    transform: translateY(24px);
  }
  50% {
    transform: translate(-10px, 34px) rotate(-4deg);
  }
  100% {
    transform: translateY(24px);
  }
}

@keyframes shuffleB {
  0% {
    transform: translateY(16px);
  }
  50% {
    transform: translate(10px, 4px) rotate(3deg);
  }
  100% {
    transform: translateY(16px);
  }
}

@keyframes shuffleC {
  0% {
    transform: translateY(8px);
  }
  50% {
    transform: translate(-6px, 20px) rotate(-3deg);
  }
  100% {
    transform: translateY(8px);
  }
}

@keyframes cardExit {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-70px) scale(0.95);
    opacity: 0;
  }
}

@keyframes cardEnter {
  0% {
    transform: translateY(28px) scale(0.96);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 1200px) {
  .page {
    padding-inline: 22px;
  }

  .game-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .card-grid {
    gap: 18px;
  }
}

@media (max-width: 900px) {
  .page {
    padding-top: 26px;
  }

  .hero h1 {
    font-size: clamp(3.1rem, 12vw, 5.3rem);
  }

  .panel {
    border-width: 14px;
    border-radius: 30px;
  }

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

  .setup-form {
    min-height: auto;
    border-right: 0;
    border-bottom: 14px solid var(--navy);
  }

  .setup-form,
  .setup-roster {
    padding: 28px 24px;
  }

  .info-rail {
    padding: 10px 10px 0;
  }

  .play-stage {
    padding: 0 10px 10px;
  }

  .deck {
    width: min(180px, 56vw);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 18px 14px 32px;
  }

  .hero {
    margin-bottom: 20px;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .section-heading h2,
  .roster-top h2 {
    font-size: 2.2rem;
  }

  .roster-top {
    flex-direction: column;
    align-items: stretch;
  }

  .roster-top .action-button,
  .player-input .action-button {
    width: 100%;
    min-width: 0;
  }

  .game {
    padding: 16px 14px 18px;
  }

  .turn-block h2 {
    font-size: 2.4rem;
  }

  .card-carousel {
    gap: 10px;
  }

  .carousel-arrow {
    display: inline-flex;
  }

  .card-grid {
    display: block;
    overflow: hidden;
  }

  .card-track {
    display: flex;
    align-items: flex-start;
    width: 100%;
    transition: transform 0.35s ease;
  }

  .card-choice {
    flex: 0 0 100%;
  }

  .card-choice:hover:not(.is-disabled),
  .card-choice.is-selected {
    transform: none;
  }

  .card-choice.is-selected {
    flex: 0 0 100%;
  }

  .round-panel {
    margin-top: 16px;
    padding: 0;
  }

  .round-panel.in-grid {
    grid-column: auto;
    grid-row: auto;
  }

  .round-header {
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.95rem;
  }

  .round-pill {
    min-height: 46px;
    padding-inline: 18px;
  }

  .answer-item {
    min-height: 64px;
    padding: 10px 18px;
    font-size: 1.05rem;
  }

  .card-front {
    padding: 22px 18px;
  }

  .card-choice.is-selected .card-front {
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
