:root {
  color-scheme: light;
  --cream: #fff7ea;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --ink: #17121f;
  --muted: #7b7188;
  --pink: #ff4f9a;
  --hot-pink: #ff2f7f;
  --cyan: #26d9ff;
  --blue: #356bff;
  --violet: #8b5cff;
  --yellow: #ffd84d;
  --orange: #ff9f2e;
  --green: #3ddc97;
  --red: #e93555;
  --card-red: #b61128;
  --shadow: rgba(33, 18, 58, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 79, 154, 0.28), transparent 24%),
    radial-gradient(circle at 85% 8%, rgba(38, 217, 255, 0.22), transparent 26%),
    radial-gradient(circle at 72% 88%, rgba(255, 216, 77, 0.28), transparent 30%),
    linear-gradient(145deg, #fff1f7 0%, #f3fbff 45%, #fff8e2 100%);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

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

body::before {
  z-index: -2;
  background:
    linear-gradient(115deg, transparent 0 48%, rgba(255, 47, 127, 0.15) 48% 50%, transparent 50% 100%),
    linear-gradient(68deg, transparent 0 55%, rgba(53, 107, 255, 0.1) 55% 56.5%, transparent 56.5% 100%);
  background-size: 180px 180px, 230px 230px;
}

body::after {
  z-index: -1;
  opacity: 0.42;
  background-image: radial-gradient(rgba(23, 18, 31, 0.16) 1px, transparent 1px);
  background-size: 15px 15px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 76%);
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 30px;
}

.app-shell::before {
  content: "";
  position: absolute;
  top: 12px;
  right: clamp(18px, 4vw, 46px);
  z-index: -1;
  width: 180px;
  height: 180px;
  border: 4px solid rgba(23, 18, 31, 0.13);
  border-radius: 38px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 79, 154, 0.08));
  transform: rotate(12deg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 12px;
  color: #ffffff;
  background: linear-gradient(90deg, var(--hot-pink), var(--violet));
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 2px var(--ink);
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(31px, 5vw, 52px);
  font-weight: 1000;
  line-height: 1.02;
  text-shadow: 3px 3px 0 #ffffff, 6px 6px 0 rgba(255, 79, 154, 0.35);
}

.mobile-title-tip {
  display: none;
}

.header-figure {
  display: none;
}

.top-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 16px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--yellow), #ffffff 52%, var(--cyan));
  box-shadow: 4px 4px 0 var(--ink), 0 12px 28px var(--shadow);
  font-size: 24px;
  font-weight: 1000;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.icon-button:hover {
  transform: translate(-2px, -2px) rotate(-4deg);
  box-shadow: 6px 6px 0 var(--ink), 0 14px 34px var(--shadow);
}

.sound-button.is-muted {
  opacity: 0.62;
  filter: grayscale(0.7);
}

.hud,
.reward-panel {
  display: grid;
  gap: 10px;
}

.hud {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 12px 0 10px;
}

.reward-panel {
  grid-template-columns: 1fr 1fr auto;
  align-items: stretch;
  margin: 10px 0;
}

.hud-item,
.reward-panel > div,
.hint-button,
.play-strip,
.complete-dialog,
.reward-result {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hud-item,
.reward-panel > div,
.hint-button {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 2px solid rgba(23, 18, 31, 0.88);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink), 0 10px 24px rgba(33, 18, 58, 0.12);
}

.hud-item:nth-child(1) {
  background: linear-gradient(135deg, rgba(255, 216, 77, 0.82), rgba(255, 255, 255, 0.86));
}

.hud-item:nth-child(2) {
  background: linear-gradient(135deg, rgba(38, 217, 255, 0.66), rgba(255, 255, 255, 0.88));
}

.hud-item:nth-child(3) {
  background: linear-gradient(135deg, rgba(255, 79, 154, 0.48), rgba(255, 255, 255, 0.9));
}

.hud-item:nth-child(4) {
  background: linear-gradient(135deg, rgba(139, 92, 255, 0.42), rgba(255, 255, 255, 0.9));
}

.hud-item span,
.reward-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.hud-item strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(23px, 4vw, 32px);
  font-weight: 1000;
  line-height: 1;
}

.reward-panel strong {
  display: block;
  margin-top: 2px;
  font-size: 19px;
  font-weight: 1000;
  line-height: 1.15;
}

.hint-button {
  color: var(--ink);
  background: linear-gradient(135deg, var(--yellow), #ffffff 60%, var(--pink));
  font-weight: 1000;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.hint-button:not(:disabled):hover {
  transform: translateY(-2px);
  filter: saturate(1.12);
}

.hint-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.play-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.88), rgba(255, 241, 247, 0.82));
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 1000;
}

.play-strip span {
  flex: 0 0 auto;
  color: var(--hot-pink);
}

.play-strip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-strip b {
  color: var(--blue);
}

.learning-tip {
  min-height: 24px;
  margin: 0 0 14px;
  color: var(--blue);
  font-size: 15px;
  font-weight: 1000;
  text-shadow: 1px 1px 0 #ffffff;
}

.board-wrap {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(23, 18, 31, 0.22);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.18)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.36) 0 8px, transparent 8px 18px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), 0 18px 50px rgba(33, 18, 58, 0.14);
}

.board {
  --columns: 4;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(96px, 1fr));
  gap: clamp(11px, 1.8vw, 19px);
  align-items: stretch;
  max-width: 1180px;
  margin: 0 auto;
}

.card {
  position: relative;
  aspect-ratio: 2480 / 3508;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--card-red);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 5px 7px 0 var(--ink), 0 18px 30px rgba(33, 18, 58, 0.18);
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease, opacity 220ms ease, filter 170ms ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.48), transparent 34%, transparent 64%, rgba(38, 217, 255, 0.14));
  opacity: 0;
  pointer-events: none;
  transition: opacity 170ms ease;
}

.card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.card:hover,
.card.is-selected {
  transform: translate(-3px, -5px) rotate(-1deg);
  box-shadow: 0 0 0 3px #ffffff, 8px 10px 0 var(--ink), 0 22px 36px rgba(33, 18, 58, 0.2);
}

.card:hover::before,
.card.is-selected::before {
  opacity: 1;
}

.card.is-selected {
  outline: 5px solid var(--yellow);
  z-index: 2;
}

.card.is-wrong {
  animation: shake 260ms ease-in-out;
  outline-color: var(--red);
}

.card.is-hint {
  outline: 6px solid var(--cyan);
  animation: pulse 900ms ease-in-out infinite;
  z-index: 3;
}

.card.is-matched {
  opacity: 0;
  transform: scale(0.86) rotate(4deg);
  pointer-events: none;
}

.card-preview {
  display: none;
}

.card-preview[aria-hidden="true"] img {
  display: none;
}

.complete-dialog {
  width: min(410px, calc(100vw - 32px));
  color: var(--ink);
  background: var(--panel-strong);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 8px 8px 0 var(--ink), 0 28px 70px rgba(33, 18, 58, 0.26);
}

.complete-dialog::backdrop {
  background: rgba(23, 18, 31, 0.42);
  backdrop-filter: blur(4px);
}

.dialog-kicker {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  color: #ffffff;
  background: linear-gradient(90deg, var(--hot-pink), var(--violet));
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 1000;
}

.complete-dialog h2 {
  margin: 0 0 8px;
  font-size: 30px;
}

.complete-dialog p {
  font-weight: 800;
}

.reward-result {
  margin-top: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255, 216, 77, 0.32), rgba(255, 255, 255, 0.92));
  border: 2px solid var(--ink);
  border-radius: 16px;
}

.reward-result p {
  margin: 4px 0;
}

.reward-result .stars {
  color: var(--orange);
  font-size: 25px;
  letter-spacing: 2px;
  text-shadow: 1px 1px 0 var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 17px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 1000;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--yellow), var(--pink));
}

.secondary-button {
  background: #ffffff;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px) rotate(-1deg);
  }
  75% {
    transform: translateX(4px) rotate(1deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 5px 5px 18px;
  }

  .app-shell::before {
    width: 120px;
    height: 120px;
    border-radius: 28px;
  }

  .topbar {
    gap: 8px;
    padding: 8px 0 4px;
  }

  .top-actions {
    gap: 5px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 22px;
    text-shadow: 2px 2px 0 #ffffff, 4px 4px 0 rgba(255, 79, 154, 0.32);
  }

  .mobile-title-tip {
    display: block;
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
  }

  .icon-button {
    width: 31px;
    height: 31px;
    border-width: 2px;
    border-radius: 9px;
    font-size: 18px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin: 15px 0 3px;
  }

  .hud-item {
    padding: 4px 5px;
    border-width: 2px;
    border-radius: 11px;
    box-shadow: 1px 1px 0 var(--ink);
  }

  .hud-item span {
    font-size: 11px;
  }

  .hud-item strong {
    font-size: 18px;
  }

  .reward-panel {
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 5px;
    margin: 3px 0;
  }

  .reward-panel > div,
  .hint-button {
    min-height: 31px;
    padding: 3px 6px;
    border-width: 2px;
    border-radius: 11px;
    box-shadow: 1px 1px 0 var(--ink);
  }

  .reward-panel > div,
  .hint-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    font-size: 12px;
  }

  .reward-panel span {
    display: inline;
    font-size: 12px;
    white-space: nowrap;
  }

  .reward-panel strong {
    display: inline;
    margin-top: 0;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }

  .play-strip {
    gap: 5px;
    margin: 3px 0 4px;
    padding: 4px 7px;
    border-width: 2px;
    border-radius: 13px;
    box-shadow: 1px 1px 0 var(--ink);
    font-size: 13px;
  }

  .play-strip strong {
    flex: 1 1 auto;
  }

  .learning-tip {
    display: none;
  }

  .board-wrap {
    padding: 5px;
    border-radius: 14px;
  }

  .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .card {
    border-width: 2px;
    border-radius: 9px;
    box-shadow: 0 0 0 2px #ffffff, 2px 3px 0 var(--ink);
  }

  .card:hover,
  .card.is-selected {
    transform: translate(-1px, -1px);
    box-shadow: 0 0 0 2px #ffffff, 3px 4px 0 var(--ink);
  }

  .card.is-selected {
    outline-width: 3px;
  }

  .card-preview {
    position: fixed;
    right: -2px;
    bottom: 74px;
    z-index: 10;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 3px;
    width: 62px;
    padding: 4px 3px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.94);
    border: 2px solid var(--ink);
    border-radius: 10px 0 0 10px;
    box-shadow: 2px 2px 0 var(--ink), 0 10px 24px rgba(33, 18, 58, 0.22);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .card-preview.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .card-preview img {
    width: 48px;
    aspect-ratio: 2480 / 3508;
    object-fit: contain;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--card-red);
  }

  .card-preview span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
  }

  .card-preview strong {
    display: none;
  }
}

@media (max-width: 360px) {
  .board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
