.g2048-page {
  --g2048-danger: #dc2626;
  --g2048-board: #ece7e0;
  --g2048-cell: #ddd6cb;
}

.g2048-layout {
  display: grid;
  gap: 24px;
  padding: 32px 0 80px;
}

.g2048-titlebar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.g2048-titlebar h1 {
  font-size: 48px;
}

.g2048-game {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-md);
}

.g2048-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.g2048-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.g2048-actions,
.overlay-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.g2048-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  color: var(--text);
  background: var(--canvas);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.g2048-button:hover,
.g2048-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--hairline-strong);
  background: var(--canvas-soft);
}

.g2048-button.primary {
  color: var(--ink);
  border-color: var(--primary);
  background: var(--primary);
}

.g2048-button.primary:hover,
.g2048-button.primary:focus-visible {
  border-color: var(--primary-deep);
  background: var(--primary-deep);
}

.g2048-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas-soft);
}

.g2048-stat {
  display: grid;
  gap: 2px;
  min-width: 92px;
}

.g2048-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.g2048-stat strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
}

.g2048-status {
  flex: 1 1 180px;
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
}

.g2048-status.is-good {
  color: var(--primary-deep);
}

.g2048-status.is-alert {
  color: var(--g2048-danger);
}

.g2048-stage {
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--canvas-soft);
}

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

.g2048-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  aspect-ratio: 1;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--g2048-board);
  box-shadow: var(--shadow-sm);
  touch-action: none;
}

.g2048-tile {
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--g2048-cell);
  color: #6f6a61;
  font-size: clamp(20px, 5vw, 34px);
  font-weight: 600;
  line-height: 1;
  transition: background 120ms ease;
}

.g2048-tile.is-empty {
  background: var(--g2048-cell);
}

.g2048-tile.tile-2 {
  background: #f3efe8;
  color: #6f6a61;
}

.g2048-tile.tile-4 {
  background: #ede6d8;
  color: #6f6a61;
}

.g2048-tile.tile-8 {
  background: #f4b17a;
  color: #ffffff;
}

.g2048-tile.tile-16 {
  background: #f59563;
  color: #ffffff;
}

.g2048-tile.tile-32 {
  background: #f67c5f;
  color: #ffffff;
}

.g2048-tile.tile-64 {
  background: #f65e3b;
  color: #ffffff;
}

.g2048-tile.tile-128 {
  background: #edcf72;
  color: #ffffff;
}

.g2048-tile.tile-256 {
  background: #edcc61;
  color: #ffffff;
}

.g2048-tile.tile-512 {
  background: #edc850;
  color: #ffffff;
}

.g2048-tile.tile-1024 {
  background: #edc53f;
  color: #ffffff;
}

.g2048-tile.tile-2048 {
  background: #edc22e;
  color: #ffffff;
  box-shadow: 0 0 24px rgba(237, 194, 46, 0.5);
}

.g2048-tile.tile-super {
  background: #3ecf8e;
  color: #ffffff;
}

.g2048-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(28, 28, 28, 0.52);
  backdrop-filter: blur(8px);
}

.g2048-overlay[hidden] {
  display: none;
}

.g2048-dialog {
  width: min(400px, 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 26px);
  background: var(--canvas);
  box-shadow: 0 22px 44px rgba(16, 19, 26, 0.26);
  text-align: center;
}

.g2048-dialog h2 {
  font-size: 32px;
}

.g2048-dialog p:not(.eyebrow) {
  color: var(--muted);
}

.overlay-actions {
  margin-top: 16px;
  justify-content: center;
}

@media (max-width: 720px) {
  .g2048-titlebar,
  .g2048-toolbar,
  .g2048-hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .g2048-titlebar h1 {
    font-size: 34px;
  }

  .g2048-status {
    flex: 0 1 auto;
    width: 100%;
    text-align: left;
  }
}
