:root {
  --bg-start: #06070c;
  --bg-end: #11172a;
  --surface: #edf2fb;
  --line: #d1dae8;
  --text: #111827;
  --panel: rgba(21, 25, 39, 0.86);
  --panel-border: rgba(255, 205, 151, 0.18);
  --muted: #b8c4de;
  --accent: #ffd089;
  --accent-2: #ff9a67;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(100% 140% at 85% 0%, rgba(255, 181, 115, 0.18), transparent 40%),
    radial-gradient(120% 140% at 15% 12%, rgba(255, 111, 89, 0.12), transparent 30%),
    linear-gradient(160deg, 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(8, 10, 23, 0.92);
  border-bottom: 1px solid rgba(255, 197, 132, 0.22);
  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(255, 208, 158, 0.18);
  background: rgba(19, 18, 28, 0.72);
  color: #f8efe7;
  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(69, 42, 33, 0.96);
  border-color: rgba(255, 209, 152, 0.48);
  box-shadow: 0 10px 24px rgba(21, 9, 4, 0.32);
}

.top-nav-link.is-active {
  background: linear-gradient(135deg, rgba(255, 166, 93, 0.94), rgba(219, 115, 66, 0.94));
  border-color: rgba(255, 228, 192, 0.7);
  color: #fff8ef;
  box-shadow: 0 12px 28px rgba(133, 62, 21, 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(21, 17, 36, 0.08);
}

.game-shell-2048 .game-shell__toolbar {
  background: rgba(26, 20, 26, 0.94);
}

.puzzle2048-surface {
  position: relative;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(255, 183, 107, 0.14), transparent 38%),
    linear-gradient(180deg, rgba(19, 15, 24, 0.98), rgba(31, 21, 30, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 207, 161, 0.14),
    inset 0 18px 44px rgba(255, 204, 138, 0.04),
    0 16px 36px rgba(13, 5, 8, 0.34);
  padding: 20px 60px 20px 60px;
  gap: 20px;
}

.puzzle2048-hud {
  display: grid;
  gap: 12px;
  flex: 0 0 190px;
  width: 190px;
  align-self: stretch;
  align-content: start;
  z-index: 1;
}

.puzzle2048-hud__card {
  width: 100%;
  min-height: 126px;
  padding: 1.12rem 1.2rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 213, 174, 0.16);
  background: rgba(34, 23, 27, 0.8);
  color: #fff6ee;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(10, 4, 7, 0.18);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.puzzle2048-hud__label {
  display: block;
  color: #ebd1bb;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.puzzle2048-hud__value {
  display: block;
  margin-top: 0.55rem;
  font-size: 2.5rem;
  line-height: 1;
  font-weight: 800;
  color: #ffffff;
}

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

.puzzle2048-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 18px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(74, 51, 45, 0.92), rgba(42, 28, 30, 0.96)),
    radial-gradient(circle at top, rgba(255, 208, 148, 0.1), transparent 40%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 221, 184, 0.14),
    0 20px 48px rgba(9, 4, 7, 0.34);
  touch-action: none;
}

.puzzle2048-grid,
.puzzle2048-tiles {
  position: absolute;
  inset: 18px;
}

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

.puzzle2048-cell {
  border-radius: 20px;
  background: rgba(255, 239, 226, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.puzzle2048-tiles {
  pointer-events: none;
}

.puzzle2048-tile {
  position: absolute;
  border-radius: 20px;
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease,
    filter 220ms ease;
  will-change: transform, opacity;
}

.puzzle2048-tile__body {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  color: #3b271b;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 14px 26px rgba(20, 9, 4, 0.18);
}

.puzzle2048-tile.is-new .puzzle2048-tile__body {
  animation: tile-pop 220ms ease;
}

.puzzle2048-tile.is-merged .puzzle2048-tile__body {
  animation: tile-merge 220ms ease;
}

.puzzle2048-tile span {
  transform: translateY(1px);
}

.tile-value-2 {
  background: linear-gradient(180deg, #fef4ea, #f7d8b2);
}

.tile-value-4 {
  background: linear-gradient(180deg, #ffe8d0, #ffc38c);
}

.tile-value-8 {
  background: linear-gradient(180deg, #ffd39f, #ff9e62);
  color: #fff8ef;
}

.tile-value-16 {
  background: linear-gradient(180deg, #ffbe86, #ff7d4d);
  color: #fff8ef;
}

.tile-value-32 {
  background: linear-gradient(180deg, #ffab7d, #f35a4b);
  color: #fff9f3;
}

.tile-value-64 {
  background: linear-gradient(180deg, #ff9d9a, #ea444d);
  color: #fff9f3;
}

.tile-value-128 {
  background: linear-gradient(180deg, #f6df92, #f0bb4f);
  color: #2d2013;
}

.tile-value-256 {
  background: linear-gradient(180deg, #f7d16d, #eca23d);
  color: #2d2013;
}

.tile-value-512 {
  background: linear-gradient(180deg, #f3cb70, #de8434);
  color: #2d2013;
}

.tile-value-1024 {
  background: linear-gradient(180deg, #e7c97c, #d7743d);
  color: #fffdf7;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(255, 224, 176, 0.3),
    0 0 26px rgba(255, 186, 98, 0.32);
}

.tile-value-2048,
.tile-value-super {
  background: linear-gradient(180deg, #ffe08f, #ff9f54);
  color: #fffef8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(255, 226, 180, 0.34),
    0 0 34px rgba(255, 182, 103, 0.42);
}

.puzzle2048-overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 22px;
  background: rgba(14, 9, 16, 0.52);
  z-index: 5;
}

.puzzle2048-overlay.is-hidden {
  display: none;
}

.puzzle2048-overlay__panel {
  width: min(100%, 420px);
  padding: 1.8rem;
  border-radius: 26px;
  border: 1px solid rgba(255, 214, 170, 0.2);
  background:
    linear-gradient(160deg, rgba(35, 19, 26, 0.96), rgba(52, 28, 30, 0.92)),
    radial-gradient(circle at top, rgba(255, 206, 133, 0.12), transparent 44%);
  color: #fff8f2;
  text-align: center;
  box-shadow: 0 28px 60px rgba(10, 4, 7, 0.38);
  backdrop-filter: blur(10px);
}

.puzzle2048-overlay__kicker {
  margin: 0 0 0.7rem;
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffd79a;
}

.puzzle2048-overlay h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(2.5rem, 4.4vw, 3.2rem);
  line-height: 1.1;
}

.puzzle2048-overlay p {
  margin: 0;
  line-height: 1.7;
  color: #f8e3d3;
  font-size: 1.15rem;
}

.puzzle2048-overlay__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 1.5rem;
}

.puzzle2048-overlay button {
  min-width: 148px;
  padding: 1rem 1.3rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffcb70, #f07a4d);
  color: #2d180e;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(191, 93, 44, 0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.puzzle2048-overlay button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(191, 93, 44, 0.3);
}

.puzzle2048-overlay__secondary {
  background: rgba(255, 246, 235, 0.1) !important;
  color: #fff6ed !important;
  border: 1px solid rgba(255, 216, 185, 0.22) !important;
  box-shadow: none !important;
}

.is-hidden {
  display: none !important;
}

.puzzle2048-sidebar {
  background:
    linear-gradient(180deg, rgba(255, 231, 201, 0.06), transparent 20%),
    rgba(21, 16, 24, 0.96);
  color: #fff4ea;
  box-shadow: inset 0 0 0 1px rgba(255, 209, 168, 0.12);
}

.puzzle2048-surface:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none;
  max-height: none;
  padding: 24px 24px 24px 44px;
  gap: 32px;
  border-radius: 0;
}

.puzzle2048-surface:fullscreen::backdrop {
  background: #09050a;
}

.puzzle2048-surface:fullscreen .puzzle2048-hud {
  flex: 0 0 210px;
  width: 210px;
}

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

.game-info__panel p {
  margin: 0.42rem 0;
  line-height: 1.7;
}

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

@keyframes tile-pop {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes tile-merge {
  0% {
    transform: scale(0.92);
  }

  55% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

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

  .top-bar {
    gap: 0.9rem;
  }

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

  .puzzle2048-hud {
    display: flex;
    width: 100%;
    flex: 0 0 auto;
    gap: 10px;
    align-self: auto;
  }

  .puzzle2048-hud__card {
    min-width: 0;
    flex: 1 1 0;
    min-height: 0;
    padding: 0.72rem 0.82rem;
  }

  .puzzle2048-hud__value {
    font-size: 1.3rem;
  }

  .puzzle2048-board {
    padding: 14px;
    border-radius: 24px;
  }

  .puzzle2048-grid,
  .puzzle2048-tiles,
  .puzzle2048-overlay {
    inset: 14px;
  }

  .puzzle2048-grid {
    gap: 10px;
  }

  .puzzle2048-tile {
    border-radius: 16px;
  }

  .puzzle2048-overlay {
    padding: 12px;
  }

  .puzzle2048-overlay__panel {
    padding: 1.3rem;
    border-radius: 18px;
  }

  .puzzle2048-surface:fullscreen {
    padding: 14px;
  }
}
