.board-card {
  width: min(100%, 590px);
  margin: 0 auto;
  padding: clamp(16px, 2.5vw, 26px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-raised);
}

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

.board-header h2 {
  margin: 2px 0 -4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.06em;
}

.score-row {
  display: flex;
  gap: 7px;
}

.score-card {
  position: relative;
  min-width: 68px;
  min-height: 52px;
  display: grid;
  place-content: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}

.score-card span {
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-card strong {
  max-width: 88px;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.score-card--best {
  background: var(--color-primary-soft);
}

.score-card--top {
  color: var(--paper);
  background: var(--blue);
}

.score-card--top span {
  color: color-mix(in srgb, var(--paper) 80%, transparent);
}

.score-gain {
  position: absolute;
  top: -18px;
  right: 3px;
  color: var(--coral);
  font-size: 0.78rem;
  pointer-events: none;
}

.score-gain.is-active {
  animation: score-rise 560ms ease-out both;
}

.number-board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(7px, 1.6vw, 12px);
  padding: clamp(9px, 1.8vw, 14px);
  border-radius: 22px;
  background: var(--board);
  touch-action: none;
  user-select: none;
}

.board-cell {
  min-width: 0;
  display: grid;
  place-items: center;
  border-radius: clamp(9px, 1.6vw, 15px);
  background: color-mix(in srgb, var(--paper) 10%, transparent);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 6.2vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 1;
}

.board-cell[data-digits="3"] { font-size: clamp(1.3rem, 5.4vw, 2.45rem); }
.board-cell[data-digits="4"] { font-size: clamp(1.05rem, 4.5vw, 2rem); }
.board-cell[data-digits="5"] { font-size: clamp(0.86rem, 3.7vw, 1.65rem); }

.board-cell[data-value="2"] { background: color-mix(in srgb, var(--paper) 92%, var(--ink)); }
.board-cell[data-value="4"] { background: color-mix(in srgb, var(--lime) 20%, var(--paper)); }
.board-cell[data-value="8"] { background: color-mix(in srgb, var(--lime) 58%, white); }
.board-cell[data-value="16"] { background: var(--lime); }
.board-cell[data-value="32"] { background: color-mix(in srgb, var(--blue) 26%, white); }
.board-cell[data-value="64"] { background: var(--blue); color: var(--paper); }
.board-cell[data-value="128"] { background: color-mix(in srgb, var(--coral) 35%, white); }
.board-cell[data-value="256"] { background: var(--coral); }
.board-cell[data-value="512"] { background: var(--ink); color: var(--lime); }
.board-cell[data-value="1024"] { background: var(--ink); color: #91a9ff; }
.board-cell[data-value="2048"] {
  border: 3px solid var(--lime);
  background: var(--ink);
  color: var(--lime);
  box-shadow: 0 0 22px color-mix(in srgb, var(--lime) 62%, transparent);
}
.board-cell[data-value="super"] {
  border: 3px solid var(--coral);
  background: var(--ink);
  color: var(--coral);
}

.board-cell.is-new {
  animation: tile-new 220ms ease-out both;
}

.board-cell.is-merged {
  animation: tile-merge 260ms ease-out both;
}

.board-footer {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.undo-button {
  min-width: 82px;
  min-height: 42px;
  border-radius: 11px;
  color: var(--ink);
  background: var(--color-secondary-soft);
  font-size: 0.72rem;
  font-weight: 850;
}

.undo-button:hover:not(:disabled) {
  color: var(--blue);
}

.undo-button:disabled {
  opacity: 0.42;
}

.direction-pad {
  display: none;
}

.game-dialog {
  position: relative;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-raised);
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
}

.dialog-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--lime);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.dialog-icon--result {
  width: 84px;
  font-size: 1.25rem;
}

.dialog-icon.is-lost {
  background: var(--coral);
  color: var(--ink);
  font-family: inherit;
  font-size: 2.4rem;
}

.dialog-kicker {
  margin-bottom: 7px;
}

.game-dialog h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  font-weight: 500;
  letter-spacing: -0.05em;
}

.game-dialog > p:not(.dialog-kicker) {
  margin: 13px 0 20px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.dialog-tip {
  margin: -2px 0 20px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--color-primary-soft);
  color: var(--muted);
  font-size: 0.75rem;
}

.dialog-tip span {
  margin-right: 6px;
  color: var(--ink);
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.dialog-text-button {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
  font-size: 0.78rem;
  font-weight: 900;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--lime);
  color: var(--ink);
}

.primary-button span {
  font-size: 1.2rem;
}

.secondary-button {
  margin-top: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--blue);
}

.dialog-text-button {
  min-height: 42px;
  margin-top: 4px;
  background: transparent;
  color: var(--muted);
}

@keyframes tile-new {
  from { opacity: 0; transform: scale(0.68); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes tile-merge {
  0% { transform: scale(0.84); }
  58% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes score-rise {
  0% { opacity: 0; transform: translateY(7px); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}
