﻿:root {
  --bg-deep: #05070f;
  --bg-mid: #0d1330;
  --bg-accent: #1b2553;
  --text-primary: #e6eefc;
  --text-muted: #a8b2d1;
  --grid-shell: rgba(15, 23, 60, 0.85);
  --grid-border: rgba(140, 180, 255, 0.18);
  --cell-bg: rgba(120, 150, 255, 0.12);
  --cell-glow: rgba(130, 200, 255, 0.25);
  --glow-strong: rgba(120, 200, 255, 0.45);
  --radius-lg: 14px;
  --radius-sm: 8px;
  --gap: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(
      1200px 600px at 10% 10%,
      rgba(46, 88, 255, 0.15),
      transparent 60%
    ),
    radial-gradient(
      900px 700px at 90% 20%,
      rgba(120, 60, 255, 0.12),
      transparent 65%
    ),
    linear-gradient(160deg, var(--bg-deep), var(--bg-mid) 60%, var(--bg-accent));
  color: var(--text-primary);
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  display: flex;
  justify-content: center;
  padding: 18px 12px 28px;
  overflow-x: hidden;
  position: relative;
}

.space-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.stars-far {
  position: absolute;
  inset: -200px;
  background-image:
    radial-gradient(1px 1px at 8% 12%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 22% 38%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 35% 5%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 48% 55%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1px 1px at 61% 22%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(1px 1px at 74% 70%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 85% 14%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 92% 46%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1px 1px at 15% 80%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 55% 88%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(200, 220, 255, 0.55), transparent),
    radial-gradient(1px 1px at 68% 33%, rgba(200, 220, 255, 0.6), transparent),
    radial-gradient(1px 1px at 78% 90%, rgba(200, 220, 255, 0.5), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 42% 18%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 96% 75%, rgba(255, 255, 255, 0.65), transparent);
  background-size: 700px 500px;
  animation: stars-drift-far 40s linear infinite;
}

.stars-near {
  position: absolute;
  inset: -200px;
  background-image:
    radial-gradient(2px 2px at 12% 25%, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(2px 2px at 33% 60%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(2px 2px at 57% 10%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(2px 2px at 80% 42%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(2px 2px at 90% 8%, rgba(180, 210, 255, 0.9), transparent),
    radial-gradient(2px 2px at 20% 75%, rgba(180, 210, 255, 0.8), transparent),
    radial-gradient(2px 2px at 66% 85%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(2px 2px at 44% 48%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(3px 3px at 72% 28%, rgba(255, 220, 180, 0.8), transparent),
    radial-gradient(2px 2px at 3% 90%, rgba(255, 255, 255, 0.75), transparent);
  background-size: 900px 700px;
  animation: stars-drift-near 22s linear infinite;
}

@keyframes stars-drift-far {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-500px);
  }
}

@keyframes stars-drift-near {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-700px);
  }
}

.black-hole {
  position: absolute;
  bottom: 4%;
  right: 4%;
  width: clamp(140px, 18vw, 220px);
  height: clamp(140px, 18vw, 220px);
}

.bh-disk {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0%,
    rgba(255, 100, 20, 0.55) 10%,
    rgba(255, 180, 60, 0.7) 22%,
    rgba(255, 230, 120, 0.5) 32%,
    rgba(160, 80, 255, 0.45) 48%,
    rgba(80, 140, 255, 0.4) 62%,
    rgba(255, 100, 20, 0.35) 78%,
    transparent 100%
  );
  filter: blur(6px);
  animation: bh-spin 9s linear infinite;
  transform-origin: center;
}

.bh-glow {
  position: absolute;
  inset: -35%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(140, 40, 255, 0.18) 0%,
    rgba(60, 20, 120, 0.12) 40%,
    transparent 70%
  );
  animation: bh-pulse 5s ease-in-out infinite alternate;
}

.bh-core {
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: #000;
  box-shadow:
    0 0 20px 8px rgba(0, 0, 0, 0.9),
    0 0 50px 16px rgba(60, 0, 100, 0.5),
    0 0 100px 30px rgba(40, 0, 80, 0.25);
}

.bh-orbit {
  position: absolute;
  inset: -45%;
  border-radius: 50%;
  border: 1px solid rgba(160, 200, 255, 0.12);
  animation: bh-orbit 7s linear infinite;
}

.bh-satellite {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #c8e0ff, #6090d0);
  box-shadow: 0 0 10px 3px rgba(160, 210, 255, 0.8);
}

@keyframes bh-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes bh-orbit {
  to {
    transform: rotate(-360deg);
  }
}
@keyframes bh-pulse {
  from {
    opacity: 0.6;
    transform: scale(1);
  }
  to {
    opacity: 1;
    transform: scale(1.25);
  }
}

.nebula-left {
  position: absolute;
  top: 10%;
  left: -10%;
  width: 40vw;
  height: 60vh;
  background: radial-gradient(
    ellipse at 30% 50%,
    rgba(60, 80, 255, 0.1),
    transparent 65%
  );
  animation: nebula-breathe 12s ease-in-out infinite alternate;
}

.nebula-right {
  position: absolute;
  top: 30%;
  right: -8%;
  width: 35vw;
  height: 55vh;
  background: radial-gradient(
    ellipse at 70% 40%,
    rgba(140, 40, 220, 0.09),
    transparent 65%
  );
  animation: nebula-breathe 16s ease-in-out infinite alternate-reverse;
}

@keyframes nebula-breathe {
  from {
    opacity: 0.5;
    transform: scale(1);
  }
  to {
    opacity: 1;
    transform: scale(1.15);
  }
}

.app {
  width: min(440px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 13px;
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  gap: 6px;
  text-align: left;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.title {
  font-family: "Orbitron", "Space Grotesk", sans-serif;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 18px var(--glow-strong);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-card {
  display: grid;
  gap: 4px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(140, 180, 255, 0.25);
  background: rgba(12, 20, 50, 0.65);
  box-shadow: inset 0 0 16px rgba(80, 140, 255, 0.12);
}

.score-label {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.score-value,
.best-value {
  font-family: "Orbitron", "Space Grotesk", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 12px rgba(120, 200, 255, 0.45);
}

.board-shell {
  background: linear-gradient(
    140deg,
    rgba(9, 15, 40, 0.9),
    rgba(16, 23, 60, 0.9)
  );
  border: 1px solid var(--grid-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 14px 48px rgba(8, 12, 40, 0.6),
    inset 0 0 24px rgba(80, 140, 255, 0.15);
  padding: 12px;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  aspect-ratio: 1;
}

.grid-cell {
  background: var(--cell-bg);
  border-radius: var(--radius-sm);
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.4),
    0 0 12px var(--cell-glow);
  border: 1px solid rgba(140, 180, 255, 0.12);
}

.board-shell {
  position: relative;
}

.tile-container {
  position: absolute;
  inset: 0;
  padding: 12px;
  contain: layout style paint;
}

.tile {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Orbitron", "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: #e6eefc;
  user-select: none;

  will-change: transform, left, top;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000px;
  isolation: isolate;
  z-index: 2;
}

.tile.tile-moving {
  transition:
    left 95ms cubic-bezier(0.16, 1, 0.3, 1),
    top 95ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tile.tile-undo-moving {
  transition:
    left 220ms cubic-bezier(0.16, 1, 0.3, 1),
    top 220ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.tile.tile-ghost {
  z-index: 1;
}

.tile.tile-ghost.tile-moving {
  transition:
    left 95ms cubic-bezier(0.16, 1, 0.3, 1),
    top 95ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 95ms ease-out;
}

.tile-2 {
  background: rgba(100, 140, 255, 0.45);
  border: 1px solid rgba(100, 140, 255, 0.6);
}
.tile-4 {
  background: rgba(130, 100, 255, 0.5);
  border: 1px solid rgba(130, 100, 255, 0.65);
}
.tile-8 {
  background: rgba(60, 180, 255, 0.55);
  border: 1px solid rgba(60, 180, 255, 0.7);
  font-size: 1.2rem;
}
.tile-16 {
  background: rgba(40, 220, 200, 0.55);
  border: 1px solid rgba(40, 220, 200, 0.7);
  font-size: 1.1rem;
}
.tile-32 {
  background: rgba(80, 240, 140, 0.55);
  border: 1px solid rgba(80, 240, 140, 0.7);
  font-size: 1.1rem;
}
.tile-64 {
  background: rgba(255, 200, 60, 0.6);
  border: 1px solid rgba(255, 200, 60, 0.75);
  font-size: 1.05rem;
}
.tile-128 {
  background: rgba(255, 140, 50, 0.65);
  border: 1px solid rgba(255, 140, 50, 0.8);
  font-size: 0.95rem;
  box-shadow: 0 0 18px rgba(255, 140, 50, 0.4);
}
.tile-256 {
  background: rgba(255, 80, 80, 0.65);
  border: 1px solid rgba(255, 80, 80, 0.8);
  font-size: 0.9rem;
  box-shadow: 0 0 22px rgba(255, 80, 80, 0.45);
}
.tile-512 {
  background: rgba(220, 60, 220, 0.65);
  border: 1px solid rgba(220, 60, 220, 0.8);
  font-size: 0.82rem;
  box-shadow: 0 0 26px rgba(220, 60, 220, 0.45);
}
.tile-1024 {
  background: rgba(100, 200, 255, 0.8);
  border: 1px solid rgba(100, 200, 255, 0.9);
  font-size: 0.72rem;
  box-shadow: 0 0 32px rgba(100, 200, 255, 0.55);
}
.tile-2048 {
  background: rgba(255, 230, 80, 0.9);
  border: 1px solid #ffe650;
  color: #1a1a2e;
  font-size: 0.72rem;
  box-shadow: 0 0 40px rgba(255, 230, 80, 0.7);
}
.tile-super {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #fff;
  color: #1a1a2e;
  font-size: 0.62rem;
  box-shadow: 0 0 50px rgba(255, 255, 255, 0.6);
}

.tile-new {
  animation: tile-appear 0.25s ease-out 0.07s both;
}

.tile-merged {
  z-index: 3;
  will-change: transform, opacity, box-shadow;
  animation: tile-pop 0.24s ease-out 0.1s both;
}

@keyframes tile-appear {
  0% {
    opacity: 0;
    transform: scale(0.16);
  }
  52% {
    opacity: 1;
    transform: scale(1.1);
  }
  78% {
    transform: scale(0.97);
  }
  91% {
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes tile-pop {
  0% {
    transform: scale(0.82);
  }
  45% {
    transform: scale(1.12);
  }
  72% {
    transform: scale(0.97);
  }
  88% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

.game-message {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(6px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  z-index: 50;
  animation: overlay-fade 0.3s ease;
}

.game-message.active {
  display: flex;
}

.game-message.won {
  background: rgba(255, 230, 80, 0.18);
}
.game-message.over {
  background: rgba(5, 7, 20, 0.72);
}

.game-message-text {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 900;
  color: #e6eefc;
  text-shadow: 0 0 20px rgba(120, 200, 255, 0.7);
}

.game-message.won .game-message-text {
  color: #ffe650;
  text-shadow: 0 0 24px rgba(255, 230, 80, 0.8);
}

.retry-button {
  padding: 10px 28px;
  border-radius: 100px;
  border: 1px solid rgba(140, 180, 255, 0.5);
  background: rgba(120, 150, 255, 0.2);
  color: #e6eefc;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
}

.retry-button:hover {
  background: rgba(120, 150, 255, 0.38);
  transform: translateY(-2px);
}

.retry-button:active {
  transform: translateY(0);
}

@keyframes overlay-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.new-game-button {
  margin-left: auto;
  padding: 9px 22px;
  border-radius: 100px;
  border: 1px solid rgba(140, 180, 255, 0.35);
  background: rgba(120, 150, 255, 0.15);
  color: #e6eefc;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
}

.new-game-button:hover {
  background: rgba(120, 150, 255, 0.3);
  transform: translateY(-1px);
}

.new-game-button:active {
  transform: translateY(0);
}

.undo-button {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(100, 220, 180, 0.4);
  background: rgba(60, 200, 160, 0.12);
  color: #a0f0d8;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s,
    opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.undo-button .undo-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(60, 200, 160, 0.3);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.undo-button:hover:not(:disabled) {
  background: rgba(60, 200, 160, 0.25);
  transform: translateY(-1px);
}

.undo-button:active:not(:disabled) {
  transform: translateY(0);
}

.undo-button:disabled,
.undo-button.undo-exhausted {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(140, 180, 255, 0.2);
  color: var(--text-muted);
}

.exchange-button {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(200, 120, 255, 0.4);
  background: rgba(180, 80, 255, 0.12);
  color: #e0b0ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s,
    opacity 0.2s,
    box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.exchange-button .exchange-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(180, 80, 255, 0.3);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.exchange-button:hover:not(:disabled) {
  background: rgba(180, 80, 255, 0.25);
  transform: translateY(-1px);
}

.exchange-button:active:not(:disabled) {
  transform: translateY(0);
}

.exchange-button.exchange-active {
  background: rgba(180, 80, 255, 0.28);
  border-color: rgba(200, 120, 255, 0.75);
  box-shadow: 0 0 12px rgba(180, 80, 255, 0.45);
  color: #f0d0ff;
}

.exchange-button:disabled,
.exchange-button.exchange-exhausted {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(140, 180, 255, 0.2);
  color: var(--text-muted);
}

.remove-button {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 60, 40, 0.45);
  background: rgba(200, 30, 20, 0.13);
  color: #ff9988;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s,
    opacity 0.2s,
    box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.remove-button .remove-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(200, 30, 20, 0.32);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.remove-button:hover:not(:disabled) {
  background: rgba(200, 30, 20, 0.26);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(220, 40, 20, 0.3);
}

.remove-button:active:not(:disabled) {
  transform: translateY(0);
}

.remove-button.remove-active {
  background: rgba(200, 30, 20, 0.3);
  border-color: rgba(255, 80, 60, 0.8);
  box-shadow:
    0 0 14px rgba(220, 40, 20, 0.55),
    0 0 30px rgba(180, 0, 0, 0.2);
  color: #ffbbaa;
  animation: remove-btn-pulse 1.1s ease-in-out infinite alternate;
}

@keyframes remove-btn-pulse {
  from {
    box-shadow:
      0 0 10px rgba(220, 40, 20, 0.45),
      0 0 22px rgba(180, 0, 0, 0.15);
  }
  to {
    box-shadow:
      0 0 20px rgba(255, 60, 30, 0.75),
      0 0 44px rgba(220, 0, 0, 0.3),
      inset 0 0 8px rgba(255, 60, 0, 0.15);
  }
}

.remove-button:disabled,
.remove-button.remove-exhausted {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(140, 180, 255, 0.2);
  color: var(--text-muted);
}

.help-link-row {
  display: flex;
  justify-content: center;
  margin-top: -2px;
}

.help-button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  cursor: pointer;
  padding: 4px 8px;
  letter-spacing: 0.3px;
  opacity: 0.55;
  transition:
    opacity 0.2s,
    color 0.2s;
  text-decoration: none;
}

.help-button:hover {
  opacity: 1;
  color: #c8d8ff;
}

.help-button:active {
  opacity: 0.8;
}

.mute-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(140, 200, 255, 0.3);
  background: rgba(80, 140, 255, 0.1);
  color: #c8e0ff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s,
    opacity 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.mute-button:hover {
  background: rgba(80, 140, 255, 0.22);
  border-color: rgba(140, 200, 255, 0.55);
  transform: translateY(-1px);
}

.mute-button:active {
  transform: translateY(0);
}

.mute-button[aria-pressed="true"] {
  opacity: 0.45;
  background: rgba(60, 60, 90, 0.18);
  border-color: rgba(100, 100, 160, 0.3);
}

.mute-icon {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 5, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
  padding: 20px;
}

.help-overlay.help-open {
  opacity: 1;
  visibility: visible;
}

.help-modal {
  position: relative;
  width: min(560px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(
    170deg,
    rgba(15, 22, 55, 0.97),
    rgba(8, 12, 35, 0.98) 60%,
    rgba(5, 8, 22, 0.99)
  );
  border: 1px solid rgba(140, 180, 255, 0.2);
  border-radius: 16px;
  padding: 34px 32px 28px;
  box-shadow:
    0 0 50px rgba(80, 120, 255, 0.14),
    0 10px 40px rgba(0, 0, 0, 0.55);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}

.help-overlay.help-open .help-modal {
  transform: translateY(0) scale(1);
}

.help-modal::-webkit-scrollbar {
  width: 5px;
}
.help-modal::-webkit-scrollbar-track {
  background: transparent;
}
.help-modal::-webkit-scrollbar-thumb {
  background: rgba(140, 180, 255, 0.2);
  border-radius: 3px;
}

.help-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(140, 180, 255, 0.25);
  background: rgba(80, 120, 255, 0.1);
  color: #c8d8ff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.15s;
  line-height: 1;
  padding: 0;
}

.help-close:hover {
  background: rgba(80, 120, 255, 0.25);
  transform: scale(1.05);
}

.help-title {
  font-family: "Orbitron", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffe680;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.help-section {
  margin-bottom: 16px;
}

.help-section h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  color: #c8d8ff;
  margin-bottom: 7px;
  letter-spacing: 0.5px;
}

.help-section p,
.help-section li {
  font-size: 0.86rem;
  color: #a8b8d8;
  line-height: 1.6;
}

.help-muted {
  font-size: 0.72rem;
  color: #7888a8;
  font-weight: 400;
}

.help-rules {
  padding-left: 18px;
  margin: 0;
}

.help-rules li {
  margin-bottom: 3px;
}

.help-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.help-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #a8b8d8;
}

.help-key {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(120, 150, 255, 0.15);
  border: 1px solid rgba(140, 180, 255, 0.25);
  color: #d0e0ff;
  font-family: "Space Grotesk", monospace;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.help-powers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-power {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.help-power-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.help-power-undo {
  background: rgba(60, 200, 160, 0.15);
  border: 1px solid rgba(100, 220, 180, 0.3);
  color: #a0f0d8;
}

.help-power-swap {
  background: rgba(180, 80, 255, 0.15);
  border: 1px solid rgba(200, 120, 255, 0.3);
  color: #e0b0ff;
}

.help-power-remove {
  background: rgba(200, 30, 20, 0.15);
  border: 1px solid rgba(255, 60, 40, 0.3);
  color: #ff9988;
}

.help-power div strong {
  font-size: 0.84rem;
  color: #d0e0ff;
}

.help-power div p {
  margin-top: 1px;
  font-size: 0.78rem;
}

.help-tips ul {
  padding-left: 18px;
  margin: 0;
}

.help-tips li {
  margin-bottom: 3px;
}

.swap-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(5, 8, 28, 0.92);
  border: 1px solid rgba(255, 215, 0, 0.45);
  color: #ffe066;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 18px;
  border-radius: 100px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
  box-shadow:
    0 0 14px rgba(255, 200, 0, 0.22),
    inset 0 0 10px rgba(255, 200, 0, 0.07);
}

.swap-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.swap-hint.step2 {
  background: rgba(12, 6, 30, 0.94);
  border-color: rgba(200, 120, 255, 0.65);
  color: #e8b0ff;
  box-shadow:
    0 0 16px rgba(180, 80, 255, 0.3),
    inset 0 0 10px rgba(160, 60, 255, 0.1);
}

.swap-hint.pending {
  background: rgba(0, 18, 30, 0.96);
  border-color: rgba(0, 220, 255, 0.75);
  color: #80f0ff;
  box-shadow:
    0 0 18px rgba(0, 200, 255, 0.38),
    inset 0 0 10px rgba(0, 180, 255, 0.12);
  animation: hint-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes hint-pulse {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

.exchange-button {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(200, 120, 255, 0.4);
  background: rgba(180, 80, 255, 0.12);
  color: #e0b0ff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s,
    opacity 0.2s,
    box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.exchange-button .exchange-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(180, 80, 255, 0.3);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.exchange-button:hover:not(:disabled) {
  background: rgba(180, 80, 255, 0.25);
  transform: translateY(-1px);
}

.exchange-button:active:not(:disabled) {
  transform: translateY(0);
}

.exchange-button.exchange-active {
  background: rgba(180, 80, 255, 0.28);
  border-color: rgba(200, 120, 255, 0.75);
  box-shadow: 0 0 12px rgba(180, 80, 255, 0.45);
  color: #f0d0ff;
}

.exchange-button:disabled,
.exchange-button.exchange-exhausted {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(140, 180, 255, 0.2);
  color: var(--text-muted);
}

.board-shell.exchange-mode .tile-container {
  cursor: default;
}

.tile.tile-exchangeable {
  cursor: pointer;
  filter: brightness(0.38) saturate(0.18);
  opacity: 0.52;
  transition:
    filter 0.25s ease,
    opacity 0.25s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.tile.tile-exchangeable:hover:not(.tile-exchange-selected) {
  filter: brightness(0.62) saturate(0.45);
  opacity: 0.78;
  box-shadow:
    0 0 0 2px rgba(255, 215, 0, 0.45),
    0 0 12px 3px rgba(255, 190, 0, 0.2);
  transform: scale(1.04);
}

.tile.tile-exchange-selected {
  cursor: pointer;
  z-index: 10;
  overflow: visible;

  filter: brightness(1.18) saturate(1.45) !important;
  opacity: 1 !important;
  transition: none !important;
  animation:
    gold-star-lift 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    gold-star-breathe 0.88s ease-in-out 0.22s infinite alternate,
    tile-selected-shake 0.72s ease-in-out 0.22s infinite;
}

.tile.tile-exchange-selected::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 16px;
  background: conic-gradient(
    from 0deg,
    #ffd700 0%,
    #fff9b0 4%,
    #fffde7 7%,
    transparent 11%,
    #ffb300 20%,
    #ffe082 24%,
    #ffffff 27%,
    transparent 31%,
    #ffd700 40%,
    #fff59d 44%,
    #ffe57a 47%,
    transparent 51%,
    #ffca28 60%,
    #ffffff 64%,
    #fffde7 67%,
    transparent 71%,
    #ff8f00 80%,
    #ffe082 84%,
    #ffffff 87%,
    transparent 91%,
    #ffd700 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  -webkit-mask-composite: destination-out;
  mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  mask-composite: exclude;
  animation: sparkle-ring-spin 1.1s linear infinite;
  filter: blur(0.4px) brightness(1.25) contrast(1.1);
  pointer-events: none;
}

@keyframes sparkle-ring-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes gold-star-lift {
  0% {
    transform: scale(1);
  }
  60% {
    transform: scale(1.18);
  }
  80% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1.11);
  }
}

@keyframes gold-star-breathe {
  from {
    box-shadow:
      0 0 0 2.5px #ffd700,
      0 0 0 5px rgba(255, 215, 0, 0.3),
      0 0 14px 6px rgba(255, 210, 0, 0.65),
      0 0 30px 10px rgba(255, 168, 0, 0.38),
      0 0 52px 14px rgba(255, 118, 0, 0.16);
    transform: scale(1.11);
  }
  to {
    box-shadow:
      0 0 0 3px #fff176,
      0 0 0 7px rgba(255, 240, 0, 0.38),
      0 0 22px 9px rgba(255, 248, 0, 0.95),
      0 0 46px 16px rgba(255, 210, 0, 0.62),
      0 0 78px 22px rgba(255, 150, 0, 0.28),
      inset 0 0 20px rgba(255, 255, 100, 0.2);
    transform: scale(1.11);
  }
}

@keyframes tile-selected-shake {
  0% {
    transform: scale(1.11) translate(0, 0);
  }
  10% {
    transform: scale(1.11) translate(-2px, -1.2px);
  }
  20% {
    transform: scale(1.11) translate(2px, 1.2px);
  }
  30% {
    transform: scale(1.11) translate(-1.2px, 2px);
  }
  40% {
    transform: scale(1.11) translate(1.2px, -2px);
  }
  50% {
    transform: scale(1.11) translate(-1.8px, 1px);
  }
  60% {
    transform: scale(1.11) translate(1.8px, -1px);
  }
  70% {
    transform: scale(1.11) translate(-1px, 1.6px);
  }
  80% {
    transform: scale(1.11) translate(1px, -0.8px);
  }
  90% {
    transform: scale(1.11) translate(-0.6px, 0.6px);
  }
  100% {
    transform: scale(1.11) translate(0, 0);
  }
}

.swap-star {
  position: absolute;
  border-radius: 50%;
  transform-origin: center;
  pointer-events: none;
  z-index: 30;

  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  animation: star-fly 680ms cubic-bezier(0.2, 0.8, 0.4, 1) both;
}

@keyframes star-fly {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(0);
    opacity: 1;
  }
  18% {
    transform: translate(
        calc(-50% + var(--tx) * 0.3),
        calc(-50% + var(--ty) * 0.3)
      )
      rotate(120deg) scale(1.5);
    opacity: 1;
  }
  60% {
    opacity: 0.85;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)))
      rotate(360deg) scale(0.15);
    opacity: 0;
  }
}

.tile.tile-exchange-second {
  filter: brightness(1.15) saturate(1.4) hue-rotate(160deg) !important;
}

.tile.tile-exchange-second::before {
  inset: -10px;
  border-radius: 16px;
  background: conic-gradient(
    from 0deg,
    #00e5ff 0%,
    #b2f5ff 4%,
    #e0faff 7%,
    transparent 11%,
    #00bcd4 20%,
    #80deea 24%,
    #ffffff 27%,
    transparent 31%,
    #00e5ff 40%,
    #b2ebf2 44%,
    #e0f7fa 47%,
    transparent 51%,
    #0097a7 60%,
    #ffffff 64%,
    #b2f5ff 67%,
    transparent 71%,
    #00acc1 80%,
    #80deea 84%,
    #ffffff 87%,
    transparent 91%,
    #00e5ff 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  -webkit-mask-composite: destination-out;
  mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  mask-composite: exclude;
  animation: sparkle-ring-spin 0.9s linear infinite reverse;
  filter: blur(0.4px) brightness(1.25) contrast(1.1);
}

.tile.tile-exchange-second.tile-exchange-selected {
  animation:
    gold-star-lift 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    cyan-star-breathe 0.88s ease-in-out 0.22s infinite alternate,
    tile-selected-shake 0.72s ease-in-out 0.22s infinite;
}

@keyframes cyan-star-breathe {
  from {
    box-shadow:
      0 0 0 2.5px #00e5ff,
      0 0 0 4px rgba(0, 229, 255, 0.22),
      0 0 12px 5px rgba(0, 200, 255, 0.55),
      0 0 26px 8px rgba(0, 160, 220, 0.3),
      0 0 44px 10px rgba(0, 120, 190, 0.12);
    transform: scale(1.11);
  }
  to {
    box-shadow:
      0 0 0 2.5px #80f0ff,
      0 0 0 5px rgba(0, 240, 255, 0.28),
      0 0 18px 7px rgba(0, 230, 255, 0.8),
      0 0 38px 12px rgba(0, 200, 240, 0.45),
      0 0 62px 16px rgba(0, 160, 220, 0.18);
    transform: scale(1.11);
  }
}

.tile.tile-exchange-swap {
  overflow: visible;

  transition:
    left 360ms cubic-bezier(0.22, 1.6, 0.36, 1),
    top 360ms cubic-bezier(0.22, 1.6, 0.36, 1);
  animation: exchange-boom-arc 360ms cubic-bezier(0.22, 1.6, 0.36, 1) both;
  z-index: 15;
}

@keyframes exchange-boom-arc {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  18% {
    transform: scale(1.45);
    filter: brightness(1.6);
  }
  55% {
    transform: scale(0.88);
    filter: brightness(1.2);
  }
  78% {
    transform: scale(1.06);
    filter: brightness(1.1);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.tile.tile-exchange-swap::after {
  content: "";
  position: absolute;
  inset: 50%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 230, 80, 0.8) 20%,
    rgba(255, 160, 0, 0.5) 42%,
    rgba(255, 100, 0, 0.2) 65%,
    transparent 85%
  );
  pointer-events: none;
  animation: swap-flash-ring 400ms ease-out both;
  z-index: 20;
}

@keyframes swap-flash-ring {
  0% {
    inset: 50%;
    opacity: 1;
  }
  35% {
    inset: -28px;
    opacity: 0.9;
  }
  100% {
    inset: -60px;
    opacity: 0;
  }
}

.board-shell.remove-mode .tile-container {
  cursor: crosshair;
}

.tile.tile-removeable {
  cursor: crosshair;
  filter: brightness(0.32) saturate(0.15);
  opacity: 0.5;
  transition:
    filter 0.22s ease,
    opacity 0.22s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.tile.tile-removeable:hover:not(.tile-remove-target) {
  filter: brightness(0.55) saturate(0.35);
  opacity: 0.75;
  box-shadow:
    0 0 0 2px rgba(255, 60, 30, 0.55),
    0 0 14px 4px rgba(220, 30, 10, 0.28);
  transform: scale(1.04);
}

.tile.tile-remove-target {
  cursor: crosshair;
  z-index: 10;
  filter: brightness(1.15) saturate(1.3) !important;
  opacity: 1 !important;

  transition: none !important;
}

.tile.tile-remove-target::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 16px;
  background: conic-gradient(
    from 0deg,
    #ff1a00 0%,
    #ff6644 5%,
    #ffccb0 9%,
    transparent 13%,
    #cc0000 25%,
    #ff4422 30%,
    #ffffff 33%,
    transparent 37%,
    #ff1a00 48%,
    #ff7755 53%,
    #ffddcc 57%,
    transparent 61%,
    #aa0000 72%,
    #ff3311 77%,
    #ffffff 80%,
    transparent 84%,
    #ff1a00 95%,
    #ff6644 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  -webkit-mask-composite: destination-out;
  mask:
    linear-gradient(#fff 0 0),
    linear-gradient(#fff 0 0) 10px 10px / calc(100% - 20px) calc(100% - 20px)
      no-repeat;
  mask-composite: exclude;
  animation: danger-ring-spin 0.65s linear infinite;
  filter: blur(0.5px) brightness(1.3);
  pointer-events: none;
}

@keyframes danger-ring-spin {
  to {
    transform: rotate(360deg);
  }
}

.remove-sparkle {
  position: absolute;
  pointer-events: none;
  z-index: 25;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--s-color, #ff2a1a);
  box-shadow:
    0 0 5px 2px var(--s-color, rgba(255, 40, 20, 0.6)),
    0 0 10px 3px rgba(255, 60, 20, 0.3);
  animation: remove-sparkle-burst var(--s-dur, 400ms)
    cubic-bezier(0.15, 0, 0.35, 1) forwards;
  opacity: 0;
}

@keyframes remove-sparkle-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  15% {
    transform: translate(
        calc(-50% + var(--s-tx) * 0.1),
        calc(-50% + var(--s-ty) * 0.1)
      )
      scale(1.4);
    opacity: 1;
  }
  45% {
    transform: translate(
        calc(-50% + var(--s-tx) * 0.5),
        calc(-50% + var(--s-ty) * 0.5)
      )
      scale(1);
    opacity: 0.85;
  }
  75% {
    transform: translate(
        calc(-50% + var(--s-tx) * 0.85),
        calc(-50% + var(--s-ty) * 0.85)
      )
      scale(0.5);
    opacity: 0.4;
  }
  100% {
    transform: translate(calc(-50% + var(--s-tx)), calc(-50% + var(--s-ty)))
      scale(0);
    opacity: 0;
  }
}

.remove-ember {
  position: absolute;
  pointer-events: none;
  z-index: 24;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px 3px rgba(120, 0, 0, 0.4);
  animation: remove-ember-drift var(--e-dur, 400ms) cubic-bezier(0.3, 0, 0.5, 1)
    forwards;
  opacity: 0;
}

@keyframes remove-ember-drift {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
  20% {
    transform: translate(
        calc(-50% + var(--e-tx) * 0.15),
        calc(-50% + var(--e-ty) * 0.15)
      )
      scale(1.2);
    opacity: 0.7;
  }
  60% {
    transform: translate(
        calc(-50% + var(--e-tx) * 0.6),
        calc(-50% + var(--e-ty) * 0.6)
      )
      scale(0.8);
    opacity: 0.4;
  }
  100% {
    transform: translate(calc(-50% + var(--e-tx)), calc(-50% + var(--e-ty)))
      scale(0);
    opacity: 0;
  }
}

.remove-ring {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 24;
  border: 2px solid rgba(255, 50, 20, 0.8);
  box-shadow:
    0 0 14px 5px rgba(255, 40, 10, 0.4),
    0 0 6px 2px rgba(200, 20, 0, 0.3);
  animation: remove-ring-expand 450ms cubic-bezier(0.2, 0, 0.3, 1) forwards;
}

@keyframes remove-ring-expand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    border-color: rgba(255, 80, 30, 0.9);
    box-shadow: 0 0 18px 6px rgba(255, 50, 10, 0.5);
  }
  40% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0.6;
    border-color: rgba(200, 30, 0, 0.6);
    box-shadow: 0 0 12px 4px rgba(180, 20, 0, 0.3);
  }
  100% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
    border-color: rgba(80, 0, 0, 0);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  }
}

.swap-hint.remove-step {
  background: rgba(28, 4, 4, 0.94);
  border-color: rgba(255, 70, 40, 0.7);
  color: #ff9988;
  box-shadow:
    0 0 16px rgba(220, 40, 10, 0.32),
    inset 0 0 10px rgba(200, 20, 0, 0.12);
}

.swap-hint.remove-pending {
  background: rgba(30, 0, 0, 0.96);
  border-color: rgba(255, 30, 0, 0.9);
  color: #ffccbb;
  box-shadow:
    0 0 22px rgba(255, 30, 0, 0.55),
    inset 0 0 12px rgba(200, 0, 0, 0.18);
  animation: hint-pulse 0.4s ease-in-out infinite alternate;
}

@media (max-width: 520px) {
  .help-modal {
    width: min(440px, 94vw);
    padding: 26px 22px 22px;
    border-radius: 14px;
  }
  .help-title {
    font-size: 1.2rem;
    margin-bottom: 14px;
  }
  .help-section h3 {
    font-size: 0.88rem;
  }
  .help-section p,
  .help-section li {
    font-size: 0.8rem;
  }
  body {
    min-height: 100dvh;
    margin-top: 25px;
    align-items: flex-start;
    padding: 8px 16px 20px;
  }
  :root {
    --gap: 8px;
  }
  .app {
    width: min(440px, 90vw);
    gap: 10px;
  }
  .hero {
    margin-bottom: 20px;
    row-gap: 10px;
  }
  .board-shell {
    padding: 9px;
  }
  .tile-container {
    padding: 9px;
  }
  .tile {
    font-size: 1rem;
  }
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 0.78rem;
  }
  .tile-1024,
  .tile-2048,
  .tile-super {
    font-size: 0.62rem;
  }
  .score-card {
    padding: 7px 9px;
  }
  .controls-row {
    gap: 7px;
  }
  .new-game-button,
  .undo-button,
  .exchange-button,
  .remove-button {
    padding: 8px 14px;
    font-size: 0.8rem;
  }
}

@media (max-width: 420px) {
  .help-modal {
    width: 96vw;
    max-height: 82vh;
    padding: 22px 18px 18px;
    border-radius: 12px;
  }
  .help-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }
  .help-section h3 {
    font-size: 0.84rem;
  }
  .help-section p,
  .help-section li {
    font-size: 0.76rem;
  }
  .help-close {
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    top: 10px;
    right: 12px;
  }
  body {
    min-height: 100dvh;

    padding: 6px 18px 16px;
  }
  :root {
    --gap: 7px;
  }
  .app {
    width: 100%;
    gap: 9px;
  }
  .hero {
    margin-bottom: 5px;
  }
  .board-shell {
    padding: 8px;
  }
  .tile-container {
    padding: 8px;
  }
  .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 2px;
  }
  .subtitle {
    font-size: 0.72rem;
  }
  .score-card {
    padding: 6px 8px;
  }
  .score-value,
  .best-value {
    font-size: 0.95rem;
  }
  .controls-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .new-game-button,
  .undo-button,
  .exchange-button,
  .remove-button {
    padding: 7px 12px;
    font-size: 0.78rem;
  }
  .help-button {
    font-size: 0.72rem;
  }
  .mute-button {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
  .tile {
    font-size: 0.9rem;
  }
  .tile-64 {
    font-size: 0.88rem;
  }
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 0.72rem;
  }
  .tile-1024,
  .tile-2048,
  .tile-super {
    font-size: 0.58rem;
  }
  .swap-hint {
    font-size: 0.7rem;
    padding: 5px 14px;
  }
}

@media (max-width: 360px) {
  .help-modal {
    width: 98vw;
    max-height: 80vh;
    padding: 18px 14px 14px;
    border-radius: 10px;
  }
  .help-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }
  .help-section {
    margin-bottom: 12px;
  }
  .help-section h3 {
    font-size: 0.78rem;
  }
  .help-section p,
  .help-section li {
    font-size: 0.72rem;
  }
  .help-key {
    font-size: 0.68rem;
    padding: 1px 6px;
  }
  .help-close {
    width: 26px;
    height: 26px;
    font-size: 1rem;
    top: 8px;
    right: 10px;
  }
  :root {
    --gap: 6px;
  }
  body {
    min-height: 100dvh;
    align-items: flex-start;
    padding: 4px 14px 14px;
  }
  .app {
    width: 100%;
    gap: 7px;
  }
  .hero {
    margin-bottom: 4px;
  }
  .board-shell {
    padding: 7px;
  }
  .tile-container {
    padding: 7px;
  }
  .score-row {
    gap: 7px;
  }
  .score-card {
    padding: 5px 7px;
  }
  .score-label {
    font-size: 0.58rem;
  }
  .score-value,
  .best-value {
    font-size: 0.88rem;
  }
  .controls-row {
    flex-wrap: wrap;
    gap: 5px;
  }
  .new-game-button,
  .undo-button,
  .exchange-button,
  .remove-button {
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .help-button {
    font-size: 0.66rem;
  }
  .mute-button {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }
  .tile {
    font-size: 0.82rem;
  }
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 0.66rem;
  }
  .tile-1024,
  .tile-2048,
  .tile-super {
    font-size: 0.52rem;
  }
  .swap-hint {
    font-size: 0.64rem;
    padding: 4px 12px;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  body {
    padding: 6px 12px 10px;
  }
  .app {
    width: min(400px, 55vw);
    gap: 7px;
  }
  .hero {
    gap: 2px;
  }
  .eyebrow {
    display: none;
  }
  .subtitle {
    display: none;
  }
  .score-card {
    padding: 5px 9px;
  }
  .black-hole {
    display: none;
  }
}
