:root {
  --bg-1: #05052a;
  --bg-2: #101d87;
  --panel: rgba(10, 18, 75, 0.86);
  --panel-2: rgba(19, 28, 97, 0.72);
  --ink: #eef6ff;
  --muted: #aeb9ff;
  --cyan: #10d8ff;
  --blue: #2a7cff;
  --pink: #ff2e7e;
  --green: #58ff20;
  --gold: #ffd447;
  --cell: rgba(8, 2, 32, 0.92);
  --line: rgba(20, 112, 255, 0.42);
  --radius: 26px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(24, 219, 255, 0.22), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(255, 46, 126, 0.16), transparent 30%),
    linear-gradient(135deg, #05051f, #071273 54%, #060626);
}

.site-header {
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #ececec;
  color: #222222;
}

.site-header-inner {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 22px;
}

.site-title {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.site-subtitle {
  margin: 12px 0 0;
  color: #697386;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: 32px auto;
  display: grid;
  grid-template-columns: minmax(360px, 780px) minmax(260px, 330px);
  gap: 22px;
  align-items: start;
}

.game-panel,
.side-panel {
  border: 1px solid rgba(68, 215, 255, 0.28);
  background: linear-gradient(180deg, rgba(13, 22, 96, 0.92), rgba(7, 8, 45, 0.88));
  border-radius: 30px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42), inset 0 0 30px rgba(0, 196, 255, 0.06);
  backdrop-filter: blur(16px);
}

.game-panel { padding: 24px; }
.side-panel { padding: 26px; }

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.game-title {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.85;
  letter-spacing: -0.08em;
  text-shadow: 0 5px 0 rgba(0,0,0,0.18), 0 0 24px rgba(16,216,255,0.4);
}

.subtitle,
.instructions,
.side-panel li,
.tip,
.goal-card small,
.message-card p {
  color: var(--muted);
  line-height: 1.55;
}

.subtitle {
  max-width: 520px;
  margin: 12px 0 0;
}

.score-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, auto));
  gap: 10px;
  align-items: start;
}

.score-box {
  border-radius: 18px;
  padding: 10px 14px;
  background: rgba(2, 4, 34, 0.74);
  box-shadow: inset 0 0 0 2px rgba(37, 118, 255, 0.25);
}

.score-box.glow {
  box-shadow: inset 0 0 0 2px rgba(16,216,255,0.34), 0 0 24px rgba(16,216,255,0.12);
}

.score-box span {
  display: block;
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.score-box strong {
  display: block;
  font-size: 1.45rem;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 22px 0;
}

button {
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255,255,255,0.09);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.13);
  padding: 12px 16px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform .14s ease, opacity .14s ease, box-shadow .14s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(16,216,255,0.36), 0 10px 22px rgba(0,0,0,0.22);
}

button:active { transform: translateY(1px) scale(.99); }
button:disabled { opacity: .46; cursor: not-allowed; transform: none; }

.primary-btn {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #041038;
  box-shadow: 0 12px 28px rgba(16, 216, 255, .25);
}

.soft-btn {
  background: rgba(255,255,255,0.09);
  color: var(--ink);
}

.classic-play-wrap {
  display: grid;
  grid-template-columns: minmax(300px, 520px) 150px;
  gap: 18px;
  justify-content: center;
  align-items: start;
}

.board-column {
  display: grid;
  justify-items: center;
}

.board-area {
  position: relative;
  width: min(100%, 520px);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, #1321a0, #060023);
  box-shadow: inset 0 0 0 2px rgba(16,216,255,.35), 0 24px 48px rgba(0,0,0,.34);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.board.dragging { cursor: grabbing; }

.board::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(16,216,255,.85), transparent);
  z-index: 1;
  opacity: .65;
}

.cell {
  border-radius: 14px;
  background: var(--cell);
  border: 1px solid var(--line);
}

.tile {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 1000;
  text-shadow: 0 3px 0 rgba(0,0,0,.22);
  border-radius: 15px;
  user-select: none;
  transition: transform .12s ease;
  animation: dropPop .18s ease-out;
}

.tile.merged {
  animation: mergePulse .26s ease-out;
  z-index: 8;
}

@keyframes dropPop {
  from { transform: scale(.9); opacity: .3; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes mergePulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.tile-2 { background: linear-gradient(145deg, #ff2e7e, #fd1247); box-shadow: inset 0 -7px rgba(102,0,34,.22), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #a20c34; }
.tile-4 { background: linear-gradient(145deg, #58ff20, #19c500); box-shadow: inset 0 -7px rgba(0,80,10,.22), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #0b7a0a; }
.tile-8 { background: linear-gradient(145deg, #10d8ff, #096cff); box-shadow: inset 0 -7px rgba(0,50,128,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #063fa7; }
.tile-16 { background: linear-gradient(145deg, #ff7a20, #ff2d00); box-shadow: inset 0 -7px rgba(128,30,0,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #a82800; }
.tile-32 { background: linear-gradient(145deg, #d842ff, #8c20ff); box-shadow: inset 0 -7px rgba(56,0,110,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #4b0fa3; }
.tile-64 { background: linear-gradient(145deg, #ffd447, #ff9d00); box-shadow: inset 0 -7px rgba(129,72,0,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #a76500; color: #11194b; text-shadow: none; }
.tile-128 { background: linear-gradient(145deg, #82ffe9, #00bfae); box-shadow: inset 0 -7px rgba(0,98,89,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #007d73; color: #031c29; text-shadow: none; }
.tile-256 { background: linear-gradient(145deg, #fff, #a9beff); box-shadow: inset 0 -7px rgba(60,73,150,.2), inset 0 7px rgba(255,255,255,.55), 0 8px 0 #7081dd; color: #091145; text-shadow: none; }
.tile-512 { background: linear-gradient(145deg, #ff98dc, #ff27a8); box-shadow: inset 0 -7px rgba(115,0,80,.25), inset 0 7px rgba(255,255,255,.18), 0 8px 0 #a70072; }
.tile-1024,
.tile-2048,
.tile-super {
  background: linear-gradient(145deg, #fef38d, #ff5dcb 45%, #5c38ff);
  box-shadow: inset 0 -7px rgba(60,0,90,.25), inset 0 7px rgba(255,255,255,.22), 0 8px 0 #3c1cae;
}

.goal-card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 16px;
  text-align: center;
  display: grid;
  gap: 12px;
  align-self: center;
}

.goal-card span {
  color: var(--cyan);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .78rem;
}

.goal-card strong {
  font-size: 2rem;
  color: var(--gold);
}

.instructions {
  margin: 18px 0 0;
  text-align: center;
  font-weight: 800;
}

.mobile-pad {
  display: none;
  margin: 18px auto 0;
  width: fit-content;
  text-align: center;
}

.mobile-pad button {
  width: 58px;
  height: 48px;
  margin: 4px;
  padding: 0;
}

.side-panel h2 { margin: 0 0 12px; font-size: 1.65rem; }
.side-panel ol { padding-left: 22px; }
.side-panel li { margin: 11px 0; }

.tip {
  margin-top: 22px;
  padding: 16px;
  background: rgba(255,255,255,.07);
  border-radius: 18px;
}

.message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(1,2,24,.74);
  backdrop-filter: blur(8px);
  padding: 20px;
  border-radius: 22px;
  z-index: 20;
}

.hidden { display: none !important; }

.message-card {
  width: min(390px, 100%);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(18, 25, 95, .98), rgba(5, 6, 38, .98));
  border: 1px solid rgba(16,216,255,.3);
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  padding: 26px;
  text-align: center;
}

.message-card h2 { margin: 0 0 10px; font-size: 2rem; }
.message-card p { margin: 0 0 14px; }
.message-card button { width: 100%; margin-top: 10px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side-panel { order: 2; }
  .classic-play-wrap { grid-template-columns: 1fr; }
  .goal-card {
    width: min(100%, 520px);
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  body { padding: 0; }
  .site-header-inner,
  .shell { width: min(100%, calc(100% - 24px)); }
  .shell { margin: 20px auto; }
  .game-panel { padding: 16px; border-radius: 22px; }
  .game-header { flex-direction: column; }
  .score-stack { width: 100%; grid-template-columns: 1fr 1fr; }
  .toolbar button { flex: 1 1 130px; }
  .board { gap: 8px; padding: 10px; border-radius: 18px; }
  .tile { border-radius: 12px; }
  .mobile-pad { display: block; }
}


@media (max-width: 560px) {
  .score-stack { grid-template-columns: 1fr 1fr; }
}
