/* ── 2048 Game ── */

.twenty48-container {
  background: #faf8ef;
  border-radius: var(--radius-lg, 16px);
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ── Header Bar ── */
.t48-header {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  flex-wrap: wrap;
}

.t48-title {
  font-size: 2rem;
  font-weight: 800;
  color: #776e65;
  margin: 0;
  line-height: 1;
}

.t48-scores {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.t48-score-box {
  background: #bbada0;
  border-radius: 6px;
  padding: 6px 16px;
  text-align: center;
  min-width: 64px;
}

.t48-score-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #eee4da;
}

.t48-score-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

/* ── Controls ── */
.t48-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

.t48-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  background: #8f7a66;
  color: #f9f6f2;
  transition: background 0.15s ease;
}

.t48-btn:hover { background: #9f8b77; }

.t48-btn-help {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  background: #bbada0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.t48-btn-help:hover { background: #c9b9ab; }

/* ── Power-ups ── */
.t48-powerups {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

.t48-powerup {
  flex: 1;
  padding: 7px 8px;
  border: 2px solid #d4c4b0;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  background: #ede0c8;
  color: #776e65;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
  white-space: nowrap;
  text-align: center;
}

.t48-powerup:hover:not(:disabled) {
  border-color: #8f7a66;
  background: #e4d4bc;
}

.t48-powerup:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.t48-powerup.active {
  border-color: #f59563;
  background: #f2b179;
  color: #fff;
}

.t48-powerup-count {
  display: inline-block;
  background: #bbada0;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.65rem;
  margin-left: 3px;
  vertical-align: middle;
}

.t48-powerup.active .t48-powerup-count {
  background: rgba(255, 255, 255, 0.3);
}

/* Tooltips */
.t48-powerup[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #3c3a32;
  color: #f9f6f2;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}

.t48-powerup[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #3c3a32;
  z-index: 20;
  pointer-events: none;
}

/* Mode prompt */
.t48-mode-prompt {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f59563;
  text-align: center;
  min-height: 20px;
  width: 100%;
  max-width: 420px;
}

.t48-mode-prompt:empty { display: none; }

/* ── Tutorial Overlay ── */
.t48-tutorial {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 22, 0.85);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.t48-tutorial.visible {
  opacity: 1;
  pointer-events: auto;
}

.t48-tut-card {
  background: #faf8ef;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 280px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.t48-tut-content {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.t48-tut-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.t48-tut-heading {
  font-size: 1rem;
  font-weight: 700;
  color: #776e65;
  margin: 0;
}

.t48-tut-desc {
  font-size: 0.82rem;
  color: #a09080;
  line-height: 1.4;
  margin: 0;
}

.t48-tut-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 12px 0;
}

.t48-tut-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4c4b0;
  transition: background 0.2s ease;
}

.t48-tut-dot.active {
  background: #8f7a66;
}

.t48-tut-actions {
  display: flex;
  justify-content: center;
}

.t48-tut-next {
  padding: 8px 28px;
  font-size: 0.9rem;
}

/* Tile clickable state during swap/delete */
.t48-board.pick-mode .t48-tile {
  cursor: pointer;
}

.t48-board.pick-mode .t48-tile:hover {
  outline: 3px solid #f59563;
  outline-offset: -3px;
  border-radius: 6px;
}

.t48-tile.selected-tile {
  outline: 3px solid #f65e3b !important;
  outline-offset: -3px;
}

/* ── Board ── */
.t48-board {
  position: relative;
  background: #bbada0;
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
}

.t48-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  height: 100%;
}

/* Empty cell background */
.t48-cell-bg {
  background: rgba(238, 228, 218, 0.35);
  border-radius: 6px;
}

/* ── Tile Layer ── */
.t48-tiles {
  position: absolute;
  inset: 8px;
}

.t48-tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 700;
  transition: top 0.12s ease, left 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
}

/* Tile appearance animation */
@keyframes t48-appear {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.t48-tile.new-tile {
  animation: t48-appear 0.15s ease-out;
}

@keyframes t48-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.t48-tile.merged-tile {
  animation: t48-pop 0.2s ease-out;
}

/* ── Tile Colors ── */
.t48-tile-2    { background: #eee4da; color: #776e65; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-4    { background: #ede0c8; color: #776e65; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-8    { background: #f2b179; color: #f9f6f2; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-16   { background: #f59563; color: #f9f6f2; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-32   { background: #f67c5f; color: #f9f6f2; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-64   { background: #f65e3b; color: #f9f6f2; font-size: clamp(20px, 5vw, 36px); }
.t48-tile-128  { background: #edcf72; color: #f9f6f2; font-size: clamp(17px, 4.2vw, 30px); box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2); }
.t48-tile-256  { background: #edcc61; color: #f9f6f2; font-size: clamp(17px, 4.2vw, 30px); box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3); }
.t48-tile-512  { background: #edc850; color: #f9f6f2; font-size: clamp(17px, 4.2vw, 30px); box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4); }
.t48-tile-1024 { background: #edc53f; color: #f9f6f2; font-size: clamp(14px, 3.5vw, 24px); box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5); }
.t48-tile-2048 { background: #edc22e; color: #f9f6f2; font-size: clamp(14px, 3.5vw, 24px); box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.6); }
.t48-tile-super { background: #3c3a32; color: #f9f6f2; font-size: clamp(12px, 3vw, 20px); }

/* ── Game Over Overlay ── */
.t48-game-over {
  position: absolute;
  inset: 0;
  background: rgba(238, 228, 218, 0.73);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.t48-game-over.visible {
  opacity: 1;
  pointer-events: auto;
}

.t48-game-over-text {
  font-size: 2rem;
  font-weight: 700;
  color: #776e65;
  margin-bottom: 12px;
}

.t48-game-over .t48-btn {
  font-size: 0.95rem;
  padding: 10px 24px;
}

/* ── Swipe hint (mobile) ── */
.t48-hint {
  color: #bbada0;
  font-size: 0.72rem;
  text-align: center;
}

/* ── Best Stats ── */
.t48-best-row {
  display: flex;
  gap: 16px;
  color: #bbada0;
  font-size: 0.72rem;
}

.t48-best-row span {
  color: #776e65;
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .twenty48-container { padding: 12px 8px; border-radius: 12px; }
  .t48-title { font-size: 1.5rem; }
  .t48-score-box { padding: 4px 10px; min-width: 50px; }
  .t48-score-label { font-size: 0.5rem; }
  .t48-score-value { font-size: 1rem; }
  .t48-board { padding: 6px; }
  .t48-grid { gap: 6px; }
  .t48-game-over-text { font-size: 1.5rem; }
  .t48-powerup { font-size: 0.65rem; padding: 5px 4px; }
  .t48-powerup-count { font-size: 0.58rem; padding: 1px 4px; }
  .t48-powerup[data-tooltip]:hover::after,
  .t48-powerup[data-tooltip]:hover::before { display: none; }
  .t48-tut-card { padding: 18px 20px; }
  .t48-tut-icon { font-size: 1.8rem; }
}
