/* ===== VARIABEL WARNA PINK PASTEL ===== */
:root {
  --bg: #fff0f6;
  --card-bg: #ffe4f0;
  --board-bg: #f7c5de;
  --cell-bg: #fadadf;
  --primary: #ff85a1;
  --accent: #c77dff;
  --mint: #a8edca;
  --lav: #d5b8f5;
  --text-dark: #5c3a5a;
  --text-mid: #8b5e8b;
  --white: #fff;
  --shadow: rgba(255, 133, 161, 0.3);
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== DEKORASI BACKGROUND ===== */
#deco-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.deco-item {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.25;
  animation: floatDeco linear infinite;
  user-select: none;
}

@keyframes floatDeco {
  0%   { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.25; }
  90%  { opacity: 0.25; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* ===== WRAPPER ===== */
.wrapper {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ===== HEADER ===== */
.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2.4rem;
  color: var(--primary);
  line-height: 1;
  text-shadow: 3px 3px 0 #ffc1d6;
}

.game-title span {
  font-size: 1.8rem;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-mid);
  margin-top: 2px;
}

/* ===== SCORE BOXES ===== */
.scores {
  display: flex;
  gap: 8px;
}

.score-box {
  background: var(--primary);
  border-radius: 14px;
  padding: 6px 14px;
  text-align: center;
  min-width: 64px;
  box-shadow: 0 4px 0 #e06080;
}

.score-box.best {
  background: var(--accent);
  box-shadow: 0 4px 0 #9b59d0;
}

.score-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 900;
  color: rgba(255,255,255,0.85);
  letter-spacing: 1px;
}

.score-val {
  display: block;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--white);
}

/* ===== KONTROL ===== */
.controls {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-music {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--lav);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #b09ad4;
  transition: transform 0.1s, box-shadow 0.1s;
  flex-shrink: 0;
}

.btn-music:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b09ad4;
}

.btn-music.muted {
  background: #e0e0e0;
  box-shadow: 0 4px 0 #b0b0b0;
}

.btn-new {
  flex: 1;
  padding: 11px 0;
  border-radius: 14px;
  border: none;
  background: var(--primary);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #e06080;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-new:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #e06080;
}

/* ===== BOARD ===== */
.board-wrap {
  width: 100%;
}

.board {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--board-bg);
  border-radius: 20px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  box-shadow: 0 8px 24px var(--shadow), inset 0 2px 8px rgba(255,255,255,0.5);
}

/* Sel kosong */
.cell {
  background: var(--cell-bg);
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== TILE ===== */
.tile {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-weight: 400;
  animation: tileAppear 0.15s ease;
}

@keyframes tileAppear {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes tileMerge {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.tile.merged {
  animation: tileMerge 0.2s ease;
}

/* ===== WARNA TILE ===== */
/* Setiap nilai punya warna berbeda - tema pastel lucu */
.tile[data-val="2"]    { background: #ffd6e8; color: #d44f80; }
.tile[data-val="4"]    { background: #ffc3da; color: #c43870; }
.tile[data-val="8"]    { background: #ffaad0; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tile[data-val="16"]   { background: #ff91c4; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tile[data-val="32"]   { background: #e8b4f8; color: #6a1b9a; }
.tile[data-val="64"]   { background: #d4a0f5; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tile[data-val="128"]  { background: #b8e4c8; color: #2d6a4f; }
.tile[data-val="256"]  { background: #95ddb4; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tile[data-val="512"]  { background: #f9c8a0; color: #8b4513; }
.tile[data-val="1024"] { background: #f5a87a; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tile[data-val="2048"] { background: linear-gradient(135deg, #ff85a1, #c77dff, #a8edca); color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.tile[data-val="4096"] { background: linear-gradient(135deg, #ff6b6b, #ffd93d); color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,0.3); }

/* ===== SHADOW TILE ===== */
.tile { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.tile[data-val="2048"] { box-shadow: 0 6px 20px rgba(199,125,255,0.5); }

/* ===== MOBILE CONTROLS ===== */
.mobile-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.mc-row {
  display: flex;
  gap: 6px;
}

.mc-btn {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: none;
  background: var(--card-bg);
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #f0a0c0;
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mc-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #f0a0c0;
}

/* ===== OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 182, 210, 0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

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

.overlay-box {
  background: var(--white);
  border-radius: 28px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(255, 133, 161, 0.4);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.overlay-emoji {
  font-size: 3.5rem;
  margin-bottom: 10px;
}

.overlay-box h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.overlay-box p {
  color: var(--text-mid);
  font-size: 1rem;
  margin-bottom: 20px;
}

.btn-new.big {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 18px;
}

/* ===== ANIMASI SKOR NAIK ===== */
.score-pop {
  animation: scorePop 0.3s ease;
}

@keyframes scorePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== RESPONSIF ===== */
@media (max-width: 360px) {
  .game-title { font-size: 2rem; }
  .board { gap: 8px; padding: 8px; }
  .mc-btn { width: 48px; height: 48px; font-size: 1.1rem; }
}

@media (min-width: 480px) {
  .wrapper { padding: 24px 24px 32px; }
  .mc-btn { width: 60px; height: 60px; }
}