:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #f4f1ff;
  background: #171324;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a,
#board {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  font-weight: 700;
  background: #413653;
  border: 1px solid #726183;
  color: #fff;
  border-radius: 12px;
  min-height: 46px;
  padding: 10px 16px;
  cursor: pointer;
}
button:hover {
  background: #594773;
}
button:focus-visible,
a:focus-visible,
#board:focus-visible {
  outline: 3px solid #f6cf73;
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.game-shell {
  max-width: 510px;
  padding: 24px 18px;
  margin: auto;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #c8b7e9;
  margin: 0 0 6px;
}
h1 {
  font-size: clamp(40px, 12vw, 64px);
  line-height: 1;
  margin: 0;
  letter-spacing: -0.06em;
}
h1 span {
  color: #c7a4ff;
  font-size: 0.7em;
  margin-left: 10px;
}
.scores {
  display: flex;
  gap: 8px;
}
.scores > div {
  background: #292136;
  border: 1px solid #48395c;
  border-radius: 12px;
  text-align: center;
  padding: 10px;
  min-width: 70px;
  font-size: 11px;
  color: #d6c7e8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.scores strong {
  display: block;
  color: #fff;
  font-size: 20px;
  letter-spacing: 0;
  margin-top: 4px;
  overflow-wrap: anywhere;
  max-width: 110px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0;
}
.toolbar p {
  font-size: 13px;
  line-height: 1.65;
  margin: 0;
  color: #d6c7e8;
}
.toolbar button {
  white-space: nowrap;
  font-size: 12px;
}
.board-wrap {
  padding: 10px;
  background: #30263e;
  border: 1px solid #554268;
  border-radius: 18px;
  box-shadow: 0 15px 40px #0003;
}
#board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  touch-action: none;
  border-radius: 8px;
}
#board .row {
  display: contents;
}
.cell {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 9px;
  background: #44364f;
  display: grid;
  place-items: center;
  position: relative;
}
.tile {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #ede6f3;
  color: #33243f;
  border-radius: 9px;
  font-size: clamp(23px, 7vw, 39px);
  font-weight: 800;
  animation: appear 0.14s ease-out;
}
.tile[data-value="4"] {
  background: #d9c5ef;
}
.tile[data-value="8"] {
  background: #c09ae8;
}
.tile[data-value="16"] {
  background: #a66dd8;
  color: #fff;
}
.tile[data-value="32"] {
  background: #8246b1;
  color: #fff;
}
.tile[data-value="64"] {
  background: #693399;
  color: #fff;
}
.tile.high {
  background: #f7cd71;
  color: #392408;
  font-size: clamp(19px, 6vw, 32px);
}
.tile.higher {
  font-size: clamp(15px, 5vw, 26px);
}
@keyframes appear {
  from {
    transform: scale(0.92);
    opacity: 0.65;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
#status {
  min-height: 42px;
  font-size: 13px;
  line-height: 1.5;
  color: #e3d3f7;
  margin: 16px 0 8px;
}
.direction-pad {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.direction-pad button {
  width: 54px;
  font-size: 24px;
  line-height: 1;
}
.help {
  font-size: 12px;
  line-height: 1.7;
  color: #c5b7d5;
  margin: 14px 0 0;
}
footer {
  font-size: 11px;
  line-height: 1.7;
  color: #baacca;
  border-top: 1px solid #3d304e;
  padding-top: 16px;
  margin-top: 20px;
}
a {
  color: #dbbfff;
}
dialog {
  background: #292136;
  color: #fff;
  border: 1px solid #9373b5;
  border-radius: 16px;
  max-width: min(420px, 90vw);
  padding: 24px;
}
dialog::backdrop {
  background: #000a;
}
dialog p {
  line-height: 1.6;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
#continue {
  background: #66408a;
  margin-bottom: 12px;
}
@media (max-width: 350px) {
  .game-shell {
    padding: 18px 12px;
  }
  .scores > div {
    min-width: 60px;
    padding: 8px;
  }
  .scores strong {
    font-size: 17px;
  }
  .toolbar {
    gap: 8px;
  }
  .toolbar p {
    font-size: 12px;
  }
  #board {
    gap: 6px;
  }
  .board-wrap {
    padding: 8px;
  }
  .direction-pad {
    gap: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tile {
    animation: none;
  }
}
