/* ============================================
   Tablo — 2048 Styles
   ============================================ */

:root {
  --bg-dark: var(--bg-primary, #0f1923);
  --bg-panel: var(--bg-surface, #1a2332);
  --accent-light: #5eead4;
  --font-primary: 'Nunito', sans-serif;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px;
  gap: 24px;
}

.game-wrapper::before {
  content: '';
  display: block;
  height: 12px;
  flex-shrink: 0;
}

.game-stats {
  flex-shrink: 0;
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg-surface, #1a2332);
  border: 1px solid var(--border-color, #2a3441);
  border-radius: var(--radius-lg, 12px);
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 500px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #8892a0);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent, #2dd4bf);
  font-family: 'Nunito', monospace;
}

.grid-container {
  flex-shrink: 0;
  position: relative;
  width: 340px;
  height: 340px;
  background: var(--bg-surface, #1a2332);
  border-radius: var(--radius-lg, 12px);
  padding: 10px;
  border: 1px solid var(--border-color, #2a3441);
  touch-action: none;
}

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

.grid-cell {
  background: var(--bg-dark, #0f1923);
  border-radius: 8px;
}

.tile-container {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
}

.tile {
  position: absolute;
  width: calc(25% - 10px);
  height: calc(25% - 10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  border-radius: 8px;
  transition: top 0.15s ease, left 0.15s ease;
  margin: 5px;
}

.tile-2 { background: #1e3a3a; color: #e4e9ee; }
.tile-4 { background: #1e4751; color: #e4e9ee; }
.tile-8 { background: #2dd4bf; color: #0f1923; }
.tile-16 { background: #14b8a6; color: #0f1923; }
.tile-32 { background: #0d9488; color: #fff; }
.tile-64 { background: #0f766e; color: #fff; }
.tile-128 { background: #f59e0b; color: #0f1923; font-size: 1.6rem; }
.tile-256 { background: #d97706; color: #fff; font-size: 1.6rem; }
.tile-512 { background: #b45309; color: #fff; font-size: 1.6rem; }
.tile-1024 { background: #92400e; color: #fff; font-size: 1.3rem; }
.tile-2048 { background: #7c2d12; color: #fff; font-size: 1.3rem; box-shadow: 0 0 20px rgba(245,158,11,0.5); }

.game-controls {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.game-btn {
  background: var(--bg-surface, #1a2332);
  border: 1px solid var(--border-color, #2a3441);
  color: var(--text-primary, #e4e7eb);
  padding: 10px 20px;
  border-radius: var(--radius-md, 8px);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.game-btn:hover {
  background: var(--bg-hover, #243044);
  border-color: var(--accent, #2dd4bf);
  color: var(--accent, #2dd4bf);
}

.game-btn.primary {
  background: var(--accent, #2dd4bf);
  border-color: var(--accent, #2dd4bf);
  color: #0f1923;
}

.game-btn.primary:hover {
  background: var(--accent-light, #5eead4);
  border-color: var(--accent-light, #5eead4);
}

.game-hint {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted, #5a6e7c);
  text-align: center;
  margin-top: 8px;
}

.desktop-only { display: block; }
.mobile-only { display: none; }

.winner-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.winner-modal.visible {
  display: flex;
}

.winner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.winner-content {
  position: relative;
  z-index: 1;
  background: var(--bg-panel, #1a2332);
  border: 2px solid var(--accent, #2dd4bf);
  border-radius: var(--radius-lg, 12px);
  padding: 32px 24px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.winner-icon { font-size: 48px; margin-bottom: 16px; }
.winner-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.winner-message { font-size: 14px; color: var(--text-secondary, #8892a0); margin-bottom: 24px; }

.winner-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.tablo-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel, #1a2332);
  border: 1px solid var(--border-color, #2a3441);
  color: var(--text-primary, #e4e7eb);
  padding: 12px 24px;
  border-radius: var(--radius-md, 8px);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.tablo-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
  .grid-container { width: 300px; height: 300px; }
  .tile { font-size: 1.4rem; }
  .tile-128, .tile-256, .tile-512 { font-size: 1.2rem; }
  .tile-1024, .tile-2048 { font-size: 1rem; }
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .game-stats { gap: 16px; padding: 12px 16px; }
}

@media (max-width: 480px) {
  .game-wrapper { padding: 0 12px 12px; }
  .grid-container { width: 270px; height: 270px; }
}