:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #172026;
  --muted: #63717a;
  --line: #d9e1e5;
  --panel: #ffffff;
  --panel-strong: #eef3f5;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --danger: #c2410c;
  --tile-empty: #dfe7eb;
  --tile-2: #e8f4f1;
  --tile-4: #d2ece7;
  --tile-8: #cfe6ff;
  --tile-16: #b8d5ff;
  --tile-32: #ffd8a8;
  --tile-64: #ffc078;
  --tile-128: #f8b4b4;
  --tile-256: #fda4af;
  --tile-512: #c4b5fd;
  --tile-1024: #a5b4fc;
  --tile-2048: #67e8f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

.shell {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(320px, 560px) minmax(280px, 360px);
  justify-content: center;
  padding: 28px;
}

.game-panel,
.side-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 50px rgba(23, 32, 38, 0.08);
}

.game-panel {
  padding: 22px;
}

.side-panel {
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 20px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 3.1rem;
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.scorebox {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 104px;
  padding: 10px 12px;
  text-align: right;
}

.scorebox span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.scorebox strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.1;
}

.board-wrap {
  aspect-ratio: 1;
  width: 100%;
}

.board {
  background: #b9c7cd;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 1fr);
  height: 100%;
  padding: 10px;
  touch-action: none;
  width: 100%;
}

.tile {
  align-items: center;
  aspect-ratio: 1;
  background: var(--tile-empty);
  border-radius: 7px;
  color: #172026;
  display: flex;
  font-size: clamp(1.3rem, 8vw, 3.2rem);
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  min-width: 0;
}

.tile[data-value="2"] {
  background: var(--tile-2);
}

.tile[data-value="4"] {
  background: var(--tile-4);
}

.tile[data-value="8"] {
  background: var(--tile-8);
}

.tile[data-value="16"] {
  background: var(--tile-16);
}

.tile[data-value="32"] {
  background: var(--tile-32);
}

.tile[data-value="64"] {
  background: var(--tile-64);
}

.tile[data-value="128"] {
  background: var(--tile-128);
}

.tile[data-value="256"] {
  background: var(--tile-256);
}

.tile[data-value="512"] {
  background: var(--tile-512);
}

.tile[data-value="1024"] {
  background: var(--tile-1024);
  font-size: clamp(1.05rem, 6vw, 2.5rem);
}

.tile[data-value="2048"] {
  background: var(--tile-2048);
  font-size: clamp(1.05rem, 6vw, 2.5rem);
}

.controls,
.dpad {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.controls {
  grid-template-columns: 1fr 1fr;
}

.dpad {
  grid-template-columns: repeat(4, 1fr);
}

.dpad button {
  background: #27343b;
}

.dpad button:hover {
  background: #11191e;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
}

.status-list dt {
  color: var(--muted);
  font-weight: 700;
}

.status-list dd {
  font-weight: 800;
  margin: 0;
  max-width: 180px;
  overflow-wrap: anywhere;
  text-align: right;
}

.results {
  display: grid;
  gap: 8px;
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.results li {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.results .storage-location {
  color: var(--accent-strong);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  h1 {
    font-size: 2.5rem;
  }

  .dpad {
    grid-template-columns: 1fr 1fr;
  }
}
