.planet-shell {
  max-width: 680px;
}

.planet-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.theme-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-btn {
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  touch-action: manipulation;
}

.theme-btn.active {
  border-color: var(--yellow);
  color: #052e16;
  background: linear-gradient(135deg, var(--yellow), #f59e0b);
}

.board-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: #0d1430;
  border: 2px solid rgba(56, 189, 248, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  aspect-ratio: 1 / 1;
}

.tile {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: #ffffff;
  text-align: center;
  padding: 4px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  transition: transform 0.1s ease;
}

.tile-icon {
  font-size: clamp(1.35rem, 4.6vw, 2.05rem);
  line-height: 1.05;
}

.tile-num {
  font-size: clamp(0.75rem, 2.3vw, 0.96rem);
  line-height: 1;
  opacity: 0.95;
}

.tile.num-only .tile-num {
  font-size: clamp(1.25rem, 4.2vw, 1.85rem);
}

.tile.tile-spawn {
  animation: tileSpawn 0.18s ease-out;
}

.tile.tile-merge {
  animation: tileMerge 0.22s ease-out;
}

@keyframes tileSpawn {
  0% { transform: scale(0.55); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

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

/* Color scale per value */
.v-2 { background: linear-gradient(135deg, #1e293b, #334155); border: 1px solid rgba(255, 255, 255, 0.16); }
.v-4 { background: linear-gradient(135deg, #334155, #475569); border: 1px solid rgba(255, 255, 255, 0.2); }
.v-8 { background: linear-gradient(135deg, #c2410c, #ea580c); }
.v-16 { background: linear-gradient(135deg, #d97706, #f59e0b); color: #0b1024; }
.v-32 { background: linear-gradient(135deg, #0284c7, #0ea5e9); }
.v-64 { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.v-128 { background: linear-gradient(135deg, #0d9488, #14b8a6); color: #052e16; }
.v-256 { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.v-512 { background: linear-gradient(135deg, #be185d, #ec4899); }
.v-1024 { background: linear-gradient(135deg, #eab308, #facc15); color: #0b1024; box-shadow: 0 0 18px rgba(250, 204, 21, 0.4); }
.v-2048 { background: linear-gradient(135deg, #16a34a, #39ff6e); color: #052e16; box-shadow: 0 0 24px rgba(57, 255, 110, 0.55); }
.v-super { background: linear-gradient(135deg, #ff5ca8, #ffd84d); color: #0b1024; box-shadow: 0 0 24px rgba(255, 92, 168, 0.55); }

.board-overlay {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(11, 16, 36, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 12px;
  z-index: 10;
}

.board-overlay[hidden] {
  display: none;
}

.dpad-wrap {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 8px;
  justify-content: center;
  margin: 16px auto 6px;
}

.dpad-btn {
  height: 48px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.dpad-btn:active {
  transform: scale(0.95);
  border-color: var(--yellow);
}

.dpad-spacer {
  visibility: hidden;
}

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 28, 58, 0.65);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 999px;
}

@media (max-width: 440px) {
  .board-grid {
    gap: 8px;
    padding: 9px;
  }
  .planet-shell {
    padding: 14px;
  }
}
