/* =========================================
   game.css - 2048 게임 페이지
   pages.css의 CSS 변수 재사용
   ========================================= */

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  width: min(100%, 400px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: 10px;
  background: var(--input-border);
  border-radius: var(--radius);
  touch-action: none;
}

.game-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.4rem;
  background: var(--card-bg);
  color: var(--text-primary);
}

.game-tile[data-value="0"] { background: rgba(255,255,255,0.4); }
.game-tile[data-value="2"] { background: #eee4da; }
.game-tile[data-value="4"] { background: #ede0c8; }
.game-tile[data-value="8"] { background: #f2b179; color: #fff; }
.game-tile[data-value="16"] { background: #f59563; color: #fff; }
.game-tile[data-value="32"] { background: #f67c5f; color: #fff; }
.game-tile[data-value="64"] { background: #f65e3b; color: #fff; }
.game-tile[data-value="128"] { background: #edcf72; color: #fff; font-size: 1.2rem; }
.game-tile[data-value="256"] { background: #edcc61; color: #fff; font-size: 1.2rem; }
.game-tile[data-value="512"] { background: #edc850; color: #fff; font-size: 1.2rem; }
.game-tile[data-value="1024"] { background: #edc53f; color: #fff; font-size: 1rem; }
.game-tile[data-value="2048"] { background: #edc22e; color: #fff; font-size: 1rem; }

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 400px;
  margin: 0 auto 16px;
}

.game-score-box {
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  text-align: center;
  min-width: 80px;
}

.game-score-box .label { font-size: 0.7rem; opacity: 0.7; }
.game-score-box .value { font-size: 1.2rem; font-weight: 700; }

#game-over-msg {
  text-align: center;
  margin: 16px auto;
  max-width: 400px;
  color: var(--danger);
  font-weight: 700;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
  font-size: 0.9rem;
}

.leaderboard-row.is-me {
  background: var(--accent-light);
  font-weight: 700;
}

.leaderboard-row.rank-1 { background: rgba(255, 215, 0, 0.15); }
.leaderboard-row.rank-2 { background: rgba(192, 192, 192, 0.18); }
.leaderboard-row.rank-3 { background: rgba(205, 127, 50, 0.15); }

.leaderboard-trophy {
  margin-left: 4px;
}

.leaderboard-rank {
  color: var(--text-muted);
  width: 28px;
  display: inline-block;
}

/* =========================================
   다이스 드랍 (수박게임)
   ========================================= */

.suika-canvas {
  display: block;
  width: min(100%, 400px);
  margin: 0 auto;
  background: var(--card-bg);
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  touch-action: none;
}

.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.lb-tab {
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input-border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
}

.lb-tab.active {
  background: var(--input-border);
  color: var(--text-primary);
  font-weight: 700;
}

/* =========================================
   미니게임 허브 (/games/)
   ========================================= */

.minigame-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.minigame-item {
  flex: 1 1 140px;
  display: block;
  padding: 28px 16px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
}

.minigame-item:hover {
  background: var(--accent-light);
}

/* =========================================
   1위 등극 연출 (victory.js)
   ========================================= */

.victory-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
  pointer-events: none;
  animation: victory-pop 2.2s ease-in-out forwards;
}

.victory-overlay img {
  width: min(70vw, 420px);
  height: auto;
}

.victory-overlay p {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 20px;
  border-radius: 12px;
}

@keyframes victory-pop {
  0%   { transform: scale(0);   opacity: 0; }
  12%  { transform: scale(1.1); opacity: 1; }
  18%  { transform: scale(1); }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
