:root {
  --bg: #05060c;
  --panel: rgba(11, 15, 28, 0.84);
  --panel-strong: rgba(8, 11, 20, 0.96);
  --text: #e8fbff;
  --muted: #89a2b5;
  --accent: #00f5ff;
  --accent-2: #ff4fd8;
  --accent-3: #7cff6b;
  --grid: rgba(120, 183, 255, 0.14);
  --cell: rgba(15, 21, 36, 0.9);
  --cell-border: rgba(125, 255, 244, 0.1);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Rajdhani", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 79, 216, 0.2), transparent 24%),
    radial-gradient(circle at 80% 15%, rgba(0, 245, 255, 0.18), transparent 22%),
    radial-gradient(circle at 50% 85%, rgba(124, 255, 107, 0.12), transparent 25%),
    linear-gradient(135deg, #05060c 0%, #070b16 48%, #02040a 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01) 2px, transparent 2px, transparent 6px);
  background-size: 100% 6px;
  mix-blend-mode: screen;
  opacity: 0.18;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.45) 100%);
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(0, 245, 255, 0.09), transparent 25%),
    linear-gradient(300deg, rgba(255, 79, 216, 0.08), transparent 30%);
  filter: blur(40px);
}

.shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 42px 0 48px;
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.28em;
  font-size: 0.84rem;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 0 14px rgba(0, 245, 255, 0.55), 0 0 34px rgba(255, 79, 216, 0.24);
}

.subtitle {
  max-width: 42rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.14rem;
  line-height: 1.55;
}

.hud {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat,
.action {
  border: 1px solid rgba(119, 227, 255, 0.18);
  background: linear-gradient(180deg, rgba(20, 25, 40, 0.92), rgba(8, 12, 22, 0.98));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.stat {
  min-width: 110px;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-family: "Orbitron", sans-serif;
  font-size: 1.7rem;
  color: #f6feff;
  text-shadow: 0 0 12px rgba(0, 245, 255, 0.22);
}

.action {
  border-radius: 999px;
  padding: 0 20px;
  min-height: 52px;
  color: var(--text);
  font: 700 0.95rem/1 "Orbitron", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.action:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 245, 255, 0.45);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45), 0 0 24px rgba(0, 245, 255, 0.18);
}

.action:active {
  transform: translateY(1px) scale(0.99);
}

.action-ghost {
  background: linear-gradient(180deg, rgba(255, 79, 216, 0.14), rgba(12, 15, 24, 0.98));
}

.board-panel {
  display: grid;
  gap: 18px;
}

.board-frame {
  position: relative;
  border-radius: calc(var(--radius-xl) + 8px);
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(0, 245, 255, 0.12), transparent 18%),
    linear-gradient(315deg, rgba(255, 79, 216, 0.12), transparent 18%),
    var(--panel);
  border: 1px solid rgba(122, 249, 255, 0.18);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(14px);
}

.fx-layer {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border-radius: var(--radius-xl);
  overflow: hidden;
  z-index: 2;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  aspect-ratio: 1;
  padding: 14px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.04), transparent 55%),
    linear-gradient(180deg, rgba(8, 13, 23, 0.98), rgba(6, 8, 15, 0.98));
  border: 1px solid rgba(128, 203, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.particle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: screen;
  animation: particle-burst 760ms ease-out forwards;
}

.particle.spawn {
  background: radial-gradient(circle, rgba(0, 245, 255, 1), rgba(0, 245, 255, 0.18) 55%, transparent 72%);
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.8), 0 0 34px rgba(0, 245, 255, 0.28);
}

.particle.merge {
  background: radial-gradient(circle, rgba(255, 79, 216, 1), rgba(255, 79, 216, 0.2) 55%, transparent 72%);
  box-shadow: 0 0 18px rgba(255, 79, 216, 0.8), 0 0 34px rgba(255, 79, 216, 0.3);
}

.particle.win {
  background: radial-gradient(circle, rgba(255, 242, 161, 1), rgba(255, 207, 77, 0.28) 55%, transparent 72%);
  box-shadow: 0 0 20px rgba(255, 214, 102, 0.9), 0 0 40px rgba(255, 214, 102, 0.35);
}

.particle.lose {
  background: radial-gradient(circle, rgba(255, 88, 131, 1), rgba(255, 88, 131, 0.22) 55%, transparent 72%);
  box-shadow: 0 0 18px rgba(255, 88, 131, 0.8), 0 0 34px rgba(255, 88, 131, 0.26);
}

.cell {
  position: relative;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(26, 34, 53, 0.82), rgba(12, 17, 27, 0.98));
  border: 1px solid var(--cell-border);
  overflow: hidden;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 35%);
  opacity: 0.5;
}

.tile {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.55rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.tile.pop {
  animation: pop 160ms ease-out;
}

.tile.merged {
  animation: pulse 220ms ease-out;
}

.tile[data-value="2"] {
  background: linear-gradient(180deg, #0cf2ff, #0088ff);
  color: #04121f;
  box-shadow: 0 0 22px rgba(0, 245, 255, 0.34), inset 0 0 18px rgba(255, 255, 255, 0.25);
}

.tile[data-value="4"] {
  background: linear-gradient(180deg, #7cff6b, #16d5a9);
  color: #05140e;
  box-shadow: 0 0 22px rgba(124, 255, 107, 0.34), inset 0 0 18px rgba(255, 255, 255, 0.18);
}

.tile[data-value="8"] {
  background: linear-gradient(180deg, #fffb6b, #ff9c2e);
  color: #201000;
  box-shadow: 0 0 24px rgba(255, 177, 51, 0.42);
}

.tile[data-value="16"] {
  background: linear-gradient(180deg, #ff8a5b, #ff4fd8);
  color: #1c0611;
  box-shadow: 0 0 28px rgba(255, 79, 216, 0.36);
}

.tile[data-value="32"] {
  background: linear-gradient(180deg, #ff4fd8, #9f4bff);
  color: #fff5ff;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.26);
}

.tile[data-value="64"] {
  background: linear-gradient(180deg, #9f4bff, #5b7cff);
  color: #f7f6ff;
}

.tile[data-value="128"] {
  background: linear-gradient(180deg, #5b7cff, #00c2ff);
  color: #effbff;
  font-size: clamp(1.25rem, 3vw, 2.1rem);
}

.tile[data-value="256"] {
  background: linear-gradient(180deg, #00c2ff, #00ffa8);
  color: #041818;
  font-size: clamp(1.25rem, 3vw, 2.05rem);
}

.tile[data-value="512"] {
  background: linear-gradient(180deg, #00ffa8, #7cff6b);
  color: #05170d;
  font-size: clamp(1.2rem, 2.9vw, 1.95rem);
}

.tile[data-value="1024"] {
  background: linear-gradient(180deg, #ff4fd8, #00f5ff);
  color: #fff;
  font-size: clamp(1.1rem, 2.75vw, 1.75rem);
}

.tile[data-value="2048"] {
  background: linear-gradient(180deg, #fff2a1, #ffcf4d);
  color: #1a1100;
  box-shadow: 0 0 34px rgba(255, 214, 102, 0.52);
  font-size: clamp(1.05rem, 2.65vw, 1.7rem);
}

.tile[data-value]:not([data-value="2"]):not([data-value="4"]):not([data-value="8"]):not([data-value="16"]):not([data-value="32"]):not([data-value="64"]):not([data-value="128"]):not([data-value="256"]):not([data-value="512"]):not([data-value="1024"]):not([data-value="2048"]) {
  background: linear-gradient(180deg, #ff78c5, #ff4f80);
  color: #fff;
}

.overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 14, 0.62);
  border-radius: calc(var(--radius-xl) - 4px);
  backdrop-filter: blur(10px);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  width: min(340px, calc(100% - 24px));
  padding: 28px 22px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(13, 17, 28, 0.96), rgba(8, 10, 18, 0.98));
  border: 1px solid rgba(122, 249, 255, 0.18);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.44), 0 0 28px rgba(0, 245, 255, 0.12);
}

.overlay-kicker {
  margin: 0 0 8px;
  color: var(--accent-2);
  letter-spacing: 0.24em;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.overlay-card h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.overlay-card p {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.legend {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.legend p {
  margin: 0;
}

.hint {
  color: rgba(0, 245, 255, 0.86);
}

@keyframes pop {
  0% {
    transform: scale(0.72);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.92);
    box-shadow: inherit;
  }
  50% {
    transform: scale(1.08);
    filter: brightness(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes particle-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.9);
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 100%);
    padding: 18px 0 28px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud {
    width: 100%;
    justify-content: flex-start;
  }

  .stat {
    min-width: 0;
    flex: 1 1 0;
  }

  .board-frame {
    padding: 12px;
  }

  .board {
    gap: 10px;
    padding: 10px;
  }

  .overlay {
    inset: 12px;
  }

  .legend {
    font-size: 0.92rem;
  }
}
