/* =========================================================
   拾光小站 · Arcade hub, 2048 & memory
   ========================================================= */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 30px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .05em;
}

.breadcrumb a {
  transition: color .2s ease;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span:nth-child(2) {
  opacity: .45;
}

/* ---------------- Arcade landing ---------------- */

.arcade-hero {
  padding-block: 26px clamp(42px, 6vw, 70px);
  overflow: clip;
}

.arcade-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  align-items: center;
  gap: clamp(36px, 6vw, 90px);
}

.arcade-hero h1 {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 5.2vw, 4.25rem);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: 1.04;
}

.arcade-hero h1 .marker {
  position: relative;
  display: inline-block;
  color: var(--green-deep);
  z-index: 0;
}

[data-theme="dark"] .arcade-hero h1 .marker {
  color: var(--green);
}

.arcade-hero h1 .marker::after {
  content: "";
  position: absolute;
  left: -1%;
  right: -1%;
  bottom: .1em;
  height: .24em;
  border-radius: 2px;
  background: var(--yellow);
  opacity: .72;
  transform: rotate(-1deg);
  z-index: -1;
}

.arcade-hero p {
  max-width: 520px;
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.85;
}

.arcade-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 30px;
}

.arcade-hero-meta span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .05em;
}

.arcade-hero-meta b {
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -.04em;
}

.player-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(239, 197, 95, .2), transparent 38%),
    var(--green-deep);
  color: #f8f2e4;
  box-shadow: var(--shadow-lg);
  transform: rotate(1.8deg);
  transition: transform .5s var(--ease);
}

.player-card:hover {
  transform: rotate(0deg) translateY(-3px);
}

[data-theme="dark"] .player-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(239, 197, 95, .22), transparent 38%),
    #294635;
}

.player-card::before {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 220px;
  height: 220px;
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 50%;
}

.player-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  color: rgba(248, 242, 228, .5);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .13em;
}

.player-card__main {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-block: 22px;
}

.player-card__avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 16px;
  background: var(--yellow);
  color: var(--green-deep);
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  transform: rotate(-4deg);
}

.player-card__main small {
  color: var(--yellow);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .16em;
}

.player-card__main h2 {
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.03em;
}

.player-card__main p {
  color: rgba(248, 242, 228, .55);
  font-size: 10px;
}

.player-card__bottom {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 10px;
  background: rgba(255, 255, 255, .13);
}

.player-card__bottom div {
  display: grid;
  gap: 1px;
  padding: 9px 10px;
  background: rgba(20, 36, 27, .5);
}

.player-card__bottom span {
  color: rgba(248, 242, 228, .42);
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: .1em;
}

.player-card__bottom b {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.player-card__stripe {
  height: 4px;
  margin: 18px -24px -24px;
  background: repeating-linear-gradient(90deg, var(--yellow) 0 18px, transparent 18px 25px, var(--accent) 25px 43px, transparent 43px 50px);
  opacity: .8;
}

/* ---------------- Game library ---------------- */

.game-library {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.library-feature {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  min-height: 400px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  transition: transform .3s var(--ease), box-shadow .3s ease, border-color .25s ease;
}

.library-feature:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}

.library-feature__art {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  background: #111726;
}

.library-feature__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 48%;
  transition: transform .8s var(--ease);
}

.library-feature:hover .library-feature__art img {
  transform: scale(1.035);
}

.library-feature__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(17, 23, 38, .35));
  pointer-events: none;
}

.play-circle {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: rgba(15, 22, 30, .48);
  color: #fff;
  font-size: 14px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background .25s ease, color .25s ease, transform .3s var(--ease);
}

.library-feature:hover .play-circle,
.library-game:hover .play-circle {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.06);
}

.play-circle--small {
  right: 14px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  font-size: 11px;
}

.library-feature__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(24px, 4vw, 44px);
}

.library-feature__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .05em;
}

.library-feature__body h3 {
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: -.05em;
  line-height: 1.04;
}

.library-feature__body h3 small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: .22em;
}

.library-feature__body > p {
  margin-top: 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.library-feature__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.library-feature__tags span {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  transition: color .2s ease, border-color .2s ease, gap .2s ease;
}

a:hover > .text-link,
.text-link:hover {
  gap: 11px;
  color: var(--accent);
  border-color: var(--accent);
}

.library-game {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  transition: transform .3s var(--ease), box-shadow .3s ease, border-color .25s ease;
}

.library-game:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.library-game__art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 230px;
  overflow: hidden;
}

.library-game--2048 .library-game__art {
  background:
    radial-gradient(circle at 50% 45%, rgba(239, 197, 95, .38), transparent 55%),
    #dfd2b7;
}

[data-theme="dark"] .library-game--2048 .library-game__art {
  background:
    radial-gradient(circle at 50% 45%, rgba(239, 197, 95, .22), transparent 55%),
    #262e26;
}

.library-game--memory .library-game__art {
  background:
    radial-gradient(circle at 50% 40%, rgba(231, 101, 63, .28), transparent 55%),
    var(--accent-soft);
}

[data-theme="dark"] .library-game--memory .library-game__art {
  background:
    radial-gradient(circle at 50% 40%, rgba(231, 101, 63, .2), transparent 55%),
    #261c18;
}

.library-game__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  padding: 22px;
}

.library-game__title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.library-game__title h3 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1;
}

.library-game__title span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: .05em;
}

.library-game__body p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.library-game__body .text-link {
  margin-top: auto;
  padding-top: 16px;
}

.art-2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  width: min(210px, 62%);
  padding: 8px;
  border-radius: 14px;
  background: #2b3a30;
  box-shadow: 0 24px 40px -22px rgba(25, 31, 26, .6);
  transform: rotate(-4deg);
  transition: transform .5s var(--ease);
}

.library-game:hover .art-2048 {
  transform: rotate(0deg) scale(1.03);
}

.art-2048 span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  color: #f6efe0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.art-2048 span:nth-child(2) { background: #f2ead8; color: #6d685d; }
.art-2048 span:nth-child(3) { background: #eddfc0; color: #6d685d; }
.art-2048 span:nth-child(5) { background: #efc55f; color: #4c3b12; }
.art-2048 span:nth-child(6) { background: #e7a253; color: #fffaf2; }
.art-2048 span:nth-child(10) { background: #df6c44; color: #fffaf2; }
.art-2048 span:nth-child(11) { background: #cc5638; color: #fffaf2; }
.art-2048 span:nth-child(15) { background: #3f6d51; color: #f6efe0; }
.art-2048 span:nth-child(16) { background: #2b4c37; color: #efc55f; }

.art-memory {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(230px, 68%);
  transform: rotate(3deg);
  transition: transform .5s var(--ease);
}

.library-game:hover .art-memory {
  transform: rotate(0deg) scale(1.03);
}

.art-memory span {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 7px;
  background: var(--accent);
  color: rgba(255, 250, 242, .9);
  font-family: var(--font-display);
  font-size: 15px;
  box-shadow: 0 8px 18px -11px rgba(91, 35, 20, .7);
}

.art-memory span:nth-child(2),
.art-memory span:nth-child(3) {
  background: var(--green);
}

.art-memory span:nth-child(6),
.art-memory span:nth-child(7) {
  background: var(--surface-solid);
  color: var(--accent);
}

.arcade-note {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 22px;
  padding: 20px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-solid) 46%, transparent);
}

.arcade-note__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
}

.arcade-note > div {
  flex: 1;
}

.arcade-note h3 {
  font-size: 12px;
  font-weight: 600;
}

.arcade-note p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}

.arcade-note .text-link {
  flex: none;
  margin-top: 0;
  font-size: 10px;
}

.arcade-cta {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  padding: clamp(28px, 5vw, 52px);
  border-radius: var(--radius-xl);
  background: var(--green-deep);
  color: #f7f1e2;
}

[data-theme="dark"] .arcade-cta {
  background: #264333;
}

.arcade-cta .eyebrow {
  color: rgba(247, 241, 226, .5);
}

.arcade-cta .eyebrow::before {
  background: var(--yellow);
}

.arcade-cta h2 {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.7vw, 3rem);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1.08;
}

.arcade-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: none;
}

.arcade-cta .btn--primary {
  background: var(--yellow);
  color: var(--green-deep);
}

.arcade-cta .btn--primary:hover {
  background: #f6d886;
}

.arcade-cta .btn--ghost {
  border-color: rgba(255, 255, 255, .28);
  color: #f7f1e2;
}

.arcade-cta .btn--ghost:hover {
  border-color: rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .08);
}

/* ---------------- Game pages ---------------- */

.game-page {
  padding-block: 22px 70px;
}

.game-page .breadcrumb {
  margin-bottom: 24px;
}

.game-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 26px;
}

.game-head h1 {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 5vw, 4rem);
  font-weight: 600;
  letter-spacing: -.06em;
  line-height: .95;
}

.game-head p {
  max-width: 460px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.game-kicker {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .13em;
}

.score-pair {
  display: flex;
  gap: 8px;
  flex: none;
}

.score-box {
  display: grid;
  gap: 1px;
  min-width: 92px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-solid);
  text-align: right;
}

.score-box span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.score-box b {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.score-box--accent {
  border-color: transparent;
  background: var(--green-deep);
  color: #f7f1e2;
}

[data-theme="dark"] .score-box--accent {
  background: #2a4736;
}

.score-box--accent span {
  color: rgba(247, 241, 226, .5);
}

.score-pop {
  animation: score-pop .25s var(--ease);
}

@keyframes score-pop {
  50% { transform: scale(1.08); }
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  align-items: start;
  gap: 22px;
}

.game-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.game-toolbar__hint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .04em;
}

.game-toolbar__hint::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

.game-toolbar__actions {
  display: flex;
  gap: 7px;
}

.game-toolbar .btn {
  min-height: 36px;
  padding-inline: 13px;
  font-size: 11px;
  border-radius: 9px;
}

.game-aside {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  display: grid;
  gap: 12px;
}

.aside-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
}

.aside-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.aside-card h2,
.aside-card h3 {
  font-size: 13px;
  font-weight: 600;
}

.aside-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.75;
}

.how-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  list-style: none;
}

.how-list li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 9px;
  align-items: start;
}

.how-list b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
}

.how-list span {
  padding-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(3, 26px);
  gap: 4px;
  width: max-content;
  margin: 10px 0 0 33px;
}

.key-row kbd {
  display: grid;
  place-items: center;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-solid);
  font-family: var(--font-mono);
  font-size: 10px;
  box-shadow: 0 1px 0 var(--line);
}

.key-row .key-blank {
  height: 24px;
}

.game-tip {
  display: flex;
  gap: 10px;
  padding: 15px;
  border-radius: 13px;
  background: var(--yellow-soft);
  color: var(--ink-soft);
}

.game-tip span {
  color: #8a6a18;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1;
}

.game-tip p {
  margin: 0;
  color: #6d5b2a;
  font-size: 10px;
  line-height: 1.65;
}

[data-theme="dark"] .game-tip {
  background: var(--yellow-soft);
}

[data-theme="dark"] .game-tip p {
  color: #d9c58d;
}

[data-theme="dark"] .game-tip span {
  color: var(--yellow);
}

.game-footer-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .04em;
}

.game-footer-line a {
  color: var(--ink-soft);
  transition: color .2s ease;
}

.game-footer-line a:hover {
  color: var(--accent);
}

/* ---------------- 2048 ---------------- */

.board-shell {
  position: relative;
  width: min(100%, 500px);
  margin-inline: auto;
}

.board-2048 {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 12px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, .08), transparent 32%),
    #26382c;
  outline: 0;
  touch-action: none;
  container-type: inline-size;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}

.board-2048:focus-visible {
  box-shadow: 0 0 0 3px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .07);
}

.board-grid,
.tile-layer {
  position: absolute;
  inset: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}

.board-grid span {
  border-radius: 9px;
  background: rgba(255, 255, 255, .065);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .08);
}

.tile-layer {
  pointer-events: none;
}

.tile-slot {
  display: flex;
  min-width: 0;
  min-height: 0;
}

.tile-2048 {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  background: #f3ecdc;
  color: #6b665a;
  font-family: var(--font-mono);
  font-size: clamp(.95rem, 7.4cqw, 2.15rem);
  font-weight: 700;
  letter-spacing: -.055em;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}

.tile-2048.is-new {
  animation: tile-in .18s var(--ease) both;
}

.tile-2048.is-merged {
  animation: tile-pop .24s var(--ease);
}

.tile-2048[data-digits="3"] {
  font-size: clamp(.85rem, 6.1cqw, 1.8rem);
}

.tile-2048[data-digits="4"] {
  font-size: clamp(.75rem, 5.1cqw, 1.5rem);
}

.tile-2048[data-digits="5"] {
  font-size: clamp(.65rem, 4.3cqw, 1.25rem);
}

.tile-2048[data-value="2"] { background: #f4eee0; color: #6b665a; }
.tile-2048[data-value="4"] { background: #efe3c8; color: #6b665a; }
.tile-2048[data-value="8"] { background: #efc56e; color: #564313; }
.tile-2048[data-value="16"] { background: #eaa75b; color: #fffaf2; }
.tile-2048[data-value="32"] { background: #e78252; color: #fffaf2; }
.tile-2048[data-value="64"] { background: #dc5c3b; color: #fffaf2; }
.tile-2048[data-value="128"] { background: #e7c65e; color: #4d3a0c; }
.tile-2048[data-value="256"] { background: #dfb646; color: #fffaf2; }
.tile-2048[data-value="512"] { background: #c99b2e; color: #fffaf2; }
.tile-2048[data-value="1024"] { background: #477559; color: #f7f1e2; }
.tile-2048[data-value="2048"] { background: #2b5039; color: #efc55f; box-shadow: inset 0 0 0 1px rgba(239, 197, 95, .4), 0 0 24px rgba(239, 197, 95, .25); }
.tile-2048[data-value="4096"],
.tile-2048[data-value="8192"],
.tile-2048[data-value="16384"] { background: #17251c; color: #efc55f; }

@keyframes tile-in {
  from { opacity: 0; transform: scale(.55); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes tile-pop {
  0% { transform: scale(1); }
  55% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 20px;
  background: color-mix(in srgb, #142119 80%, transparent);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  text-align: center;
  animation: overlay-in .25s ease both;
}

@keyframes overlay-in {
  from { opacity: 0; }
}

.board-overlay__inner {
  display: grid;
  justify-items: center;
  max-width: 280px;
}

.board-overlay__tag {
  color: var(--yellow);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .18em;
}

.board-overlay h2 {
  margin-top: 8px;
  color: #fffaf2;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1.05;
}

.board-overlay p {
  margin-top: 8px;
  color: rgba(255, 250, 242, .62);
  font-size: 11px;
  line-height: 1.7;
}

.board-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.board-overlay .btn {
  min-height: 40px;
  padding-inline: 16px;
  font-size: 11px;
}

.board-overlay .btn--ghost {
  border-color: rgba(255, 255, 255, .3);
  color: #fffaf2;
}

.board-overlay .btn--ghost:hover {
  border-color: rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .08);
}

.board-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .04em;
}

.board-caption kbd {
  margin-inline: 1px;
}

.undo-disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---------------- Memory ---------------- */

.memory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.memory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.stat-pill span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: .08em;
}

.stat-pill b {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.memory-board-shell {
  position: relative;
  width: min(100%, 560px);
  margin-inline: auto;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1.4vw, 11px);
}

.memory-card {
  position: relative;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  perspective: 800px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.memory-card__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .42s cubic-bezier(.22, .8, .3, 1);
}

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

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

.memory-card__back {
  border: 1px solid color-mix(in srgb, var(--green) 65%, #000);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .1), transparent 46%),
    linear-gradient(145deg, #355d46, #24422f);
  color: rgba(247, 241, 226, .46);
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.4vw, 1.5rem);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07), 0 8px 18px -13px rgba(20, 35, 26, .8);
  transition: transform .2s ease, box-shadow .2s ease;
}

.memory-card__back::before,
.memory-card__back::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
}

.memory-card__back::before {
  width: 60%;
  aspect-ratio: 1;
}

.memory-card__back::after {
  width: 34%;
  aspect-ratio: 1;
  border-style: dashed;
}

.memory-card:nth-child(4n + 2) .memory-card__back {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .1), transparent 46%),
    linear-gradient(145deg, #a9583d, #7d3b29);
}

.memory-card:nth-child(4n + 3) .memory-card__back {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .1), transparent 46%),
    linear-gradient(145deg, #3f5966, #2a3e48);
}

.memory-card:hover .memory-card__back {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 14px 24px -16px rgba(20, 35, 26, .9);
}

.memory-card__front {
  transform: rotateY(180deg);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 42%, var(--surface-solid), var(--surface-soft));
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2.6rem);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.memory-card.is-matched .memory-card__front {
  border-color: var(--green);
  color: var(--green-deep);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--green) 22%, transparent), 0 0 0 2px color-mix(in srgb, var(--green) 12%, transparent);
}

.memory-card.is-matched {
  animation: match-bounce .45s var(--ease);
}

.memory-card.is-wrong .memory-card__inner {
  animation: card-shake .35s ease;
}

.memory-card.is-locked {
  cursor: default;
}

@keyframes match-bounce {
  0%, 100% { transform: translateY(0); }
  42% { transform: translateY(-5px) scale(1.02); }
}

@keyframes card-shake {
  25% { transform: rotateY(180deg) translateX(3px); }
  75% { transform: rotateY(180deg) translateX(-3px); }
}

.memory-overlay {
  position: absolute;
  inset: -8px;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  text-align: center;
  animation: overlay-in .25s ease both;
}

.memory-overlay__card {
  display: grid;
  justify-items: center;
  width: min(100%, 320px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}

.memory-overlay__mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--yellow-soft);
  color: #9a761e;
  font-family: var(--font-display);
  font-size: 24px;
}

.memory-overlay h2 {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.04em;
}

.memory-overlay p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.memory-overlay__stats {
  display: flex;
  gap: 18px;
  margin-top: 16px;
}

.memory-overlay__stats div {
  display: grid;
  gap: 1px;
}

.memory-overlay__stats span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: .08em;
}

.memory-overlay__stats b {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
}

.memory-overlay .btn {
  margin-top: 18px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1000px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
  }

  .library-feature {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 880px) {
  .arcade-hero-grid {
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .player-card {
    max-width: 520px;
    transform: rotate(1deg);
  }

  .library-feature {
    grid-template-columns: 1fr;
  }

  .library-feature__art {
    min-height: 290px;
    max-height: 340px;
  }

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

  .game-aside {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .game-aside .aside-card:first-child {
    grid-row: span 2;
  }

  .game-head {
    align-items: flex-start;
  }
}

@media (max-width: 700px) {
  .arcade-hero {
    padding-top: 18px;
  }

  .arcade-hero h1 {
    font-size: clamp(2.8rem, 11.5vw, 4rem);
  }

  .arcade-hero p {
    font-size: 13.5px;
  }

  .game-library {
    grid-template-columns: 1fr;
  }

  .library-feature {
    grid-column: auto;
  }

  .library-feature__art {
    min-height: 230px;
  }

  .library-feature__body {
    padding: 24px;
  }

  .arcade-note {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .arcade-note .text-link {
    grid-column: 2;
    justify-self: start;
  }

  .arcade-cta {
    display: grid;
    gap: 24px;
  }

  .arcade-cta__actions .btn {
    flex: 1;
  }

  .game-head {
    display: grid;
    gap: 14px;
  }

  .score-pair {
    justify-content: stretch;
  }

  .score-box {
    flex: 1;
    text-align: left;
  }

  .game-panel {
    padding: 12px;
  }

  .game-toolbar {
    margin-bottom: 10px;
  }

  .game-toolbar__hint {
    display: none;
  }

  .game-toolbar__actions {
    margin-left: auto;
  }

  .game-aside {
    grid-template-columns: 1fr;
  }

  .game-aside .aside-card:first-child {
    grid-row: auto;
  }

  .board-2048 {
    padding: 9px;
    border-radius: 15px;
  }

  .board-grid,
  .tile-layer {
    inset: 9px;
    gap: 7px;
  }

  .board-grid span,
  .tile-2048 {
    border-radius: 7px;
  }

  .board-caption {
    display: grid;
    gap: 5px;
  }

  .memory-head {
    display: grid;
  }

  .memory-board {
    gap: 6px;
  }

  .memory-card {
    border-radius: 8px;
  }

  .memory-face {
    border-radius: 8px;
  }

  .memory-overlay {
    inset: -4px;
  }

  .memory-overlay__card {
    padding: 22px;
  }
}

@media (max-width: 430px) {
  .game-head h1 {
    font-size: 2.5rem;
  }

  .game-panel {
    padding: 9px;
  }

  .game-toolbar__actions .btn {
    padding-inline: 10px;
    font-size: 10px;
  }

  .board-2048 {
    padding: 7px;
  }

  .board-grid,
  .tile-layer {
    inset: 7px;
    gap: 5px;
  }

  .board-grid span,
  .tile-2048 {
    border-radius: 6px;
  }

  .arcade-cta {
    padding: 24px 20px;
    border-radius: 22px;
  }

  .arcade-cta__actions {
    display: grid;
  }

  .player-card {
    padding: 18px;
  }

  .player-card__stripe {
    margin: 16px -18px -18px;
  }
}
