/* ═══════════════════════════════════════════════════════════════
   넘버 블라스트 - 실시간 2048 변형 게임 스타일
   ═══════════════════════════════════════════════════════════════ */

/* ─── 게임 페이지 레이아웃 ─────────────────────────────────────── */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 14px 40px;
  position: relative;
  z-index: 1;
}

/* ─── 게임 헤더 ─────────────────────────────────────────────────── */
.game-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 14px;
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(255,122,179,0.12);
}

.back-btn {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(255,122,179,0.10);
  border: 1.5px solid rgba(255,122,179,0.25);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.back-btn:hover {
  background: rgba(255,122,179,0.18);
  transform: translateX(-2px);
}

.game-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  flex: 1;
  line-height: 1.2;
}
.game-title span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* ─── 점수 표시 ─────────────────────────────────────────────────── */
.score-display {
  display: flex;
  gap: 12px;
  align-items: center;
}
.score-item {
  text-align: center;
  background: rgba(255,255,255,0.8);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  box-shadow: var(--shadow-sm);
  min-width: 70px;
}
.score-item .label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}
.score-item .value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}
.score-item .value.best { color: var(--primary); }

/* ─── 게임 메인 영역 ─────────────────────────────────────────────── */
.game-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── 보드 영역 ─────────────────────────────────────────────────── */
.board-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── 스폰 타이머 바 ────────────────────────────────────────────── */
.spawn-timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.spawn-timer-label {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 2px;
}

.spawn-timer-track {
  height: 10px;
  background: rgba(0,0,0,0.07);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  transition: box-shadow 0.2s;
}

.spawn-timer-track.timer-urgent {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 8px rgba(255,80,40,0.5);
  animation: timer-pulse 0.4s ease-in-out infinite alternate;
}

@keyframes timer-pulse {
  from { box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 6px rgba(255,80,40,0.4); }
  to   { box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 14px rgba(255,80,40,0.7); }
}

.spawn-timer-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  width: 0%;
  transition: background-color 0.2s;
  background: linear-gradient(90deg, #4ECDC4, #FFD93D);
}

/* ─── 보드 래퍼 ─────────────────────────────────────────────────── */
.board-wrapper {
  position: relative;
  border-radius: var(--radius-md);
}

/* ─── 게임 보드 (4×4 그리드) ────────────────────────────────────── */
.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  background: rgba(200,190,230,0.35);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow-md);
  border: 3px solid rgba(255,255,255,0.85);
  width: 360px;
  height: 360px;
}

@media (max-width: 420px) {
  .game-board {
    width: calc(100vw - 60px);
    height: calc(100vw - 60px);
    gap: 8px;
    padding: 8px;
  }
}

/* ─── 타일 공통 ─────────────────────────────────────────────────── */
.tile {
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 2.2rem;
  line-height: 1;
  transition: background 0.08s, color 0.08s;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* 빈 칸 */
.tile-empty {
  background: rgba(200,190,230,0.25);
}

/* 새 타일 애니메이션 */
.tile-new {
  animation: tile-spawn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* 합쳐진 타일 애니메이션 */
.tile-merged {
  animation: tile-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tile-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ─── 타일 색상 ─────────────────────────────────────────────────── */
.tile-2    { background: #FFD6E7; color: #CC4488; box-shadow: 0 3px 0 #FFB3D1; font-size: 2.4rem; }
.tile-4    { background: #FFF5CC; color: #B07000; box-shadow: 0 3px 0 #FFE080; font-size: 2.4rem; }
.tile-8    { background: #FFE0B0; color: #C05000; box-shadow: 0 3px 0 #FFCC80; font-size: 2.4rem; }
.tile-16   { background: #FFBBAA; color: #CC2200; box-shadow: 0 3px 0 #FF9980; font-size: 2.2rem; }
.tile-32   { background: #C8F4E0; color: #1A7A50; box-shadow: 0 3px 0 #99E8C4; font-size: 2.2rem; }
.tile-64   { background: #BDE8FF; color: #0066BB; box-shadow: 0 3px 0 #88CCFF; font-size: 2.2rem; }
.tile-128  { background: #DDD0FF; color: #6633CC; box-shadow: 0 3px 0 #BBAAFF; font-size: 1.9rem; }
.tile-256  { background: #FFE87A; color: #7A5500; box-shadow: 0 3px 0 #FFD040; font-size: 1.9rem; }
.tile-512  { background: #FFB0D8; color: #CC0066; box-shadow: 0 3px 0 #FF80BB; font-size: 1.9rem; }
.tile-1024 { background: #90DCFF; color: #004488; box-shadow: 0 3px 0 #60C0FF; font-size: 1.5rem; }
.tile-2048 {
  background: linear-gradient(135deg, #FFD700, #FF6B6B, #FF7AB3);
  color: #FFF;
  box-shadow: 0 3px 0 #CC9900, 0 0 20px rgba(255,200,0,0.5);
  font-size: 1.5rem;
  animation: rainbow-glow 1.5s ease-in-out infinite alternate;
}

.tile-super {
  background: linear-gradient(135deg, #B197FC, #5EC8F0, #4ECDC4);
  color: #FFF;
  box-shadow: 0 3px 0 #8866DD, 0 0 16px rgba(177,151,252,0.5);
  font-size: 1.3rem;
}

@keyframes rainbow-glow {
  from { box-shadow: 0 3px 0 #CC9900, 0 0 16px rgba(255,200,0,0.4); }
  to   { box-shadow: 0 3px 0 #CC9900, 0 0 30px rgba(255,180,0,0.8); }
}

/* ─── 게임 오버레이 ─────────────────────────────────────────────── */
.canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: var(--radius-md);
  animation: fadeInScale 0.25s ease;
  z-index: 10;
}
.canvas-overlay.hidden { display: none; }

.overlay-title {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 900;
  text-align: center;
  background: linear-gradient(135deg, var(--primary), var(--coral));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: float 3s ease-in-out infinite;
}

.overlay-subtitle {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}
.overlay-subtitle strong, .overlay-subtitle span {
  color: var(--primary);
  font-weight: 800;
  -webkit-text-fill-color: var(--primary);
}

.overlay-score {
  font-size: 4rem;
  font-weight: 900;
  color: var(--accent-dark);
  line-height: 1;
}

/* ─── 사이드 패널 ───────────────────────────────────────────────── */
.side-panel {
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 650px) {
  .side-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .side-panel > * { flex: 1; min-width: 140px; }
}

.panel-section {
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1.5px solid rgba(255,122,179,0.15);
}

/* ─── 상태 행 ───────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.stat-row:last-child { border-bottom: none; }
.stat-label-sm { font-weight: 600; color: var(--text-muted); }
.stat-val { font-weight: 900; color: var(--text); font-size: 1.2rem; }
.stat-val.pink  { color: var(--primary); }

/* ─── 조작법 ────────────────────────────────────────────────────── */
.how-to-play { display: flex; flex-direction: column; gap: 5px; }
.htp-row {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.htp-row span { color: var(--text); }

/* ─── 마일스톤 ──────────────────────────────────────────────────── */
.milestone-list { display: flex; flex-direction: column; gap: 5px; }
.milestone-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-light);
  padding: 4px 6px;
  border-radius: 8px;
  transition: all 0.2s;
}
.milestone-row.achieved {
  color: var(--text);
  background: rgba(255,217,61,0.15);
}
.milestone-row .ms-emoji { font-size: 1.3rem; width: 24px; text-align: center; }
.milestone-row .ms-val   { flex: 1; }
.milestone-row .ms-check { color: var(--primary); font-size: 1.2rem; }

/* ─── 컨트롤 버튼 ───────────────────────────────────────────────── */
.control-btn {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 9px 12px;
  background: rgba(255,255,255,0.6);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
  text-align: left;
}
.control-btn:hover {
  background: rgba(255,122,179,0.08);
  border-color: rgba(255,122,179,0.25);
  color: var(--primary-dark);
}

/* ─── 스코어 브레이크다운 ───────────────────────────────────────── */
.score-breakdown {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  width: 100%;
  margin: 6px 0;
}
.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.score-row:last-child { border-bottom: none; }
.score-row .sval { color: var(--text); font-weight: 800; }
.score-row.total { color: var(--text); font-size: 1.4rem; font-weight: 900; margin-top: 4px; }
.score-row.total .sval { color: var(--primary); }

/* ─── 랭킹 배지 ─────────────────────────────────────────────────── */
.rank-badge { font-size: 3rem; margin: 4px 0; }
.rank-text  { font-size: 1.4rem; font-weight: 800; }
.rank-text.top3   { color: var(--accent-dark); }
.rank-text.normal { color: var(--text-muted); }

/* ─── 랭킹 테이블 ───────────────────────────────────────────────── */
.ranking-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 1.2rem;
  margin: 14px 0;
}
.ranking-table th {
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 10px;
  text-align: left;
  font-size: 1.1rem;
  border-bottom: 2px solid var(--border);
}
.ranking-table td {
  padding: 10px 10px;
  background: rgba(255,255,255,0.6);
  font-weight: 700;
  color: var(--text);
}
.ranking-table td:first-child { border-radius: 10px 0 0 10px; }
.ranking-table td:last-child  { border-radius: 0 10px 10px 0; }
.ranking-table tr:nth-child(1) td { background: rgba(255,217,61,0.15); color: #B07000; }
.ranking-table tr:nth-child(2) td { background: rgba(200,210,230,0.20); color: #5566AA; }
.ranking-table tr:nth-child(3) td { background: rgba(200,140,80,0.15);  color: #8B5500; }
.rank-medal { font-size: 1.4rem; }

/* ─── 이름 입력 ─────────────────────────────────────────────────── */
.name-input {
  font-family: var(--font);
  font-size: 1.4rem;
  font-weight: 700;
  background: rgba(255,122,179,0.06);
  border: 2px solid rgba(255,122,179,0.3);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  width: 100%;
  text-align: center;
  letter-spacing: 1px;
  outline: none;
  margin: 10px 0;
  transition: border-color 0.2s;
}
.name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,122,179,0.15);
}
.name-input::placeholder { color: var(--text-light); }

/* ─── 파티클 캔버스 ─────────────────────────────────────────────── */
#particle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

/* ─── 알림 토스트 ───────────────────────────────────────────────── */
.nb-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, var(--primary), var(--coral));
  color: #FFF;
  font-size: 1.6rem;
  font-weight: 900;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  animation: toast-in 2.2s cubic-bezier(0.22,1,0.36,1) forwards;
  white-space: nowrap;
}

@keyframes toast-in {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.8); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.05); }
  25%  { transform: translateX(-50%) translateY(0) scale(1); }
  75%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
