: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: 26px 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: 20px 24px 22px; }
.side-panel { padding: 26px; }

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

.brand {
  margin: 0 0 6px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 900;
  font-size: 0.78rem;
}

.game-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.92;
  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, .hint-line, .side-panel li, .tip, small {
  color: var(--muted);
  line-height: 1.55;
}

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

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

.score-box {
  border-radius: 14px;
  padding: 8px 12px;
  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.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.score-box strong { font-size: 1.18rem; }

@media (min-width: 561px) {
  .score-box {
    min-width: 102px;
  }
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 16px;
}

button {
  border: 0;
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.09);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.13);
  padding: 9px 13px;
  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 {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #041038;
  box-shadow: 0 12px 28px rgba(16, 216, 255, .25);
}

.play-wrap {
  display: grid;
  grid-template-columns: 126px minmax(300px, 500px) 126px;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.next-card, .mission-card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 13px;
  text-align: center;
  display: grid;
  gap: 12px;
}

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

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

.board {
  --cols: 5;
  --rows: 7;
  position: relative;
  width: min(100%, 485px);
  aspect-ratio: 5 / 7;
  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(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 8px;
  overflow: hidden;
}

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

.cell::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 14px solid rgba(20,112,255,.72);
  opacity: .55;
}

.tile,
.preview-tile {
  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;
}

.tile {
  position: absolute;
  z-index: 4;
  transition: left .18s ease, top .18s ease, transform .18s ease, opacity .18s ease;
  animation: none;
}

.tile.merging { animation: mergePulse .26s ease-out; z-index: 8; }
.tile.new-drop { animation: dropPop .2s ease-out; }

.preview-tile {
  width: 66px;
  height: 66px;
  margin: 0 auto;
  font-size: 1.8rem;
}

@keyframes dropPop {
  from { transform: translateY(-14px) scale(.9); opacity: .3; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes mergePulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  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; }

.column-buttons {
  width: min(100%, 500px);
  margin: 16px auto 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.column-buttons button {
  padding: 10px 4px;
  border-radius: 14px;
  color: var(--cyan);
}

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

.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; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(1,2,24,.74);
  backdrop-filter: blur(8px);
  padding: 20px;
}

.hidden { display: none !important; }

.modal-card {
  width: min(420px, 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;
}

.modal-card h2 { margin: 0 0 10px; font-size: 2rem; }
.modal-card p { color: var(--muted); line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 960px) {
  body { padding: 14px; }
  .shell { grid-template-columns: 1fr; }
  .side-panel { order: 2; }
  .play-wrap { grid-template-columns: 1fr; }
  .next-card, .mission-card {
    width: min(100%, 500px);
    margin: 0 auto;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    text-align: left;
  }
  .preview-tile { margin: 0; width: 58px; height: 58px; font-size: 1.5rem; }
}

@media (max-width: 560px) {
  .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: 6px; padding: 8px; border-radius: 18px; }
  .tile { border-radius: 12px; }
}

.difficulty-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.09);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.13);
  padding: 8px 10px 8px 12px;
  font-weight: 900;
}

.difficulty-wrap span {
  color: var(--cyan);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.difficulty-wrap select {
  appearance: none;
  border: 0;
  outline: 0;
  border-radius: 12px;
  padding: 6px 26px 6px 10px;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, var(--cyan) 50%) right 12px center / 7px 7px no-repeat,
    rgba(2, 4, 34, 0.74);
  box-shadow: inset 0 0 0 1px rgba(16,216,255,.25);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.drop-timer {
  display: none;
}

#dropBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--gold));
  box-shadow: 0 0 18px rgba(16,216,255,.55);
}

@keyframes dropProgress {
  from { width: 0%; }
  to { width: 100%; }
}

.speed-line {
  text-align: center;
  margin: 8px 0 0;
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: .04em;
}

.cell.last-column {
  box-shadow: none;
}

.tile.recent-column {
  filter: saturate(1.08) brightness(1.03);
}

button.active {
  background: linear-gradient(135deg, var(--gold), #ff8c20);
  color: #130a1f;
  box-shadow: 0 0 24px rgba(255,212,71,.3), inset 0 0 0 1px rgba(255,255,255,.2);
}

@media (max-width: 560px) {
  .difficulty-wrap { flex: 1 1 100%; justify-content: space-between; }
  .difficulty-wrap select { flex: 1; }
}

.tile.falling {
  z-index: 12;
  transition: top .42s cubic-bezier(.15,.82,.22,1), transform .18s ease;
  animation: none;
  filter: saturate(1.12) brightness(1.08);
}

.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: 2;
  opacity: .65;
}

.board.drag-ready { cursor: grab; touch-action: none; }
.board.drag-ready:active { cursor: grabbing; }


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


#soundBtn[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(16,216,255,.32), 0 0 18px rgba(16,216,255,.08);
}

#soundBtn.sound-off {
  opacity: .78;
}


.hidden-game-status,
.drop-timer,
.speed-line,
.hidden-status {
  display: none !important;
}
