/* 2048 미니 — 4x4 슬라이드 퍼즐 */

.board-wrap {
  position: relative;
  width: min(92vw, 480px);
  margin: 0 auto;
}

.g2048-board {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: linear-gradient(135deg, #4cccaf, #2fa78b);
  border-radius: 18px;
  padding: 8px;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(123, 224, 210, 0.25);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  outline: none;
}

.g2048-board.bump { animation: boardBump 0.18s ease; }
@keyframes boardBump {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-4px); }
}

.g2048-cells {
  position: absolute;
  inset: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
}

.g2048-cell {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
}

.g2048-tiles {
  position: absolute;
  inset: 8px;
  pointer-events: none;
}

.g2048-tile {
  position: absolute;
  width: var(--tile-size, 22%);
  height: var(--tile-size, 22%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  background: #eee4da;
  color: #14260a;
  transition: transform 0.12s ease-in-out;
  will-change: transform;
}

.g2048-tile[data-len="3"] { font-size: clamp(1.3rem, 6.5vw, 2rem); }
.g2048-tile[data-len="4"],
.g2048-tile[data-len="5"] { font-size: clamp(1.05rem, 5.2vw, 1.6rem); }

.g2048-tile[data-value="2"]    { background: #eee4da; color: #14260a; }
.g2048-tile[data-value="4"]    { background: #ede0c8; color: #14260a; }
.g2048-tile[data-value="8"]    { background: #f2b179; color: #fff; }
.g2048-tile[data-value="16"]   { background: #f59563; color: #fff; }
.g2048-tile[data-value="32"]   { background: #f67c5f; color: #fff; }
.g2048-tile[data-value="64"]   { background: #f65e3b; color: #fff; }
.g2048-tile[data-value="128"]  { background: #edcf72; color: #fff; }
.g2048-tile[data-value="256"]  { background: #edcc61; color: #fff; }
.g2048-tile[data-value="512"]  { background: #edc850; color: #fff; }
.g2048-tile[data-value="1024"] { background: #edc53f; color: #fff; }
.g2048-tile[data-value="2048"] { background: #edc22e; color: #fff; box-shadow: 0 0 18px rgba(237, 194, 46, 0.65); }
.g2048-tile[data-super]        { background: #3c3a32; color: #fff; }

.g2048-tile.spawn  { animation: tile-spawn 0.18s ease 0.10s backwards; }
.g2048-tile.merged { animation: tile-pop   0.20s ease 0.10s; }

@keyframes tile-spawn {
  from { transform: var(--tile-translate) scale(0); opacity: 0; }
  to   { transform: var(--tile-translate) scale(1); opacity: 1; }
}
@keyframes tile-pop {
  0%, 100% { transform: var(--tile-translate) scale(1); }
  50%      { transform: var(--tile-translate) scale(1.16); }
}

/* ===== 시작 오버레이 ===== */

.g2048-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 41, 0.78);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  z-index: 5;
  transition: opacity 0.2s;
}
.g2048-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-content { text-align: center; padding: 24px; }
.overlay-icon { font-size: 3.5rem; margin-bottom: 12px; }
.overlay-content h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; color: var(--text); }
.overlay-content p { color: var(--text-dim); margin-bottom: 18px; line-height: 1.5; }

/* ===== 컨트롤 행 ===== */

.g2048-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
  flex-wrap: wrap;
  padding: 0 16px;
}

.g2048-controls .btn-mini {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.g2048-controls .btn-mini:hover  { background: rgba(255,255,255,0.12); }
.g2048-controls .btn-mini:active { transform: scale(0.96); }

.g2048-controls .hint {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0;
}

/* ===== 결과 모달 ===== */

.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 41, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.25s ease;
}
.result-modal.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-emoji { font-size: 4rem; margin-bottom: 8px; }
.result-card h2 { font-size: 1.5rem; margin-bottom: 8px; }
.result-msg { color: var(--text-dim); margin-bottom: 24px; }

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.result-stats > div {
  background: rgba(255,255,255,0.05);
  padding: 14px;
  border-radius: 12px;
}
.result-stats span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.result-stats strong {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-rank {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--accent);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.result-actions .btn {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.95rem;
}
