:root {
  --bg-start: #07100b;
  --bg-end: #182116;
  --surface: #f1f6ec;
  --line: #cfdbca;
  --text: #172018;
  --muted: #c7d6c0;
  --accent: #f7c85e;
  --accent-2: #54b76c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    linear-gradient(180deg, rgba(12, 24, 14, 0.28), rgba(12, 19, 15, 0.88)),
    linear-gradient(145deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  min-height: 100vh;
}

.page-wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: 24px;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 13, 10, 0.92);
  border-bottom: 1px solid rgba(247, 200, 94, 0.24);
  backdrop-filter: blur(8px);
}

.top-strip-inner {
  overflow-x: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 58px;
  width: max-content;
  min-width: 100%;
  padding: 0.5rem 0;
}

.icon-button {
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.icon-button img {
  width: clamp(168px, 26vw, 280px);
  height: auto;
  display: block;
  pointer-events: none;
}

.icon-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.top-nav-links {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  flex-shrink: 0;
  min-width: max-content;
  white-space: nowrap;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.02rem;
  border-radius: 999px;
  border: 1px solid rgba(247, 200, 94, 0.2);
  background: rgba(14, 25, 18, 0.72);
  color: #f4f8ef;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.top-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(34, 57, 40, 0.96);
  border-color: rgba(255, 216, 122, 0.5);
  box-shadow: 0 10px 24px rgba(4, 12, 7, 0.32);
}

.top-nav-link.is-active {
  background: linear-gradient(135deg, rgba(84, 183, 108, 0.95), rgba(43, 132, 76, 0.95));
  border-color: rgba(210, 247, 191, 0.7);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(21, 91, 45, 0.28);
}

.game-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem 0 2rem;
}

.game-stage,
.game-info {
  grid-column: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(13, 26, 17, 0.08);
}

.game-shell-memory .game-shell__toolbar {
  background: rgba(12, 24, 15, 0.94);
}

.memory-surface {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 22px;
  overflow: hidden;
  border-radius: 18px;
  padding: 22px 58px;
  background:
    linear-gradient(90deg, rgba(6, 18, 11, 0.9), rgba(10, 24, 15, 0.56), rgba(6, 18, 11, 0.88)),
    url("./assets/background.png") center / cover;
  box-shadow:
    inset 0 0 0 1px rgba(236, 232, 170, 0.18),
    inset 0 18px 42px rgba(255, 239, 170, 0.05),
    0 16px 36px rgba(4, 12, 8, 0.34);
}

.memory-hud {
  display: grid;
  align-content: start;
  gap: 12px;
  flex: 0 0 205px;
  width: 205px;
  z-index: 2;
}

.memory-hud__item {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem 1.12rem;
  border-radius: 8px;
  border: 1px solid rgba(241, 229, 169, 0.18);
  background: rgba(14, 31, 20, 0.82);
  color: #fffdf2;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(5, 16, 8, 0.18);
}

.memory-hud__label {
  color: #d7e5c9;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.memory-hud__value {
  margin-top: 0.55rem;
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 900;
  color: #ffffff;
}

.memory-board-shell {
  display: grid;
  place-items: start center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.memory-board {
  width: min(100%, 690px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 233, 172, 0.24);
  background: rgba(8, 21, 12, 0.68);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 44px rgba(3, 10, 5, 0.28);
}

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.memory-card:focus-visible {
  outline: 4px solid rgba(247, 200, 94, 0.82);
  outline-offset: 3px;
}

.memory-card:disabled {
  cursor: default;
}

.memory-card__inner {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  transform-style: preserve-3d;
  transition: transform 0.34s ease, filter 0.2s ease;
  box-shadow: 0 10px 22px rgba(4, 12, 7, 0.32);
  will-change: transform;
}

.memory-card:not(.is-flipped):not(.is-matched):hover:not(:disabled) .memory-card__inner {
  filter: brightness(1.08);
}

.memory-card.is-flipped .memory-card__inner,
.memory-card.is-matched .memory-card__inner {
  transform: rotateY(180deg) translateZ(0);
}

.memory-card.is-matched .memory-card__inner {
  box-shadow:
    0 0 0 3px rgba(247, 200, 94, 0.75),
    0 14px 26px rgba(4, 12, 7, 0.28);
}

.memory-card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.memory-card__back {
  background: #213326;
}

.memory-card__back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.memory-card__front {
  transform: rotateY(180deg) translateZ(1px);
  border: 1px solid rgba(255, 241, 191, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 255, 246, 0.96), rgba(233, 245, 221, 0.96));
}

.memory-card.is-flipped .memory-card__front,
.memory-card.is-matched .memory-card__front {
  border: 3px solid #f4c851;
  box-shadow: inset 0 0 0 1px rgba(255, 237, 181, 0.86);
}

.memory-card__front img {
  width: 76%;
  height: 76%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 10px rgba(29, 49, 20, 0.18));
}

.memory-win {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 12, 7, 0.62);
  backdrop-filter: blur(7px);
}

.memory-win[hidden] {
  display: none;
}

.memory-win__panel {
  width: min(520px, 92%);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 236, 180, 0.34);
  background: rgba(14, 31, 20, 0.96);
  color: #fffdf2;
  text-align: center;
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.34);
}

.memory-win__kicker {
  margin: 0 0 0.5rem;
  color: #f7d57f;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.memory-win h1 {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.12;
}

.memory-win p {
  margin: 1rem 0 1.35rem;
  color: #e1ecd9;
  font-size: 1.15rem;
  line-height: 1.7;
}

.memory-win button {
  min-height: 48px;
  padding: 0.78rem 1.35rem;
  border: 1px solid rgba(255, 239, 195, 0.5);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(247, 200, 94, 0.96), rgba(218, 151, 45, 0.96));
  color: #1d1609;
  font-size: 1.12rem;
  font-weight: 900;
  cursor: pointer;
}

.game-info__panel {
  max-width: none;
  margin: 0 auto;
  color: #1d2a1c;
  line-height: 1.85;
}

.memory-audio-toggle.is-muted {
  opacity: 0.88;
}

.game-info__panel h2,
.game-info__panel h3 {
  line-height: 1.35;
}

.game-info__panel h2 {
  margin: 0 0 0.75rem;
}

.game-info__panel h3 {
  margin: 1.2rem 0 0.35rem;
}

.game-info__panel p {
  margin: 0.4rem 0;
}

@media (max-width: 900px) {
  .page-wrap {
    padding-inline: 14px;
  }

  .card {
    padding: 0.7rem;
  }

  .memory-surface {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 14px;
  }

  .memory-hud {
    width: 100%;
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .memory-hud__item {
    min-height: 90px;
    padding: 0.8rem 0.82rem;
  }

  .memory-hud__value {
    font-size: 2rem;
  }
}
