:root {
  --pink: #ff8aa1;
  --pink-dark: #e96f8a;
  --pink-soft: #fff0f4;
  --gold: #ffe25b;
  --gold-dark: #6f5b00;
  --gold-soft: #fff9d9;
  --white: #ffffff;
  --cream: #fffdf6;
  --ink: #342f31;
  --muted: #756e71;
  --line: #eadfe2;
  --shadow: 0 22px 65px rgba(100, 69, 78, 0.14);
  --shadow-soft: 0 12px 34px rgba(100, 69, 78, 0.09);
  --content-width: 940px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 138, 161, 0.17), transparent 28rem),
    radial-gradient(circle at 92% 18%, rgba(255, 226, 91, 0.21), transparent 28rem),
    linear-gradient(180deg, #fff8fa 0%, var(--cream) 60%, #fff 100%);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC",
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.background-shape {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.shape-pink {
  top: 170px;
  left: -120px;
  width: 260px;
  height: 260px;
  border: 38px solid rgba(255, 138, 161, 0.09);
}

.shape-gold {
  right: -100px;
  bottom: 90px;
  width: 245px;
  height: 245px;
  background: rgba(255, 226, 91, 0.1);
}

.game-header {
  display: grid;
  width: min(calc(100% - 40px), 1160px);
  margin: 0 auto;
  padding: 22px 0;
  align-items: center;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
}

.back-link, .text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.back-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-self: start;
}

.text-button { justify-self: end; }

.back-link:hover, .text-button:hover { color: var(--pink-dark); }

button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 3px solid rgba(255, 138, 161, 0.28);
  outline-offset: 4px;
}

.mini-brand {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 850;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.brand-dot-pink { background: var(--pink); }
.brand-dot-gold { background: var(--gold); }

.game-shell {
  width: min(calc(100% - 40px), var(--content-width));
  margin: 0 auto;
  padding: 50px 0 90px;
}

.setup-intro {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--pink-dark);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.setup-intro h1,
.secret-stage h1,
.sort-stage h1,
.result-stage h1,
.result-card h1 {
  margin: 0;
  font-size: clamp(2.35rem, 7vw, 4.7rem);
  line-height: 1.02;
  letter-spacing: -0.06em;
}

.setup-intro > p:last-child {
  max-width: 650px;
  margin: 24px auto 0;
  color: var(--muted);
}

.choice-section { margin-top: 48px; }

.section-label {
  display: flex;
  margin-bottom: 16px;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}

.section-label span {
  color: var(--pink-dark);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.section-label h2 { margin: 0; font-size: 1.25rem; }

.choice-grid {
  display: grid;
  gap: 15px;
}

.choice-grid-round,
.choice-grid-role {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-card {
  position: relative;
  cursor: pointer;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card-inner {
  display: flex;
  min-height: 140px;
  padding: 24px 22px;
  flex-direction: column;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-soft);
  transition: 180ms ease;
}

.choice-card strong,
.choice-card small { display: block; }

.choice-card small {
  margin-top: 5px;
  color: var(--muted);
}

.choice-card input:checked + .choice-card-inner {
  border-color: var(--pink);
  background: var(--pink-soft);
  transform: translateY(-2px);
}

.start-panel,
.select-card,
.toggle-card,
.role-banner,
.theme-box {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-soft);
}

.start-panel {
  display: grid;
  margin-top: 48px;
  padding: 28px;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 24px;
  align-items: center;
}

.start-panel h2 { margin: 0; font-size: 1.8rem; }
.start-panel p:last-child { margin: 5px 0 0; color: var(--muted); }

.start-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 9px;
}

.start-button,
.start-main-button,
.button {
  min-height: 50px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.start-pink, .button-primary, .start-main-button {
  color: var(--white);
  background: var(--pink);
}

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

.start-random, .button-secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--white);
}

.start-main-button {
  display: flex;
  width: min(100%, 420px);
  margin: 40px auto 0;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.round-progress { margin-bottom: 24px; }

.round-copy {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  margin-top: 9px;
  border-radius: 999px;
  background: rgba(52,47,49,.08);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  transition: width 220ms ease;
}

.balance-card,
.secret-number-card,
.result-card,
.result-stage,
.sort-stage,
.secret-stage {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  color: var(--pink-dark);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .1em;
}

.balance-options {
  display: grid;
  margin-top: 28px;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 14px;
  align-items: stretch;
}

.balance-option {
  display: flex;
  min-height: 220px;
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  text-align: center;
}

.balance-option-pink { background: var(--pink-soft); }
.balance-option-gold { background: var(--gold-soft); }

.balance-option span {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--pink);
  font-weight: 900;
}

.balance-option-gold span {
  color: var(--ink);
  background: var(--gold);
}

.balance-option strong {
  margin-top: 18px;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.35;
}

.balance-or {
  display: grid;
  align-items: center;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 900;
}

.card-tip,
.sort-hint {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
}

.play-actions,
.stage-actions,
.result-actions,
.punishment-actions {
  display: flex;
  margin-top: 20px;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.centered-text-button {
  width: 100%;
  justify-self: center;
  text-align: center;
}

.result-card { text-align: center; }

.result-grid,
.order-result-grid {
  display: grid;
  margin: 26px 0;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}

.result-grid > div,
.order-result-grid > div {
  padding: 18px;
  border-radius: 18px;
  background: var(--pink-soft);
}

.result-grid span,
.result-grid strong,
.order-result-grid span,
.order-result-grid strong {
  display: block;
}

.result-grid span,
.order-result-grid span {
  color: var(--muted);
  font-size: .76rem;
}

.result-grid strong,
.order-result-grid strong {
  margin-top: 5px;
  font-size: 1.3rem;
}

.select-card {
  display: block;
  padding: 20px;
}

.select-card > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.select-card select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--white);
}

.toggle-card {
  display: flex;
  padding: 20px;
  gap: 13px;
  align-items: flex-start;
  cursor: pointer;
}

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

.custom-checkbox {
  display: grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 9px;
  color: transparent;
}

.toggle-card input:checked + .custom-checkbox {
  border-color: var(--pink);
  color: var(--white);
  background: var(--pink);
}

.toggle-card strong,
.toggle-card small { display: block; }

.toggle-card small {
  margin-top: 4px;
  color: var(--muted);
}

.role-banner {
  display: grid;
  margin-bottom: 22px;
  padding: 18px;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}

.role-banner > div {
  padding: 12px;
  border-radius: 16px;
  background: var(--pink-soft);
  text-align: center;
}

.role-banner > div:last-child { background: var(--gold-soft); }

.role-banner span,
.role-banner strong { display: block; }
.role-banner span { color: var(--muted); font-size: .72rem; }
.role-banner strong { margin-top: 3px; }

.secret-stage,
.sort-stage,
.result-stage { text-align: center; }

.theme-box {
  margin: 24px auto 0;
  padding: 16px;
  text-align: center;
}

.theme-box span,
.theme-box strong,
.theme-box small { display: block; }

.theme-box span,
.theme-box small { color: var(--muted); }
.theme-box strong { margin: 4px 0; font-size: 1.15rem; }

.secret-number-card {
  max-width: 430px;
  margin: 24px auto 0;
  text-align: center;
}

.secret-number-card > span {
  color: var(--pink-dark);
  font-size: 1rem;
  font-weight: 900;
}

.secret-number-card > strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
  filter: blur(10px);
}

.secret-number-card > strong.is-visible { filter: none; }

.secret-number-card p {
  margin: 18px 0 0;
  color: var(--muted);
}

.label-buttons {
  display: grid;
  max-width: 520px;
  margin: 24px auto 0;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}

.label-buttons button {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--white);
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.label-buttons button:disabled {
  opacity: .35;
  cursor: default;
}

.chosen-order {
  display: grid;
  max-width: 520px;
  margin: 18px auto 0;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}

.chosen-order span {
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255,255,255,.55);
  font-weight: 900;
}

.chosen-order span.is-filled {
  border-style: solid;
  border-color: var(--pink);
  color: var(--ink);
  background: var(--pink-soft);
}

.number-reveal-list {
  display: grid;
  margin-top: 20px;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}

.number-reveal-list > div {
  padding: 15px;
  border-radius: 16px;
  background: var(--gold-soft);
}

.number-reveal-list span,
.number-reveal-list strong { display: block; }

.number-reveal-list strong {
  margin-top: 4px;
  font-size: 1.35rem;
}

.punishment-panel {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid rgba(255,138,161,.25);
  border-radius: 22px;
  background: var(--pink-soft);
}

.punishment-panel > span,
.punishment-panel > strong { display: block; }

.punishment-panel > span {
  color: var(--pink-dark);
  font-size: .76rem;
  font-weight: 900;
}

.punishment-panel > strong {
  margin-top: 9px;
  font-size: 1.15rem;
}

.help-dialog {
  width: min(calc(100% - 30px), 620px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}

.help-dialog::backdrop {
  background: rgba(52,47,49,.35);
  backdrop-filter: blur(5px);
}

.dialog-panel { padding: 26px; }

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.dialog-heading h2 { margin: 0; }

.dialog-heading button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--pink-soft);
  cursor: pointer;
}

.dialog-panel p { color: var(--muted); }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  max-width: min(calc(100% - 30px), 520px);
  padding: 11px 18px;
  border-radius: 999px;
  color: var(--white);
  background: var(--ink);
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .game-header {
    grid-template-columns: 1fr auto;
  }

  .mini-brand {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .back-link { grid-column: 1; grid-row: 2; }
  .text-button { grid-column: 2; grid-row: 2; }

  .game-shell { padding-top: 34px; }

  .choice-grid-round,
  .choice-grid-role,
  .start-buttons {
    grid-template-columns: 1fr;
  }

  .start-panel { grid-template-columns: 1fr; }

  .balance-options {
    grid-template-columns: 1fr;
  }

  .balance-or { min-height: 30px; }

  .balance-option { min-height: 170px; }

  .play-actions .button,
  .stage-actions .button,
  .result-actions .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .game-shell { width: min(calc(100% - 24px), var(--content-width)); }

  .balance-card,
  .secret-stage,
  .sort-stage,
  .result-stage,
  .result-card {
    padding: 22px 17px;
  }

  .role-banner,
  .result-grid,
  .order-result-grid {
    grid-template-columns: 1fr;
  }

  .label-buttons,
  .chosen-order,
  .number-reveal-list {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}


.rule-overview {
  margin-top: 44px;
}

.rule-step-list {
  display: grid;
  margin: 0;
  padding: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  list-style: none;
}

.rule-step-list li {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.rule-step-list li > span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--pink);
  font-size: 0.72rem;
  font-weight: 900;
}

.rule-step-list strong,
.rule-step-list p {
  display: block;
}

.rule-step-list strong {
  margin-top: 14px;
}

.rule-step-list p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.rule-example {
  margin-top: 14px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 226, 91, 0.55);
  border-radius: 20px;
  background: var(--gold-soft);
}

.rule-example strong,
.rule-example p {
  display: block;
}

.rule-example p {
  margin: 5px 0 0;
  color: var(--muted);
}

@media (max-width: 920px) {
  .rule-step-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-step-list li:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .rule-step-list {
    grid-template-columns: 1fr;
  }

  .rule-step-list li:last-child {
    grid-column: auto;
  }
}
