:root {
  color-scheme: light;
  --ink: #31243a;
  --muted: #7b647d;
  --paper: #fff8fb;
  --paper-strong: #ffffff;
  --pink: #ff6b9d;
  --pink-deep: #d93d75;
  --violet: #9270d8;
  --mint: #42bfa8;
  --peach: #ffb06b;
  --gold: #f3be4d;
  --line: rgba(92, 60, 96, 0.16);
  --shadow: 0 22px 70px rgba(104, 61, 109, 0.2);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 176, 107, 0.26), transparent 24rem),
    radial-gradient(circle at 88% 16%, rgba(66, 191, 168, 0.2), transparent 23rem),
    linear-gradient(135deg, #fff0f6 0%, #f4ebff 48%, #effaf6 100%);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(45deg, rgba(255, 107, 157, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(146, 112, 216, 0.08) 25%, transparent 25%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 70%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.game-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 26px 0 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 12px 18px rgba(217, 61, 117, 0.22));
}

.eyebrow,
.hint,
.board-topline p,
.modal-player,
.stat-label {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.02;
}

.hint {
  max-width: 760px;
  font-size: 1rem;
  line-height: 1.7;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(310px, 1.3fr) auto;
  align-items: center;
  gap: 14px;
  margin: 10px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 40px rgba(111, 74, 119, 0.12);
  backdrop-filter: blur(16px);
}

.player-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.player-panel label {
  display: grid;
  gap: 6px;
}

.player-panel span,
.stat-label {
  font-size: 0.76rem;
  font-weight: 700;
}

.player-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(217, 61, 117, 0.22);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 248, 251, 0.92);
}

.player-panel input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.16);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-pill {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid rgba(146, 112, 216, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.stat-pill strong {
  min-width: 0;
  overflow: hidden;
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-pill.accent {
  border-color: rgba(243, 190, 77, 0.42);
  background: rgba(255, 248, 225, 0.78);
}

.primary-action,
.ghost-action,
.icon-button {
  border: 0;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.primary-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: 0 16px 26px rgba(217, 61, 117, 0.25);
}

.primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(217, 61, 117, 0.3);
}

.button-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.button-icon::after {
  position: absolute;
  right: -4px;
  bottom: -2px;
  width: 7px;
  height: 7px;
  content: "";
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(20deg);
}

.board-wrap {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.board-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.board-topline h2 {
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.board-topline p {
  margin-top: 4px;
  line-height: 1.55;
}

.category-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.category-key span,
.box-category,
.rarity-badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

[data-kind="sweet"] {
  color: #b92767;
  background: #ffe4ef;
}

[data-kind="date"] {
  color: #5b3fb2;
  background: #eee7ff;
}

[data-kind="reward"] {
  color: #9b6400;
  background: #fff0c5;
}

[data-kind="penalty"] {
  color: #0d7f6d;
  background: #dcf8f1;
}

[data-kind="wish"] {
  color: #b5551d;
  background: #ffe8d6;
}

.box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.blind-box {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.82;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  justify-items: center;
  gap: 4px;
  overflow: hidden;
  border: 1px solid rgba(217, 61, 117, 0.18);
  border-radius: 8px;
  padding: 9px 7px 8px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 239, 247, 0.82)),
    #fff;
  box-shadow: 0 12px 26px rgba(112, 67, 119, 0.12);
}

.blind-box::before {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 12px;
  height: 12px;
  content: "";
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(66, 191, 168, 0.14);
}

.blind-box:hover:not(.opened) {
  transform: translateY(-4px) scale(1.025);
  box-shadow: 0 18px 34px rgba(217, 61, 117, 0.22);
}

.blind-box:focus-visible {
  outline: 4px solid rgba(255, 107, 157, 0.28);
  outline-offset: 2px;
}

.gift-img {
  width: min(70px, 68%);
  max-height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 12px 12px rgba(217, 61, 117, 0.22));
  transition: transform 200ms ease, filter 200ms ease;
}

.blind-box:hover:not(.opened) .gift-img {
  transform: rotate(-4deg) translateY(-2px);
}

.box-number {
  font-weight: 900;
  font-size: 0.9rem;
}

.box-category {
  max-width: 100%;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blind-box:not(.opened) .box-category {
  color: var(--muted);
  background: rgba(146, 112, 216, 0.12);
}

.blind-box.opened {
  cursor: default;
  color: #766d78;
  background:
    linear-gradient(180deg, rgba(244, 242, 245, 0.98), rgba(230, 226, 232, 0.9)),
    #eee;
  box-shadow: none;
}

.blind-box.opened::before {
  background: #aaa0ad;
  box-shadow: none;
}

.blind-box.opened .gift-img {
  filter: grayscale(1) drop-shadow(0 8px 10px rgba(70, 62, 75, 0.12));
}

.blind-box.rare-open {
  border-color: rgba(243, 190, 77, 0.78);
  box-shadow: 0 0 0 2px rgba(243, 190, 77, 0.28), 0 18px 34px rgba(217, 61, 117, 0.2);
}

.result-dialog {
  width: min(92vw, 460px);
  border: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
}

.result-dialog::backdrop {
  background: rgba(48, 30, 55, 0.32);
  backdrop-filter: blur(5px);
}

.dialog-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  padding: 30px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 240, 247, 0.98)),
    var(--paper-strong);
  box-shadow: 0 28px 70px rgba(49, 36, 58, 0.28);
}

.dialog-card::before {
  position: absolute;
  top: -45px;
  right: -20px;
  width: 150px;
  height: 150px;
  content: "";
  background: url("assets/heart-mark.svg") center / contain no-repeat;
  opacity: 0.11;
  transform: rotate(12deg);
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(49, 36, 58, 0.08);
}

.close-button::before,
.close-button::after {
  position: absolute;
  top: 16px;
  left: 9px;
  width: 16px;
  height: 2px;
  content: "";
  background: var(--ink);
}

.close-button::before {
  transform: rotate(45deg);
}

.close-button::after {
  transform: rotate(-45deg);
}

.rarity-badge {
  display: inline-flex;
  margin-bottom: 14px;
  color: #9b6400;
  background: #fff0c5;
}

.rarity-badge.common {
  color: #5b3fb2;
  background: #eee7ff;
}

.modal-player {
  font-weight: 800;
}

.dialog-card h3 {
  margin-top: 5px;
  font-size: clamp(1.6rem, 6vw, 2.45rem);
  line-height: 1.08;
}

#modalText {
  margin: 16px 0 0;
  font-size: 1.08rem;
  line-height: 1.75;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

.ghost-action {
  min-height: 48px;
  border: 1px solid rgba(217, 61, 117, 0.22);
  border-radius: 8px;
  color: var(--pink-deep);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.88);
}

.ghost-action:hover,
.icon-button:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 12px 24px rgba(112, 67, 119, 0.14);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: rgba(49, 36, 58, 0.92);
  box-shadow: 0 16px 32px rgba(49, 36, 58, 0.24);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.confetti-piece {
  position: fixed;
  z-index: 20;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti-fall 900ms ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--dx), var(--dy), 0) rotate(var(--rot));
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 20px, 700px);
    padding-top: 16px;
  }

  .control-band {
    grid-template-columns: 1fr;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary-action {
    width: 100%;
  }

  .board-topline {
    display: grid;
  }

  .category-key {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .game-header {
    padding-top: 14px;
  }

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

  .stats-strip {
    grid-template-columns: 1fr 1fr;
  }

  .board-wrap {
    padding: 12px;
  }

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

  .blind-box {
    padding: 8px 5px 7px;
  }

  .gift-img {
    width: 64%;
  }

  .box-category {
    max-width: 92%;
    padding-inline: 7px;
  }

  .dialog-card {
    padding: 26px 20px 20px;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }
}

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